:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  --bg: #eef4f8;
  --surface: #ffffff;
  --surface-soft: #f6f9fc;
  --line: #d8e2eb;
  --text: #183047;
  --muted: #687b8d;
  --primary: #0874ad;
  --primary-dark: #075b88;
  --ok: #278a55;
  --ok-soft: #e9f7ef;
  --warn: #a96d00;
  --warn-soft: #fff5d9;
  --danger: #b8443c;
  --danger-soft: #fff0ee;
  --shadow: 0 14px 36px rgba(30, 64, 90, 0.09);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }

button {
  border: 0;
  border-radius: 9px;
  padding: 11px 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease, box-shadow .16s ease;
}

button:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .65; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 20px;
  background: linear-gradient(145deg, #0788c8, #075f93);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(7, 116, 173, .24);
}

.brand-mark-small {
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 14px;
  font-size: 17px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 20%, rgba(19, 141, 198, .14), transparent 33%),
    radial-gradient(circle at 85% 75%, rgba(65, 160, 126, .12), transparent 36%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  padding: 38px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(211, 224, 234, .9);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0 0 8px; font-size: 30px; }
.login-card > .muted { margin: 0 0 26px; line-height: 1.5; }

.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 7px; font-size: 14px; font-weight: 650; }

input, select {
  width: 100%;
  border: 1px solid #c9d7e1;
  border-radius: 9px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 116, 173, .12);
}

.error-line { min-height: 20px; color: var(--danger); font-size: 13px; }

