:root {
  --ink: #142d3d;
  --muted: #657681;
  --line: #dbe3e7;
  --paper: #f4f7f8;
  --white: #ffffff;
  --teal: #087f78;
  --teal-dark: #05645f;
  --teal-soft: #e7f5f3;
  --navy: #102f43;
  --amber: #d97706;
  --red: #c2413a;
  --shadow: 0 16px 45px rgba(16, 47, 67, 0.12);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, #d9f1ed 0, transparent 32%), linear-gradient(145deg, #f8fbfb, #e9f0f3); }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid rgba(8,127,120,.2); border-radius: 22px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.login-card h1 { margin: 6px 0 10px; font-size: 32px; letter-spacing: -.04em; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; color: white; background: linear-gradient(135deg, var(--teal), var(--navy)); font-weight: 900; font-size: 23px; box-shadow: 0 10px 25px rgba(8,127,120,.25); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; box-shadow: none; }
label { display: block; margin: 24px 0 8px; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--ink); background: var(--white); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,120,.12); }
.secret-field { display: flex; gap: 8px; }
.secret-field input { flex: 1; }
.icon-button { border: 0; border-radius: 9px; padding: 0 12px; color: var(--teal); background: var(--teal-soft); font-weight: 700; }
.form-error { min-height: 20px; color: var(--red); font-size: 13px; }
.button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 750; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { border: 1px solid var(--line); color: var(--ink); background: white; }
.button.danger { color: white; background: var(--red); }
.button.compact { padding: 7px 10px; font-size: 11px; }
.button.wide { width: 100%; margin-top: 20px; }
.text-button { padding: 0; border: 0; color: #b9c8d1; background: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 235px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px; color: white; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 2px; color: #9fb2be; font-size: 11px; }
nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; border-radius: 10px; color: #b9c8d1; background: transparent; text-align: left; font-weight: 700; }
.nav-item span { color: #73909f; font: 10px ui-monospace, monospace; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.09); }
.nav-item.active span { color: #54d0c4; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; }
.connection { display: flex; align-items: center; gap: 7px; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #45d6a2; box-shadow: 0 0 0 4px rgba(69,214,162,.12); }
main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 92px; padding: 20px 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.top-actions { display: flex; align-items: center; gap: 14px; font-size: 12px; }
.content { padding: 28px 32px 44px; }
.notice { margin: 16px 32px 0; padding: 12px 15px; border: 1px solid #9bd8d2; border-radius: 10px; color: var(--teal-dark); background: var(--teal-soft); }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 14px; }
.kpi { min-height: 126px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 650; }
.kpi strong { display: block; margin: 17px 0 4px; font-size: 30px; letter-spacing: -.04em; }
.kpi small { color: var(--muted); }
.kpi.good strong { color: var(--teal); }
.kpi.warn strong { color: var(--amber); }
.kpi.alert strong { color: var(--red); }
.panel { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 16px; }
.panel-body { padding: 18px 20px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar input { min-width: 240px; }
.toolbar select { width: auto; min-width: 145px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 13px; color: var(--muted); background: #f7f9fa; font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 13px; border-top: 1px solid var(--line); vertical-align: top; }
tr[data-device] { cursor: pointer; }
tr[data-device]:hover td { background: #f4fbfa; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.online, .status.completed { color: #08785f; background: #e5f6ef; }
.status.offline, .status.failed { color: var(--red); background: #fbecea; }
.status.pending, .status.acknowledged { color: #a45b08; background: #fff3df; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.payload { max-width: 430px; white-space: pre-wrap; word-break: break-word; color: #41545f; font: 11px/1.45 ui-monospace, monospace; }
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 250px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.tabs { display: flex; gap: 4px; padding: 5px; border-radius: 10px; background: #edf2f4; }
.tab { border: 0; border-radius: 7px; padding: 8px 12px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 750; }
.tab.active { color: var(--ink); background: white; box-shadow: 0 2px 7px rgba(16,47,67,.08); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(16,47,67,.35); }
.drawer { position: fixed; z-index: 21; top: 0; right: 0; width: min(620px, 100vw); height: 100vh; overflow-y: auto; padding: 26px; background: white; box-shadow: -20px 0 60px rgba(16,47,67,.18); transform: translateX(100%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; gap: 20px; }
.drawer-head h2 { margin: 5px 0 4px; font-size: 25px; }
.close { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.detail-stat { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafb; }
.detail-stat span, .detail-stat strong { display: block; }
.detail-stat span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.detail-stat strong { margin-top: 7px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { margin-top: 0; }
.command-box { margin-top: 18px; padding: 18px; border: 1px solid #b8ddd9; border-radius: 12px; background: var(--teal-soft); }
.command-box h3 { margin-top: 0; }
.credential-card { margin-top: 22px; padding: 20px; border: 1px solid #b8ddd9; border-radius: 12px; background: var(--teal-soft); }
.credential-card p { margin-top: 0; font-weight: 700; }
textarea { min-height: 100px; resize: vertical; font-family: ui-monospace, monospace; }

@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px; }
  .brand { padding-bottom: 12px; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .nav-item { justify-content: center; }
  .nav-item span { display: none; }
  .sidebar-footer { display: none; }
  .topbar { padding: 18px; }
  .top-actions .muted { display: none; }
  .content { padding: 18px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
}
