:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f3f5f8;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  min-height: 68px;
  background: #101827;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand, .top-actions, .brand > div {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand > div { align-items: flex-start; flex-direction: column; gap: 1px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #fff;
  color: #111827;
  font-weight: 900;
  font-size: 13px;
}
.revision { color: #9ca3af; font-size: 11px; }
.env {
  background: #fbbf24;
  color: #111827;
  font-weight: 900;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
}
.profile-compact { color: #e5e7eb; font-size: 13px; }

.login-wrap {
  min-height: calc(100vh - 68px);
  display: grid;
  place-items: center;
  padding: 28px;
}
.card, .panel {
  background: #fff;
  border: 1px solid #e7eaf0;
  border-radius: 18px;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.07);
}
.login-card { width: min(100%, 480px); padding: 30px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(25px, 3vw, 34px); margin-bottom: 8px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-bottom: 14px; }
.eyebrow {
  color: #4f46e5;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .13em;
  margin-bottom: 7px;
}
.muted { color: #6b7280; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

label {
  display: block;
  font-weight: 700;
  margin: 17px 0;
}
input, select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #cfd5df;
  border-radius: 10px;
  background: #fff;
  margin-top: 7px;
  outline: none;
}
input:focus, select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.button {
  border: 0;
  border-radius: 10px;
  padding: 11px 15px;
  font-weight: 800;
}
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { color: #fff; background: #111827; }
.button.secondary { color: #111827; background: #e7eaf0; }
.button.full { width: 100%; }
.button.center { display: block; margin: 18px auto 0; }
.message { min-height: 24px; color: #b91c1c; margin: 16px 0 0; }

.app-shell {
  min-height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
}
.sidebar {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 22px 14px;
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
}
.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 800;
  color: #4b5563;
  margin-bottom: 5px;
}
.nav-item.active { color: #fff; background: #111827; }
.sidebar-note {
  margin-top: 28px;
  padding: 13px;
  border-radius: 12px;
  background: #eef2ff;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #4338ca;
}

.workspace { min-width: 0; padding: 28px; }
.view { max-width: 1400px; margin: 0 auto; }
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}
.page-heading h1 { margin-bottom: 5px; }
.health-banner {
  padding: 13px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
  border: 1px solid #a7f3d0;
}
.health-banner[data-state="DEGRADED_R2"] { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.health-banner[data-state="UNHEALTHY_D1"] { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 15px;
  padding: 17px;
  min-width: 0;
}
.metric-label, .metric-note { display: block; color: #6b7280; font-size: 12px; }
.metric-value { display: block; font-size: 28px; margin: 7px 0 4px; }

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.panel { padding: 18px; box-shadow: none; }
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  border-bottom: 1px solid #edf0f4;
  margin-bottom: 6px;
}
.list-row { padding: 13px 1px; border-bottom: 1px solid #edf0f4; }
.list-row:last-child { border-bottom: 0; }
.list-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list-summary { color: #4b5563; margin: 7px 0 4px; font-size: 13px; }
.list-meta { color: #9ca3af; font-size: 11px; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2f7;
  color: #475569;
  font-size: 10px;
  font-weight: 900;
}
.badge[data-status="ACTIVE"], .badge[data-status="SUCCESS"], .badge[data-status="INFO"] {
  color: #047857; background: #d1fae5;
}
.badge[data-status="DISABLED"], .badge[data-status="FAILED"], .badge[data-status="CRITICAL"] {
  color: #b91c1c; background: #fee2e2;
}
.badge[data-status="SECURITY_LOCKED"], .badge[data-status="REJECTED"], .badge[data-status="WARNING"] {
  color: #92400e; background: #fef3c7;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-bar input, .filter-bar select { margin-top: 0; }
.table-panel { padding: 8px; }
.account-table { display: grid; gap: 5px; }
.account-row {
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: minmax(210px, 1.4fr) minmax(220px, 1fr) 170px;
  gap: 18px;
  text-align: left;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
}
.account-row:hover { background: #f5f7fb; }
.account-identity, .account-state {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.account-counts { display: flex; flex-wrap: wrap; gap: 9px; color: #4b5563; font-size: 12px; }
.account-state { align-items: flex-end; }

.drawer {
  position: fixed;
  right: 0;
  top: 68px;
  width: min(480px, 100vw);
  height: calc(100vh - 68px);
  overflow: auto;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -20px 0 55px rgba(15, 23, 42, .14);
  z-index: 30;
  padding: 22px;
}
.drawer-head, .drawer-status {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
}
.icon-button {
  border: 0;
  background: #eef1f5;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 25px;
}
.drawer-status {
  align-items: center;
  padding: 13px;
  background: #f8fafc;
  border-radius: 12px;
  margin-bottom: 15px;
}
.drawer-section {
  padding: 17px 0;
  border-bottom: 1px solid #e5e7eb;
}
.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 13px;
}
.detail-line strong { text-align: right; word-break: break-word; }
.device-card {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  margin-bottom: 9px;
}
.telemetry-label {
  margin: 11px 0 4px;
  color: #4f46e5;
  font-size: 11px;
  font-weight: 900;
}
.alert { padding: 13px 15px; border-radius: 11px; margin-bottom: 15px; }
.alert.error { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }
.empty { color: #9ca3af; text-align: center; padding: 20px 8px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: 1fr; gap: 9px; }
  .account-state { align-items: flex-start; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .profile-compact, .revision { display: none; }
  .app-shell { display: block; }
  .sidebar {
    height: auto;
    position: sticky;
    top: 68px;
    z-index: 20;
    display: flex;
    gap: 6px;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }
  .nav-item { width: auto; margin: 0; }
  .sidebar-note { display: none; }
  .workspace { padding: 18px 12px; }
  .page-heading { display: block; }
  .page-heading .button { margin-top: 10px; }
  .filter-bar { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .top-actions { gap: 7px; }
  .login-wrap { padding: 15px; }
  .login-card { padding: 22px; }
}
