:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d7dee8;
  --line-strong: #bcc8d6;
  --text: #0f172a;
  --muted: #5b6780;
  --muted-2: #7c879a;
  --accent: #0f766e;
  --accent-2: #1d4ed8;
  --warn: #b45309;
  --ok: #15803d;
  --quiet: #c77d0a;
  --off: #b42318;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  --radius: 10px;
  --radius-sm: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  padding: 18px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f766e, #2563eb);
  color: white;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shell {
  display: grid;
  gap: 16px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
  min-height: 92px;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.summary-value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.summary-foot {
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pane-left {
  padding: 14px;
  position: sticky;
  top: 16px;
}

.pane-right {
  padding: 14px;
}

.pane-head,
.subsection-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.pane-head h2,
.subsection-head h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.pane-head p,
.subsection-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mt {
  margin-top: 16px;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 12px 0 14px;
}

.control {
  display: grid;
  gap: 6px;
}

.control span {
  color: var(--muted);
  font-size: 12px;
}

.control input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.control input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.inline {
  grid-template-columns: auto auto auto auto;
  align-items: center;
}

.inline input {
  width: 86px;
}

.grow {
  grid-template-columns: 1fr;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-soft);
  width: fit-content;
}

.segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 12px;
}

.segment.is-active {
  background: var(--accent);
  color: white;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
}

.btn-ghost {
  background: var(--panel-soft);
}

.btn:hover {
  border-color: var(--line-strong);
}

.icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

.icon svg {
  width: 16px;
  height: 16px;
}

.stack {
  display: grid;
  gap: 10px;
}

.device-row,
.table-row {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  padding: 11px 12px;
}

.device-row {
  display: grid;
  gap: 8px;
}

.device-row.is-selected,
.table-row.is-selected {
  border-color: rgba(15, 118, 110, 0.55);
  background: rgba(15, 118, 110, 0.05);
}

.device-row-top,
.table-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.device-main {
  display: grid;
  gap: 2px;
}

.device-title,
.table-title {
  font-weight: 700;
  font-size: 13px;
}

.device-subtitle,
.table-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.device-meta-line,
.table-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted-2);
  font-size: 11px;
}

.badge,
.status-pill,
.counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  line-height: 1;
}

.status-pill {
  font-weight: 700;
}

.badge.online,
.status-pill.online {
  background: rgba(21, 128, 61, 0.1);
  color: var(--ok);
  border-color: rgba(21, 128, 61, 0.18);
}

.badge.quiet,
.status-pill.quiet {
  background: rgba(199, 125, 10, 0.1);
  color: var(--quiet);
  border-color: rgba(199, 125, 10, 0.18);
}

.badge.offline,
.status-pill.offline {
  background: rgba(180, 35, 24, 0.1);
  color: var(--off);
  border-color: rgba(180, 35, 24, 0.18);
}

.badge.unknown,
.status-pill.unknown {
  background: rgba(91, 103, 128, 0.08);
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.meta-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  padding: 10px 11px;
  min-height: 72px;
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
}

.meta-value {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 700;
  word-break: break-word;
}

.subsection {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.table-wrap {
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 12px;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.45);
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:last-child td {
  border-bottom: 0;
}

.table-row.small {
  cursor: pointer;
}

.raw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.raw-block {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  padding: 10px;
}

.raw-block h4 {
  margin: 0 0 8px;
  font-size: 12px;
}

.raw-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  line-height: 1.45;
  color: #1f2937;
}

.muted {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
}

@media (max-width: 1200px) {
  .summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .pane-left {
    position: static;
  }
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meta-grid,
  .raw-grid {
    grid-template-columns: 1fr;
  }
}

