:root {
  --teal: #1A6D6D;
  --teal-dark: #145656;
  --teal-deep: #0f3f3f;
  --bg: #f3f6f6;
  --paper: #ffffff;
  --ink: #1a2424;
  --muted: #5b6a6a;
  --line: #d5e0e0;
  --ok: #2c6a46;
  --ok-bg: #dcecde;
  --warn: #8a5a00;
  --warn-bg: #f3e2b8;
  --crit: #9b2c22;
  --crit-bg: #f3d4ce;
  --stale: #4d5a6a;
  --stale-bg: #d9dee6;
  --font: "Segoe UI", "Calibri", sans-serif;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
aside {
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-deep) 100%);
  color: #f4fbfb; padding: 24px 16px; display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.brand-logo { display: block; width: 168px; height: auto; }
.brand strong { display: block; }
.brand span { display: block; color: #c5e4e4; font-size: 12px; }
.brand .hub-id { font-size: 11px; opacity: 0.9; word-break: break-all; }
aside nav { display: flex; flex-direction: column; gap: 4px; }
aside nav button, .logout {
  appearance: none; border: 0; background: transparent; color: #d7ecec;
  text-align: left; padding: 10px 12px; font: 500 14px var(--font); cursor: pointer; border-radius: 8px;
}
aside nav button.active, aside nav button:hover { background: rgba(255,255,255,0.12); color: #fff; }
.logout { margin-top: auto; opacity: 0.85; }
.customer-pick-wrap {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: #c5e4e4;
}
.customer-pick-wrap select,
aside #customer-pick {
  width: 100%; min-width: 0; appearance: none;
  background: rgba(255,255,255,0.12); color: #f4fbfb;
  border: 1px solid rgba(255,255,255,0.28);
  padding: 8px 10px; border-radius: 8px; font: 500 14px var(--font);
}
.customer-pick-wrap select:hover, aside #customer-pick:focus {
  background: rgba(255,255,255,0.18); outline: none; border-color: rgba(255,255,255,0.45);
}
.customer-pick-wrap option { color: var(--ink); background: #fff; }

main { padding: 28px 32px 48px; overflow: auto; }
header { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 22px; }
header h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; }
header p { margin: 4px 0 0; color: var(--muted); }
.actions, .toolbar, .chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
input, select, textarea {
  font: 14px var(--font); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; min-width: 180px;
}
textarea { width: 100%; min-height: 180px; font-family: Consolas, monospace; }
.btn, button.btn {
  appearance: none; border: 0; background: var(--teal); color: #fff;
  padding: 8px 14px; font: 600 13px var(--font); cursor: pointer; border-radius: 8px; text-decoration: none;
}
.btn.secondary { background: transparent; color: var(--teal); border: 1px solid var(--teal); }
.btn:disabled, button.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi, .card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { font-size: 24px; }
.kpi.ok { background: var(--ok-bg); }
.kpi.warning { background: var(--warn-bg); }
.kpi.critical { background: var(--crit-bg); }
.kpi.stale { background: var(--stale-bg); }
.kpi[data-status-filter], .kpi-dot[data-status-filter], .pie-legend [data-status-filter] { cursor: pointer; }
.kpi.active, .kpi-dot.active { box-shadow: inset 0 0 0 2px var(--teal); }
.pie-legend [data-status-filter].active { font-weight: 700; }