.auth-panel > h1 { margin: 0 0 8px; font-size: 30px; }
.auth-panel > .muted { margin: 0 0 26px; line-height: 1.5; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; }
.link-button {
  padding: 4px 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 650;
}
.link-button:hover { background: transparent; color: var(--primary); text-decoration: underline; }
.auth-back { margin-top: 14px; }
.full-button { width: 100%; margin-bottom: 16px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px 18px;
  background: #f7fbfe;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px; }
.sidebar-brand strong { display: block; font-size: 16px; }
.sidebar-brand small { display: block; margin-top: 3px; color: var(--muted); }

.account-card {
  display: grid;
  gap: 4px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.account-card strong { overflow: hidden; text-overflow: ellipsis; }
.account-card span { color: var(--muted); font-size: 13px; }

.sidebar nav { display: grid; gap: 6px; }

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 13px;
  background: transparent;
  color: #395166;
  text-align: left;
  font-weight: 600;
}

.nav-button:hover { background: #e9f3f9; color: var(--primary-dark); }
.nav-button.active { background: #deeff9; color: var(--primary-dark); box-shadow: inset 3px 0 var(--primary); }
.nav-button small { max-width: 74px; color: #8999a7; font-size: 10px; text-align: right; }
.nav-counter {
  display: inline-flex;
  min-width: 24px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
}

.secondary-button {
  background: #fff;
  color: var(--primary-dark);
  border: 1px solid #c9d8e3;
}

.secondary-button:hover { background: #edf6fb; }
.sidebar-logout { margin-top: auto; width: 100%; }

.workspace { min-width: 0; padding: 26px 30px 48px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto 22px;
}

.topbar h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); }
.topbar .muted { margin: 6px 0 0; }

.panel {
  display: none;
  max-width: 1440px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(31, 67, 93, .05);
}

.panel.active { display: block; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 19px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 { margin: 0; font-size: 19px; }
.panel-heading p { margin: 5px 0 0; font-size: 13px; }
.heading-actions, .form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.device-actions { justify-content: flex-end; }
.danger-button { background: #fff; color: var(--danger); border: 1px solid #e2aaa5; }
.danger-button:hover { background: var(--danger-soft); }

.inline-form, .compact-form {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
.inline-form { grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto auto; align-items: end; }
.inline-form label, .compact-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; }
.inline-form .error-line { grid-column: 1 / -1; }
.checkbox-label { display: flex !important; align-items: center; padding-bottom: 12px; white-space: nowrap; }
.checkbox-label input { width: auto; }
.compact-form { grid-template-columns: minmax(240px, 480px) auto; align-items: end; }
.compact-form .error-line { grid-column: 1 / -1; }

.counter-pill, .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e7f3fa;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.counter-neutral { background: #eef1f4; color: #586b7b; }
.status-ok { background: var(--ok-soft); color: var(--ok); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-danger { background: var(--danger-soft); color: var(--danger); }
.status-idle { background: #edf1f4; color: #71818e; }

.table-wrap { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 14px; border-bottom: 1px solid #e5ebf0; text-align: left; vertical-align: middle; }
th { background: #f8fafc; color: #617486; font-size: 12px; font-weight: 750; white-space: nowrap; }
tbody tr { cursor: pointer; transition: background .15s ease; }
tbody tr:hover { background: #f0f8fc; }
tbody tr.selected { background: #e4f3fa; }
td strong { display: block; }
td small { display: block; margin-top: 3px; color: var(--muted); }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 52px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong { color: var(--text); font-size: 17px; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 13px;
}

.overall-state {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.overall-state strong, .overall-state small { display: block; }
.overall-state small { margin-top: 4px; color: var(--muted); }
.overall-dot { width: 13px; height: 13px; border-radius: 50%; background: #8796a3; box-shadow: 0 0 0 5px rgba(135,150,163,.13); }
.state-ok .overall-dot { background: var(--ok); box-shadow: 0 0 0 5px rgba(39,138,85,.13); }
.state-warn .overall-dot { background: #d29213; box-shadow: 0 0 0 5px rgba(210,146,19,.14); }
.state-danger .overall-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(184,68,60,.13); }

.state-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  padding: 0 20px 22px;
}

.state-card {
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.state-card span { display: block; color: var(--muted); font-size: 12px; }
.state-card strong { display: block; margin-top: 12px; font-size: 18px; }
.state-card small { display: block; margin-top: 8px; color: var(--muted); }
.state-card.status-ok { border-color: #bfe1cd; background: var(--ok-soft); }
.state-card.status-warn { border-color: #edd79d; background: var(--warn-soft); }
.state-card.status-danger { border-color: #edc3bf; background: var(--danger-soft); }

.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.roadmap-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.roadmap-grid strong, .roadmap-grid span { display: block; }
.roadmap-grid span { margin-top: 7px; color: var(--muted); line-height: 1.45; }
.developer-summary strong { margin-top: 8px; font-size: 28px; color: var(--ink); }
.developer-summary span { margin-top: 0; }
.developer-summary .developer-date { font-size: 17px; line-height: 1.35; }
.developer-summary small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.4; }
.developer-users-heading { margin-top: 26px; }
.developer-heading-actions { display: flex; align-items: center; gap: 10px; }
.developer-filter {
  min-width: 230px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
}
.developer-inline-select {
  min-width: 132px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.developer-row-actions, .developer-device-actions { display: grid; gap: 7px; min-width: 155px; }
.small-button { padding: 8px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; }
.developer-mini-check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.developer-mini-check input { width: auto; }
#developerPanel tbody tr { cursor: default; }
.capability-note {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.capability-note > div {
  padding: 16px 18px;
  border: 1px dashed #c5ced7;
  border-radius: 12px;
  background: #f7f9fb;
}
.capability-note strong, .capability-note span { display: block; }
.capability-note span { margin-top: 6px; color: var(--muted); line-height: 1.45; }

.section-heading { padding: 17px 20px 10px; }
.section-heading h3 { margin: 0; font-size: 16px; }
.section-divider { margin-top: 8px; border-top: 1px solid var(--line); }
.notification-list { display: grid; gap: 12px; padding: 6px 20px 20px; }
.notification-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px;
  border: 1px solid #edc3bf;
  border-radius: 12px;
  background: var(--danger-soft);
}
.notification-card h3 { margin: 10px 0 6px; font-size: 17px; }
.notification-card p { margin: 0; line-height: 1.45; }
.notification-meta { margin-top: 9px; color: var(--muted); font-size: 12px; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  padding: 20px;
}
.profile-grid article { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.profile-grid span, .profile-grid strong, .profile-grid small { display: block; }
.profile-grid span, .profile-grid small { color: var(--muted); }
.profile-grid span { font-size: 12px; }
.profile-grid strong { margin-top: 8px; }
.profile-grid small { margin-top: 6px; }
.profile-form { margin: 0 20px 20px; border: 1px solid var(--line); border-radius: 12px; }
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 20px 20px;
  padding: 17px;
  border: 1px solid #edc3bf;
  border-radius: 12px;
  background: var(--danger-soft);
}
.danger-zone strong, .danger-zone span { display: block; }
.danger-zone span { margin-top: 5px; color: var(--muted); font-size: 13px; }

.error-banner {
  max-width: 1440px;
  margin: 0 auto 16px;
  padding: 13px 15px;
  border: 1px solid #efc6c2;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(380px, calc(100vw - 44px));
  padding: 13px 16px;
  border-radius: 10px;
  background: #19384f;
  color: #fff;
  box-shadow: var(--shadow);
}

.mobile-menu-button { display: none; }
.mobile-backdrop { display: none; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    width: min(290px, 86vw);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  body.mobile-menu-open { overflow: hidden; }
  body.mobile-menu-open .sidebar { transform: translateX(0); }
  .mobile-menu-button {
    display: block;
    position: fixed;
    left: 16px;
    top: 16px;
    z-index: 18;
    width: 42px;
    height: 42px;
    padding: 0;
  }
  .mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    background: rgba(12, 31, 45, .42);
  }
  .workspace { padding: 72px 16px 34px; }
  .state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .login-view { padding: 14px; }
  .login-card { padding: 26px 22px; border-radius: 16px; }
  .topbar, .panel-heading { align-items: stretch; flex-direction: column; }
  .topbar > button, .panel-heading > button { width: 100%; }
  .heading-actions, .device-actions { align-items: stretch; flex-direction: column; }
  .heading-actions > button { width: 100%; }
  .state-grid, .roadmap-grid { grid-template-columns: 1fr; }
  .inline-form, .compact-form, .profile-grid { grid-template-columns: 1fr; }
  .inline-form .error-line, .compact-form .error-line { grid-column: auto; }
  .checkbox-label { padding-bottom: 0; }
  .notification-card, .danger-zone { align-items: stretch; flex-direction: column; }
  .pagination-bar { align-items: stretch; flex-direction: column; }
  .pagination-bar button { width: 100%; }
  .notification-card > button, .danger-zone > button { width: 100%; }
  .profile-form { margin: 0 14px 14px; }
  .danger-zone { margin: 0 14px 14px; }
  .capability-note { grid-template-columns: 1fr; }
  .developer-heading-actions { width: 100%; align-items: stretch; }
  .developer-filter { width: 100%; min-width: 0; }
  .state-grid { padding: 0 14px 16px; }
  .overall-state { margin: 14px; }
  th, td { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