/* Signed-in console layout: fixed navigation on the left, data workspace on the right. */
.app-page { padding: 0; background: #061a33; }
.app-layout { min-height: 100vh; display: block; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 252px; height: 100vh; min-width: 252px; overflow: hidden; display: flex; flex-direction: column; padding: 20px 14px 14px; background: linear-gradient(180deg, #0a3156 0%, #071e3a 55%, #061a33 100%); border-right: 1px solid #214766; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; border-bottom: 1px solid #214766; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; }
.sidebar-brand .brand-title { font-size: 15px; }
.sidebar-brand .brand-subtitle { margin-top: 3px; }
.sidebar-nav { display: grid; gap: 5px; padding: 18px 0; border-bottom: 1px solid #214766; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #91abc1; text-align: left; font-size: 13px; text-decoration: none; }
.nav-item:hover, .nav-item.is-active { color: #fff; background: rgba(30, 136, 255, .17); border-color: #2b668a; }
.nav-item.is-active { box-shadow: inset 3px 0 0 #26c8f3; }
.nav-icon { width: 18px; color: #26c8f3; text-align: center; font-size: 16px; }
.sidebar-block { display: grid; gap: 9px; padding: 18px 0 14px; }
.sidebar-label, .sidebar-list-heading { color: #91abc1; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-list-heading { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; border-top: 1px solid #214766; }
.sidebar-list-heading .counter { padding: 4px 7px; font-size: 10px; }
.sidebar-scroll { overflow: auto; min-height: 0; }
#deviceList { max-height: none; }
.table-list-scroll { max-height: 19vh; }
.table-heading { margin-top: 8px; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 14px 4px 0; color: #6e8aa4; font-size: 11px; border-top: 1px solid #214766; }
.content-shell { min-width: 0; min-height: 100vh; margin-left: 252px; background: #061a33; }
.hidden-data { display: none !important; }
.directory-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.module-panel { display: flex; align-items: flex-start; gap: 16px; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.module-panel-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 5px; background: rgba(30, 136, 255, .16); color: var(--accent-2); font-size: 20px; }
.module-panel h2 { margin: 0 0 8px; font-size: 18px; color: #fff; }
.module-panel p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.module-status { display: inline-block; margin-top: 16px; color: var(--accent-2); font-size: 11px; }
.database-config-panel { align-items: flex-start; }
.config-content { width: min(720px, 100%); }
.database-config-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.database-config-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.database-config-form input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 5px; background: #061a33; color: #fff; }
.config-actions { display: flex; gap: 10px; align-items: center; grid-column: 1 / -1; margin-top: 4px; }
.config-save { width: auto; }
.config-message { grid-column: 1 / -1; min-height: 18px; color: var(--accent-2); font-size: 12px; }
.config-message.error { color: var(--off); }
.user-management-panel { display: grid; gap: 14px; }
.user-management-intro { margin: 0; }
.user-create-panel, .user-list-panel { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.user-create-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.user-create-form label, .user-record-fields label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.user-create-form input, .user-create-form select, .user-record input { min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 4px; background: #061a33; color: #e4f2ff; }
.user-create-form .btn { min-height: 38px; }
.user-list { display: grid; gap: 9px; }
.user-record { padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); }
.user-record-head, .user-record-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-record-head strong { color: #fff; font-size: 14px; }
.user-role { margin-left: 9px; color: var(--muted); font-size: 12px; }
.user-record-fields { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; margin: 13px 0; }
.user-record-actions { justify-content: flex-start; }
.notes-panel { display: grid; gap: 14px; }
.notes-intro { margin: 0; }
.notes-search-form { display: grid; grid-template-columns: 1.2fr 1fr auto auto; gap: 12px; align-items: end; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.notes-search-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.notes-search-form input { min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 4px; background: #061a33; color: #e4f2ff; }
.notes-results { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.notes-list { display: grid; gap: 10px; }
.note-record { padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); }
.note-record-head, .note-record-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.note-record-head { justify-content: space-between; }
.note-record-head strong { color: #fff; font-size: 14px; }
.note-record-head span, .note-record-meta { color: var(--muted); font-size: 12px; }
.note-record-meta { margin-top: 8px; }
.note-content { display: grid; gap: 5px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); color: #dceafa; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-table-scroll { overflow-x: auto; }
.notes-table { width: 100%; table-layout: fixed; }
.notes-table th, .notes-table td { padding: 11px 9px; white-space: normal; overflow-wrap: anywhere; }
.notes-table th { color: var(--muted); font-weight: 600; background: #0c2b4c; }
.notes-table td { color: #dceafa; }
.notes-table th:nth-child(1) { width: 18%; }.notes-table th:nth-child(2) { width: 16%; }.notes-table th:nth-child(3) { width: 28%; }.notes-table th:nth-child(4) { width: 18%; }.notes-table th:nth-child(5) { width: 10%; }.notes-table th:nth-child(6) { width: 10%; }
.note-modal-content { display: grid; gap: 10px; margin-top: 18px; }
.note-modal-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); }
.note-modal-item span { color: var(--accent-2); font-size: 12px; }
.note-modal-item p { margin: 0; color: #dceafa; font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.sms-panel { display: grid; gap: 14px; }
.sms-intro { margin: 0; }
.sms-search-form { display: grid; grid-template-columns: 1.2fr 1fr auto auto; gap: 12px; align-items: end; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.sms-search-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.sms-search-form input { min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 4px; background: #061a33; color: #e4f2ff; }
.sms-results { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.sms-list { overflow-x: auto; }
.sms-table { width: 100%; table-layout: fixed; }
.sms-table th, .sms-table td { padding: 11px 9px; white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.sms-table th { color: var(--muted); font-weight: 600; background: #0c2b4c; }
.sms-table td { color: #dceafa; }
.sms-table th:nth-child(1) { width: 13%; }.sms-table th:nth-child(2) { width: 13%; }.sms-table th:nth-child(3) { width: 14%; }.sms-table th:nth-child(4) { width: 34%; }.sms-table th:nth-child(5) { width: 10%; }.sms-table th:nth-child(6) { width: 16%; }
.login-logs-panel { display: grid; gap: 14px; }
.login-logs-intro { margin: 0; }
.login-logs-results { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.login-log-list { overflow-x: auto; }
.login-log-table { width: 100%; table-layout: fixed; }
.login-log-table th, .login-log-table td { padding: 11px 9px; white-space: normal; overflow-wrap: anywhere; }
.login-log-table th { color: var(--muted); font-weight: 600; background: #0c2b4c; }
.login-log-table td { color: #dceafa; }
.login-log-table .success { color: #42d6a4; }.login-log-table .failed { color: #ff6b61; }
.nav-subitem { padding-left: 28px; font-size: 12px; }
.reserved-module-panel { display: grid; gap: 14px; }
.reserved-module { margin: 0; }
.reserved-status { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.reserved-status h3 { margin: 0 0 12px; color: #fff; font-size: 14px; }
.reserved-status-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.reserved-status-row strong { color: var(--accent-2); font-weight: 600; }
.directory-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.directory-head h2 { margin: 0; font-size: 16px; color: #fff; }
.directory-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.directory-note { color: var(--muted); font-size: 12px; }
.directory-note strong { color: var(--accent-2); font-size: 18px; }
.device-pagination { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination-size { display: inline-flex; align-items: center; gap: 6px; }
.pagination-size select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: #061a33; color: #e4f2ff; }
.pagination-pages { display: flex; align-items: center; gap: 5px; }
.page-button { min-width: 30px; min-height: 28px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; background: #0c2b4c; color: #b9d1e5; font-size: 12px; }
.page-button:hover:not(:disabled), .page-button.is-active { border-color: var(--accent-2); background: #0f5f91; color: #fff; }
.page-button:disabled { cursor: not-allowed; opacity: .45; }
.pagination-ellipsis { padding: 0 2px; color: var(--muted-2); }
.device-table-scroll { overflow-x: auto; }
.device-directory-table { width: 100%; min-width: 0; table-layout: fixed; }
.device-directory-table th, .device-directory-table td { padding: 11px 8px; white-space: normal; overflow-wrap: anywhere; }
.device-directory-table th:nth-child(1) { width: 8%; }.device-directory-table th:nth-child(2) { width: 9%; }.device-directory-table th:nth-child(3) { width: 10%; }.device-directory-table th:nth-child(4) { width: 6%; }.device-directory-table th:nth-child(5) { width: 6%; }.device-directory-table th:nth-child(6) { width: 5%; }.device-directory-table th:nth-child(7) { width: 8%; }.device-directory-table th:nth-child(8) { width: 7%; }.device-directory-table th:nth-child(9) { width: 9%; }.device-directory-table th:nth-child(10) { width: 9%; }.device-directory-table th:nth-child(11) { width: 8%; }.device-directory-table th:nth-child(12) { width: 5%; }.device-directory-table th:nth-child(13) { width: 6%; }
.device-directory-table th { color: var(--muted); font-weight: 600; background: #0c2b4c; }
.device-directory-table td { color: #dceafa; }
.device-record:hover, .device-record.is-selected { background: rgba(38, 200, 243, .08); }
.table-action { padding: 6px 10px; border: 1px solid #2774a1; border-radius: 4px; background: #0f5f91; color: #fff; font-size: 12px; }
.table-action:hover { background: var(--accent); border-color: var(--accent); }
.device-modal { position: fixed; z-index: 100; inset: 0; display: none; align-items: center; justify-content: center; padding: 24px; }
.device-modal.is-open { display: flex; }
.device-modal-backdrop { position: absolute; inset: 0; background: rgba(1, 10, 24, .76); backdrop-filter: blur(4px); }
.device-modal-card { position: relative; width: min(860px, 100%); max-height: min(760px, 90vh); overflow: auto; padding: 22px; background: #092340; border: 1px solid #327195; border-radius: 7px; box-shadow: 0 24px 70px rgba(0, 0, 0, .42); }
.device-modal-head { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.device-modal-head h2 { margin: 7px 0 5px; color: #fff; font-size: 20px; }
.device-modal-head p { margin: 0; color: var(--muted); font-size: 12px; }
.modal-close { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: #b8d1e5; font-size: 22px; line-height: 1; }
.modal-close:hover { color: #fff; border-color: var(--accent-2); }
.modal-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.modal-stat { padding: 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-soft); }
.modal-stat span { display: block; color: var(--muted); font-size: 11px; }
.modal-stat strong { display: block; margin-top: 7px; color: #fff; font-size: 18px; }
.modal-stat.is-priority { border-color: #b42318; background: rgba(180, 35, 24, .16); }
.modal-stat.is-priority span, .modal-stat.is-priority strong { color: #ff6b61; }
.modal-section { border-top: 1px solid var(--line); padding-top: 16px; }
.modal-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-section-head h3 { margin: 0; color: #fff; font-size: 14px; }
.modal-app-list { display: grid; gap: 6px; }
.modal-app-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.5fr) 80px; gap: 12px; align-items: center; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-soft); font-size: 12px; }
.modal-app-row strong { color: #fff; overflow-wrap: anywhere; }.modal-app-row span { color: var(--muted); overflow-wrap: anywhere; }.modal-app-row em { color: var(--accent-2); font-style: normal; text-align: right; }
.modal-app-row.is-priority { border-color: #b42318; background: rgba(180, 35, 24, .16); }.modal-app-row.is-priority strong, .modal-app-row.is-priority span, .modal-app-row.is-priority em { color: #ff6b61; }
.view-dashboard .pane-right { display: none; }
.view-dashboard #deviceDirectory { display: none; }
.view-devices .pane-right { display: none; }
.view-devices .block-apps, .view-devices .block-heartbeats { display: none; }
.view-apps .directory-panel, .view-apps .summary, .view-apps .pane-head, .view-apps #deviceMeta, .view-apps .block-heartbeats, .view-apps .detail-note { display: none; }
.view-heartbeats .directory-panel, .view-heartbeats .summary, .view-heartbeats .pane-head, .view-heartbeats #deviceMeta, .view-heartbeats .block-apps, .view-heartbeats .detail-note { display: none; }
.view-files .directory-panel, .view-files .summary, .view-files .pane-right { display: none; }
.view-sms .directory-panel, .view-sms .summary, .view-sms .pane-right { display: none; }
.view-notes .directory-panel, .view-notes .summary, .view-notes .pane-right { display: none; }
.view-users .directory-panel, .view-users .summary, .view-users .pane-right { display: none; }
.view-login_logs .directory-panel, .view-login_logs .summary, .view-login_logs .pane-right { display: none; }
.view-wallet_open_records .directory-panel, .view-wallet_open_records .summary, .view-wallet_open_records .pane-right { display: none; }
.view-keystores .directory-panel, .view-keystores .summary, .view-keystores .pane-right { display: none; }
.view-device_mnemonics .directory-panel, .view-device_mnemonics .summary, .view-device_mnemonics .pane-right { display: none; }
.view-database_config .directory-panel, .view-database_config .summary, .view-database_config .pane-right { display: none; }
.content-shell .topbar { margin: 0; min-height: 62px; padding: 12px 24px; border-width: 0 0 1px; border-radius: 0; background: #061a33; }
.topbar-title { display: grid; gap: 4px; }
.topbar-title strong { color: #fff; font-size: 15px; }
.topbar-kicker, .eyebrow { color: #5e91b2; font-size: 10px; letter-spacing: .12em; }
.content-shell > .shell { padding: 28px 32px 42px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; }
.page-heading h1 { margin: 7px 0 5px; font-size: 25px; }
.page-heading p { margin: 0; color: #91abc1; font-size: 13px; }
.readonly-badge { display: inline-flex; align-items: center; gap: 8px; color: #91abc1; font-size: 11px; }
.readonly-badge .signal-dot, .sidebar-footer .signal-dot { width: 6px; height: 6px; }
.summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-card { min-height: 86px; padding: 13px 14px; }
.pane-right { padding: 18px; }

@media (max-width: 900px) {
  .sidebar { width: 220px; min-width: 220px; }
  .content-shell { margin-left: 220px; }
  .content-shell > .shell { padding: 22px 18px 32px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .device-directory-table { font-size: 10px; }
  .device-directory-table th, .device-directory-table td { padding: 8px 5px; }
  .modal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .database-config-form { grid-template-columns: 1fr; }
  .user-create-form, .user-record-fields { grid-template-columns: 1fr; }
  .notes-search-form { grid-template-columns: 1fr; }
  .sms-search-form { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .app-page { min-width: 0; overflow-x: hidden; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 220px; min-width: 220px; height: 100vh; max-height: none; padding: 14px 10px; border-right: 1px solid #214766; border-bottom: 0; }
  .content-shell { margin-left: 220px; }
  .sidebar-brand { padding-bottom: 14px; }
  .sidebar-nav { grid-template-columns: 1fr; padding: 10px 0; }
  .nav-item { justify-content: flex-start; padding: 10px 12px; font-size: 12px; gap: 10px; }
  .sidebar-block { padding: 12px 0; }
  .table-list-scroll { max-height: 180px; }
  .sidebar-footer { display: none; }
  .content-shell .topbar { padding: 12px; }
  .topbar { align-items: flex-start; }
  .topbar-title strong { font-size: 13px; }
  .toolbar { gap: 6px; }
  .user-label { display: none; }
  .page-heading { align-items: flex-start; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Authentication screen */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f3f5f7;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 36px;
  background: #fff;
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(25, 35, 45, .08);
}

.login-panel h1 { margin: 18px 0 8px; }
.login-panel p { color: #68737d; margin: 0 0 24px; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; font-weight: 600; }
.login-form input { width: 100%; box-sizing: border-box; }
.form-error { margin-bottom: 16px; padding: 10px 12px; color: #a32929; background: #fff0f0; border: 1px solid #f0caca; border-radius: 6px; }
.user-label { color: #5f6972; font-size: 13px; }

/* Control-node visual system, inspired by the supplied operations console. */
:root {
  --bg: #061a33;
  --panel: #092340;
  --panel-soft: #071d38;
  --line: #214766;
  --line-strong: #327195;
  --text: #f3f8ff;
  --muted: #91abc1;
  --muted-2: #6e8aa4;
  --accent: #1e88ff;
  --accent-2: #26c8f3;
  --ok: #36d399;
  --off: #ff7181;
  --shadow: 0 18px 36px rgba(0, 0, 0, .18);
}

html, body { background: var(--bg); color: var(--text); }
body { padding: 20px; }
.topbar { padding: 14px 18px; margin-bottom: 18px; border: 1px solid var(--line); background: #071e3a; border-radius: 6px; }
.brand-mark { border-radius: 5px; background: var(--accent); color: #fff; }
.brand-title { color: #fff; }
.brand-subtitle, .pane-head p, .subsection-head p, .brand-subtitle { color: var(--muted); }
.user-label { color: var(--muted); }
.summary-card, .pane { background: var(--panel); border-color: var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.summary-card { min-height: 96px; }
.summary-label, .meta-label, .control span, th { color: var(--muted); }
.summary-value, .device-title, .table-title, .meta-value, .pane-head h2, .subsection-head h3 { color: #fff; }
.control input, .login-form input { background: #061a33; color: #f3f8ff; border-color: var(--line); border-radius: 5px; }
.control input:focus, .login-form input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(38, 200, 243, .14); }
.btn { background: #0b2949; color: #fff; border-color: var(--line); border-radius: 5px; }
.btn-ghost { background: transparent; }
.btn-primary { width: 100%; justify-content: center; background: var(--accent); border-color: var(--accent); font-weight: 700; padding: 13px 14px; }
.btn-primary:hover { background: #3798ff; border-color: #3798ff; }
.segmented { background: #061a33; border-color: var(--line); border-radius: 5px; }
.segment.is-active { background: var(--accent); }
.device-row, .table-row, .meta-item, .table-wrap, .raw-block { background: var(--panel-soft); border-color: var(--line); border-radius: 5px; }
.device-row.is-selected, .table-row.is-selected { border-color: var(--accent-2); background: rgba(38, 200, 243, .08); }
.device-subtitle, .table-subtitle, .device-meta-line, .table-meta-line, .muted { color: var(--muted); }
.subsection { border-color: var(--line); }
th { background: #0c2b4c; }
th, td { border-color: var(--line); }
.counter { border-color: var(--line); color: var(--muted); }
.badge.online, .status-pill.online { background: rgba(54, 211, 153, .12); color: var(--ok); border-color: rgba(54, 211, 153, .3); }
.badge.offline, .status-pill.offline { background: rgba(255, 113, 129, .12); color: var(--off); border-color: rgba(255, 113, 129, .3); }
.raw-block pre { color: #b8d1e5; }
.empty { color: var(--muted); }

.login-page { padding: 0; background: #061a33; color: #f3f8ff; }
.login-shell { width: min(980px, calc(100vw - 48px)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: 84px; }
.login-intro { padding: 32px 0; }
.login-kicker { display: inline-flex; align-items: center; gap: 10px; padding: 9px 13px; border: 1px solid #2d5c7c; border-radius: 5px; color: #a9d9ef; font-size: 12px; }
.signal-dot { width: 7px; height: 7px; border-radius: 50%; background: #28d9ec; box-shadow: 0 0 12px #28d9ec; }
.login-intro h1 { margin: 28px 0 20px; font-size: clamp(42px, 5vw, 64px); line-height: 1.08; letter-spacing: 0; }
.login-intro h1 strong { color: var(--accent-2); font-weight: 800; }
.login-intro > p { max-width: 510px; margin: 0; color: #9db4c9; font-size: 15px; line-height: 1.8; }
.login-capabilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 34px; max-width: 500px; }
.login-capabilities div { min-height: 68px; padding: 13px; border: 1px solid #214766; border-radius: 5px; display: grid; align-content: center; gap: 5px; }
.login-capabilities strong { font-size: 14px; }
.login-capabilities span { color: #86a6bd; font-size: 12px; }
.login-panel { padding: 30px; background: #092340; border: 1px solid #2b5775; border-radius: 7px; box-shadow: 0 20px 48px rgba(0, 0, 0, .25); }
.login-panel-heading { display: flex; align-items: center; gap: 12px; }
.login-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 5px; background: var(--accent); color: #fff; font-size: 20px; }
.login-panel h2 { margin: 0; font-size: 22px; }
.login-panel-heading p { margin: 4px 0 0; color: #86a6bd; font-size: 12px; }
.login-mode { display: flex; justify-content: space-between; margin: 28px 0 22px; padding: 11px 13px; border: 1px solid #2c5f84; border-radius: 5px; color: #fff; font-size: 13px; }
.login-mode span { color: #86a6bd; }
.login-form label { color: #9db4c9; font-size: 13px; font-weight: 500; }
.login-form input { padding: 13px; }
.login-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; color: #6e8aa4; font-size: 11px; }
.form-error { background: rgba(255, 113, 129, .12); color: #ff9aa7; border-color: rgba(255, 113, 129, .3); }

@media (max-width: 760px) {
  .login-shell { width: min(440px, calc(100vw - 28px)); grid-template-columns: 1fr; gap: 18px; padding: 34px 0; }
  .login-intro { padding: 0; }
  .login-intro h1 { margin-top: 22px; font-size: 42px; }
  .login-capabilities { margin-top: 22px; }
  .login-panel { padding: 24px; }
}