.dash-hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px;
  align-items: center; margin-bottom: 22px;
}
.kpi-dots { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.kpi-dot {
  width: 104px; height: 104px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; border: 1px solid var(--line); background: var(--paper);
}
.kpi-dot span { display: block; font-size: 11px; font-weight: 600; margin-top: 2px; }
.kpi-dot strong { font-size: 26px; line-height: 1.1; }
.kpi-dot.neutral { background: #d7ecec; color: var(--teal-dark); border-color: #b7d8d8; }
.kpi-dot.ok { background: var(--ok-bg); color: var(--ok); border-color: #b7d7bf; }
.kpi-dot.warning { background: var(--warn-bg); color: var(--warn); border-color: #e2cc8a; }
.kpi-dot.critical { background: var(--crit-bg); color: var(--crit); border-color: #e3b3ab; }
.status-pie {
  display: flex; align-items: center; gap: 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px 12px 12px;
}
.status-pie svg { display: block; }
.pie-total { font: 700 22px var(--font); fill: var(--ink); }
.pie-caption { font: 600 11px var(--font); fill: var(--muted); }
.pie-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.pie-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.pie-legend i.ok { background: #2c6a46; }
.pie-legend i.warning { background: #c9a227; }
.pie-legend i.critical { background: #9b2c22; }

table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--teal-dark); }
th.sorted-asc::after { content: " \25B2"; font-size: 9px; }
th.sorted-desc::after { content: " \25BC"; font-size: 9px; }
tbody tr[data-open] { cursor: pointer; }
tbody tr:hover { background: #eef6f6; }
.page-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.page-toolbar .tabs { margin: 0; border-bottom: 0; padding: 0; }
.alert-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.alert-list li { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.alert-list li .btn { flex-shrink: 0; }
.disk-grid { display: flex; flex-direction: column; gap: 10px; }
.disk-item {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.disk-item.excluded { background: #f6f8f8; }
.disk-item .bar { margin-top: 8px; }
.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0 12px; }
.section-head h2 { margin: 0; }
.table-wrap { overflow: auto; }
.muted { color: var(--muted); font-size: 12px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warning { background: var(--warn-bg); color: var(--warn); }
.pill.critical { background: var(--crit-bg); color: var(--crit); }
.pill.stale { background: var(--stale-bg); color: var(--stale); }

.bar { position: relative; height: 18px; background: #edf2f2; border-radius: 6px; overflow: hidden; min-width: 90px; }
.bar div { height: 100%; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; }
.bar .ok { background: #9fd0b0; }
.bar .warning { background: #e8c56b; }
.bar .critical { background: #e39a90; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card h3 { margin: 0 0 8px; }
.settings h2, main h2 { margin: 28px 0 12px; font-size: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.token { background: #e7f4f4; padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; }
.error { color: var(--crit); }

.login-page {
  min-height: 100%; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--teal-deep), var(--teal));
}
.login-card {
  width: 400px; background: #fff; padding: 32px; border-radius: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-card .brand-logo { width: 200px; height: auto; margin-bottom: 4px; }
.login-card h1 { margin: 0; color: var(--teal); }
.login-card p { margin: 0; color: var(--muted); }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-actions { display: flex; flex-direction: column; gap: 8px; }
.totp-box { margin-top: 12px; }
.totp-qr { width: 180px; height: 180px; margin: 8px 0; }
.totp-qr svg { width: 100%; height: 100%; display: block; }
.totp-secret { font-family: Consolas, monospace; letter-spacing: 0.04em; background: #e7f4f4; padding: 8px 10px; border-radius: 8px; word-break: break-all; }

.tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 20px;
  border-bottom: 1px solid var(--line); padding: 0 4px;
}
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: 600 13px var(--font); padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--teal); background: #eef6f6; }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); background: transparent; }
.tabs.sub, #rule-tabs { margin-top: -8px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { min-width: 0; width: 100%; }
.field textarea { min-height: 88px; font-family: var(--font); }
textarea.compact, .field textarea.compact { min-height: 72px; font-family: Consolas, ui-monospace, monospace; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 16px; line-height: 1.45; }

.rule-group { margin-bottom: 22px; }
.rule-group h3 { margin: 0 0 10px; font-size: 15px; color: var(--teal-dark); }
.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rule-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.rule-card.off { opacity: 0.62; }
.rule-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rule-head strong { display: block; font-size: 14px; }
.rule-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--teal); width: 16px; height: 16px; min-width: 16px; }

.editor-list { display: flex; flex-direction: column; gap: 10px; }
.editor-row {
  display: grid; gap: 10px; align-items: end;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.editor-row.software { grid-template-columns: 52px 1.2fr 1.2fr 0.8fr auto; }
.editor-row.cert { grid-template-columns: 52px 1fr 0.7fr 1fr 1fr auto; }
.editor-row.watch { grid-template-columns: 1.2fr 1.2fr 0.8fr auto; }
.editor-row.snmp-cond { grid-template-columns: 1.4fr 0.9fr 0.8fr auto; }
.snmp-oid { color: var(--muted); font-size: 11px; font-family: Consolas, monospace; margin-top: 4px; word-break: break-all; }
table input.alias { min-width: 140px; width: 100%; }
.editor-row .remove { background: transparent; color: var(--crit); border: 1px solid var(--crit-bg); }
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px;
}
.panel h3 { margin: 0 0 6px; font-size: 16px; }
.toast {
  position: fixed; right: 24px; bottom: 24px; background: var(--teal-deep); color: #fff;
  padding: 12px 16px; border-radius: 10px; font-size: 13px; z-index: 20; box-shadow: 0 8px 24px rgba(15,63,63,0.25);
}
.drop {
  border: 1px dashed var(--line); border-radius: 12px; padding: 14px; background: #f8fbfb;
}
.drop input[type=file] { min-width: 0; width: 100%; }
.cert-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 12px 0; }
.cert-meta div { font-size: 13px; }
.cert-meta span { display: block; color: var(--muted); font-size: 11px; }
.ok-text { color: var(--ok); font-weight: 600; }

@media (max-width: 1100px) {
  .dash-hero { grid-template-columns: 1fr; }
  .status-pie { justify-content: flex-start; }
  .rule-grid, .rule-fields, .cert-meta, .editor-row.software, .editor-row.cert, .editor-row.watch, .editor-row.snmp-cond, .disk-item {
    grid-template-columns: 1fr;
  }
  .cards.four { grid-template-columns: 1fr 1fr; }
}

header .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.token code, .token textarea { display: block; width: 100%; margin: 8px 0; font-family: Consolas, monospace; font-size: 12px; }
.editor-row.wrap { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.pill.stale { background: var(--stale-bg); color: var(--stale); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .kpis, .cards, .cards.four, .grid2, .dash-hero { grid-template-columns: 1fr; }
}
