/* Server Health - admin panel styles. Light theme only. No external fonts or libraries. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1d2433;
  --text-2: #4b5565;
  --muted: #7a8497;

  --primary: #16191f;
  --primary-hover: #000000;
  --primary-soft: #eceef1;
  --primary-ring: rgba(22, 25, 31, .16);
  --header-bg: #0f1111;           /* AWS-style black header strip (brand cell + top bar) */
  --header-text: #f2f3f3;
  --header-muted: #9ba7b6;
  --header-border: #2f353d;
  --header-hover: #232a31;

  --success: #1c7c54; --success-soft: #e8f5ee;
  --danger: #b42318;  --danger-soft: #fdeceb;
  --warning: #9a5b05; --warning-soft: #fdf3e0;
  --info: #2563a8;    --info-soft: #e8f1fb;
  --neutral: #5b6577; --neutral-soft: #eef0f3;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mb { margin-bottom: 14px; } .mt { margin-top: 14px; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { padding: 26px 32px 48px; width: 100%; max-width: 1560px; margin-inline: auto; outline: none; }  /* extra width is split equally left/right */
.main.is-loading { opacity: .55; transition: opacity .15s; pointer-events: none; }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 20px; font-weight: 650; font-size: 15.5px; color: var(--header-text); background: var(--header-bg); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #fff; color: #0f1111; display: grid; place-items: center; }
.brand-mark .icon { width: 17px; height: 17px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-2); font-weight: 500; cursor: pointer; text-align: left; }
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link .icon { color: var(--muted); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link.active .icon { color: var(--primary); }
.nav-parent span { flex: 1; }
.nav-parent .chev { width: 15px; height: 15px; transition: transform .18s; }
.nav-group.open > .nav-parent .chev { transform: rotate(180deg); }
.nav-children { display: none; flex-direction: column; gap: 2px; margin: 2px 0 4px 20px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-group.open > .nav-children { display: flex; }
.nav-children .nav-link { padding: 7px 10px; font-size: 13.5px; }
.sidebar-foot { padding: 14px 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.sidebar-overlay { display: none; }

/* ---------- Topbar ---------- */
.topbar { height: var(--topbar-h); background: var(--header-bg); color: var(--header-text); border-bottom: 1px solid var(--header-border); display: flex; align-items: center; gap: 14px; padding: 0 28px; position: sticky; top: 0; z-index: 30; }
.topbar-spacer { flex: 1; }
.topbar .menu-btn { display: none; color: var(--header-muted); }
.topbar .menu-btn:hover { background: var(--header-hover); color: #fff; }
.company-switch, .company-chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 1px solid var(--header-border); border-radius: var(--radius-sm); background: var(--header-hover); color: var(--header-text); }
.company-switch .icon, .company-chip .icon { color: var(--header-muted); width: 16px; height: 16px; }
.company-switch-label { font-size: 12px; color: var(--header-muted); }
.company-switch { cursor: pointer; font: inherit; transition: background .12s, border-color .12s; }
.company-switch:hover { background: #2c343c; border-color: #454d57; }
.company-switch:focus-visible { outline-color: #fff; }
.company-switch-name { font-weight: 600; color: var(--header-text); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-switch .chev { width: 15px; height: 15px; margin-left: 2px; }
.company-chip { font-weight: 600; color: var(--header-text); }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; color: var(--header-text); }
.user-btn:hover { background: var(--header-hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 650; }
.topbar .avatar { background: #fff; color: #0f1111; }
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.user-meta small { color: var(--header-muted); font-size: 12px; }
.user-btn .chev { width: 15px; height: 15px; color: var(--header-muted); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-head small { color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; color: var(--text-2); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.menu-item .icon { color: var(--muted); }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: none; }
.breadcrumbs .icon { width: 14px; height: 14px; }
.breadcrumbs .sep { width: 13px; height: 13px; opacity: .6; }
.breadcrumbs .current { color: var(--text-2); font-weight: 500; }
.page-actions { display: flex; gap: 10px; }
.section-title { font-size: 15px; font-weight: 650; margin: 28px 0 12px; }
.scope-note { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-bottom: 16px; font-size: 13px; }
.scope-note .icon { width: 15px; height: 15px; }
.scope-note strong { color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 550; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; border-color: #912018; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-lg { height: 42px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.btn-primary):not(.btn-danger).is-busy::after { border-color: var(--border-strong); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.copy-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; background: none; border-radius: 5px; color: var(--muted); cursor: pointer; vertical-align: middle; }
.copy-btn:hover { background: var(--bg); color: var(--primary); }
.copy-btn .icon { width: 14px; height: 14px; }
.link-sm { font-size: 13px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; font-weight: 650; }
.card-body { padding: 20px; }
.card-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-foot-link { padding: 0 20px 18px; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stack-narrow { max-width: 760px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 18px 20px; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; }
.tone-neutral { background: var(--neutral-soft); color: var(--neutral); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-info { background: var(--info-soft); color: var(--info); }
.stat-body { display: flex; flex-direction: column; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; }

/* ---------- Lists / key-value ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list-main { display: flex; flex-direction: column; min-width: 0; }
.list-main a, .list-main span { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main small { color: var(--muted); font-size: 12.5px; }
.list-plain li { padding: 11px 20px; color: var(--text-2); }
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--neutral-soft); color: var(--text-2); font-size: 12px; font-weight: 550; margin: 1px 2px 1px 0; }
.empty-inline { display: flex; align-items: center; gap: 10px; padding: 26px 20px; color: var(--muted); }
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state-lg { max-width: 460px; margin: 40px auto; }
.empty-state h2 { color: var(--text); font-size: 18px; margin: 6px 0; }
.empty-state p { margin-bottom: 20px; }
.empty-code { font-size: 54px; font-weight: 700; color: var(--border-strong); letter-spacing: -.03em; line-height: 1; }

/* ---------- Banners / notes ---------- */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 18px; }
.banner .icon { margin-top: 2px; }
.banner-warning { background: var(--warning-soft); border-color: #f3dfb4; color: #6f4204; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--primary-soft); color: var(--text-2); border-radius: var(--radius-sm); font-size: 13px; margin-top: 6px; }
.note .icon { width: 16px; height: 16px; margin-top: 2px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }

/* ---------- Data tables ---------- */
.dt { overflow: hidden; }
.dt-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dt-search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; flex: 1 1 260px; max-width: 380px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.dt-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.dt-search .icon { color: var(--muted); width: 16px; height: 16px; }
.dt-search input[type=search], .dt-search input[type=search]:focus { flex: 1; border: 0; box-shadow: none; outline: none; background: none; min-width: 0; height: 100%; padding: 0; }
.dt-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; transition: opacity .15s; }
.dt.is-loading .table-wrap { opacity: .5; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.cell-title { display: block; font-weight: 600; color: var(--text); }
a.cell-title:hover { color: var(--primary); }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); }
.cell-text { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.row-actions { display: inline-flex; gap: 2px; }
.table .empty-row td { text-align: center; padding: 44px 16px; color: var(--muted); }
.dt-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.dt-info { color: var(--muted); font-size: 13px; }
.dt-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dt-per { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dt-per select { height: 30px; padding: 0 24px 0 8px; font-size: 13px; }
.pager { display: flex; gap: 4px; }
.pager button { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text-2); cursor: pointer; display: inline-grid; place-items: center; }
.pager button:hover:not([disabled]):not(.active) { background: var(--bg); }
.pager button.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 650; }
.pager button[disabled] { opacity: .4; cursor: default; }
.pager .gap { display: inline-grid; place-items: center; min-width: 24px; color: var(--muted); }
.pager .icon { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.form-narrow { max-width: 720px; }
.field { margin-bottom: 18px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.field-wrap > .field { margin-bottom: 18px; }
label { display: block; font-weight: 550; margin-bottom: 6px; color: var(--text); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s;
}
input[type=search] { -webkit-appearance: none; appearance: none; }
textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8497' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.dt-filters select, .dt-per select { width: auto; height: 36px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input:disabled { background: var(--bg); color: var(--muted); }
input::placeholder, textarea::placeholder { color: #a3acba; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; min-height: 0; }
.field-error:empty { display: none; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.input-addon { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; background: var(--surface-2); color: var(--text-2); cursor: pointer; font-weight: 550; white-space: nowrap; }
.input-addon:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-addon:hover { background: var(--bg); color: var(--primary); }
.input-addon .icon { width: 16px; height: 16px; }
.form-error, .form-success { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 18px; }
.form-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f6cfcb; }
.form-success { background: var(--success-soft); color: var(--success); border: 1px solid #c7e6d5; }

/* ---------- Secrets / connection details / meters ---------- */
.secret { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.secret code { flex: 1; letter-spacing: .04em; font-size: 13.5px; word-break: break-all; }
.secret-inline { display: inline-flex; padding: 2px 4px 2px 10px; }
.conn { display: flex; flex-direction: column; gap: 12px; }
.conn > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.conn > div > span:first-child { flex: 0 0 100%; font-size: 12px; color: var(--muted); }
.conn code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; }
.meters { display: flex; flex-direction: column; gap: 16px; }
.meter-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; color: var(--text-2); }
.meter-top span { display: inline-flex; align-items: center; gap: 8px; }
.meter-top .icon { width: 16px; height: 16px; color: var(--muted); }
.bar { height: 8px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.bar.tone-warning i { background: #d9922b; } .bar.tone-danger i { background: #d4493d; } .bar.tone-ok i { background: #3f9a76; }

/* ---------- Dialogs / toasts / progress ---------- */
dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: var(--shadow-lg); width: min(460px, calc(100vw - 32px)); color: var(--text); }
dialog.dialog-wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog-body { padding: 22px 24px 8px; }
.dialog-body h3 { font-size: 17px; font-weight: 650; margin-bottom: 8px; }
.dialog-body p { color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h3 { font-size: 15px; font-weight: 650; }

/* company picker modal */
dialog.dialog-picker { width: min(480px, calc(100vw - 32px)); margin: 12vh auto auto; overflow: hidden; }
dialog.dialog-picker[open] { display: flex; flex-direction: column; max-height: min(640px, 76vh); }
.picker-search { display: flex; align-items: center; gap: 10px; padding: 0 20px; height: 52px; border-bottom: 1px solid var(--border); color: var(--muted); flex: none; }
.picker-search input { flex: 1; border: 0; outline: none; box-shadow: none; background: transparent; height: 100%; padding: 0; font-size: 14.5px; color: var(--text); }
.picker-search input:focus { box-shadow: none; }
.picker-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; min-height: 0; }
.picker-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; cursor: pointer; color: var(--text); }
.picker-item:hover, .picker-item:focus-visible { background: var(--bg); outline: none; }
.picker-item.is-current { background: var(--primary-soft); }
.picker-item.is-busy { opacity: .6; pointer-events: none; }
.picker-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--neutral-soft); color: var(--text-2); }
.picker-item.is-current .picker-ico { background: var(--primary); color: #fff; }
.picker-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.picker-txt strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-txt small { color: var(--muted); font-size: 12px; }
.picker-check { display: grid; place-items: center; color: var(--primary); }
.picker-empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.picker-foot { padding: 10px 20px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 12.5px; flex: none; }
.payload { margin: 0; padding: 18px 20px; max-height: 60vh; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; }
.toast .icon { margin-top: 1px; }
.toast.success { border-left-color: var(--success); } .toast.success .icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); } .toast.error .icon { color: var(--danger); }
.toast.info { border-left-color: var(--primary); } .toast.info .icon { color: var(--primary); }
.toast-msg { flex: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--primary); z-index: 120; opacity: 0; transition: width .3s ease, opacity .25s; }
.progress.active { opacity: 1; }

/* ---------- Auth pages ---------- */
.auth-body { background: var(--surface); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 5fr) 6fr; }
.auth-aside { background: linear-gradient(160deg, #eceef1 0%, #f3f4f6 60%, #f9fafb 100%); border-right: 1px solid var(--border); padding: 28px 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside .brand, .auth-brand-mobile { padding: 0; background: none; color: var(--text); }
.auth-aside .brand-mark, .auth-brand-mobile .brand-mark { background: var(--header-bg); color: #fff; }
.brand-lg { font-size: 17px; }
.auth-aside-copy { max-width: 420px; }
.auth-aside-copy h2 { font-size: 28px; line-height: 1.25; letter-spacing: -.02em; font-weight: 650; margin-bottom: 14px; }
.auth-aside-copy p { color: var(--text-2); font-size: 15px; margin-bottom: 26px; }
.auth-aside-copy ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; color: var(--text-2); }
.auth-aside-copy li { display: flex; gap: 12px; align-items: center; }
.auth-aside-copy li .icon { color: var(--primary); }
.auth-aside-foot { color: var(--muted); font-size: 12.5px; }
.auth-main { display: grid; place-items: center; padding: 32px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand-mobile { display: none; padding: 0; margin-bottom: 28px; height: auto; }
.auth-head { margin-bottom: 26px; }
.auth-head h1 { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-head p { color: var(--muted); }
.auth-foot { margin-top: 22px; text-align: center; }
.auth-foot a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; }
.auth-foot .icon { width: 15px; height: 15px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 35; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .main { padding: 20px 16px 40px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .user-meta, .user-btn .chev, .company-switch-label { display: none; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .kv > div { grid-template-columns: 1fr; gap: 2px; }
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-brand-mobile { display: flex; }
}

/* ---------- Server page: tabs, time range, charts, snapshot ---------- */
.text-warning { color: var(--warning); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; font-weight: 550; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

.range-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 10px 14px; margin-bottom: 18px; }
.seg-group { display: inline-flex; padding: 3px; background: var(--neutral-soft); border-radius: var(--radius-sm); gap: 2px; }
.seg { border: 0; background: none; padding: 5px 13px; border-radius: 5px; font-weight: 550; font-size: 13px; color: var(--text-2); cursor: pointer; text-decoration: none; line-height: 1.5; }
.seg:hover { color: var(--text); text-decoration: none; }
.seg.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.range-custom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.range-custom label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.range-custom input[type=date] { height: 32px; width: auto; padding: 0 8px; }
.range-info { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.range-info strong { color: var(--text-2); font-weight: 600; }
.range-notice { flex-basis: 100%; display: flex; align-items: center; gap: 8px; color: var(--warning); font-size: 13px; }
.range-notice .icon { width: 15px; height: 15px; }

.stat-sub { color: var(--muted); font-size: 12px; line-height: 1.3; margin-top: 1px; }
.stat-grid .stat-body { min-width: 0; }
.stat-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 8px; }
.chart-card .card-head { padding: 12px 16px; }
.chart-card .card-head h2 { font-size: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .chart-tip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.chart-body { position: relative; padding: 6px 4px 0; min-height: 196px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .grid.v { stroke-dasharray: 2 4; opacity: .7; }
.chart-svg .grid.base { stroke: var(--border-strong); }
.chart-svg .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-svg .cross { stroke: var(--border-strong); stroke-width: 1; }
.chart-msg { height: 190px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 8px 10px; background: var(--header-bg); color: #fff; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow-lg); }
.chart-tip strong { display: block; margin-bottom: 4px; font-weight: 600; color: #d6dae0; }
.chart-tip div { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.chart-tip span { flex: 1; color: #c0c6cf; }
.chart-tip b { font-weight: 600; }

.section-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.section-title .btn { margin-left: auto; }

.snap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.snap-wide { grid-column: 1 / -1; }
.kv-compact > div { padding: 9px 20px; grid-template-columns: 130px 1fr; }
.kvgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 28px; margin: 0; }
.kvgrid > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kvgrid dt { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.kvgrid dd { margin: 0; font-weight: 550; text-align: right; overflow-wrap: anywhere; }
.bar-sm { height: 6px; margin-top: 6px; }
.usage { display: flex; align-items: center; gap: 8px; }
.usage .bar { flex: 1; margin: 0; }
.usage span { width: 34px; text-align: right; font-size: 12.5px; color: var(--text-2); }
.table-compact th, .table-compact td { padding-top: 9px; padding-bottom: 9px; }
.svc-list li { padding: 9px 20px; }
.list-block { align-items: flex-start; }
.git-status { margin: 6px 0 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.help.mb { margin-bottom: 12px; }

@media (max-width: 1100px) {
  .chart-grid, .snap-grid { grid-template-columns: minmax(0, 1fr); }
  .range-info { margin-left: 0; }
}

.stat-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat-grid-6 .stat { padding: 14px 14px; gap: 11px; }
.stat-grid-6 .stat-icon { width: 36px; height: 36px; flex: none; }
.stat-grid-6 .stat-value { font-size: 22px; }
@media (max-width: 1320px) { .stat-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .stat-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.table .num { white-space: nowrap; }

/* ---------- Slide-over drawer (add / edit forms) ---------- */
body.drawer-open { overflow: hidden; }
.drawer-root { position: fixed; inset: 0; z-index: 90; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); opacity: 0; transition: opacity .22s ease; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); display: flex; flex-direction: column; background: var(--surface); box-shadow: -12px 0 32px rgba(16, 24, 40, .16); transform: translateX(100%); transition: transform .24s cubic-bezier(.22, .8, .3, 1); }
.drawer-root.open .drawer { transform: none; }
.drawer-root.open .drawer-backdrop { opacity: 1; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--topbar-h); padding: 0 12px 0 24px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.drawer-body > .stack { gap: 0; flex: 1; }
.drawer .card { border: 0; border-radius: 0; box-shadow: none; }
.drawer .form-narrow { max-width: none; }
.drawer .field-row { grid-template-columns: minmax(0, 1fr); }
.drawer-body > form.card { flex: 1; display: flex; flex-direction: column; }
.drawer-body > form.card > .card-body { flex: 1; }
.drawer .card-body { padding: 22px 24px; }
.drawer .card-head { padding: 14px 24px; background: var(--surface-2); border-top: 1px solid var(--border); }
.drawer .card-footer { position: sticky; bottom: 0; padding: 14px 24px; border-radius: 0; }
.drawer .stack > form.card + form.card { border-top: 1px solid var(--border); }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-backdrop { transition: none; } }
.drawer .field-row > .field:last-child { margin-bottom: 18px; }   /* rows are stacked in the drawer */
@media (max-width: 900px) { .field-row > .field:last-child { margin-bottom: 18px; } }

/* ---------- Themed dropdown (replaces the native <select>; see UISelect in app.js) ---------- */
.ui-select { position: relative; display: block; width: 100%; min-width: 0; }
.dt-filters .ui-select, .dt-per .ui-select { display: inline-block; width: auto; }
select.ui-select-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; background-image: none; }
.ui-select-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; outline: none; transition: border-color .12s, box-shadow .12s, background .12s; }
.ui-select-btn:hover:not(:disabled) { border-color: #b4bcc9; }
.ui-select-btn:focus-visible, .ui-select.is-open .ui-select-btn { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.ui-select-btn .icon { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform .15s; }
.ui-select.is-open .ui-select-btn .icon { transform: rotate(180deg); color: var(--text); }
.ui-select-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field .ui-select.is-placeholder .ui-select-label { color: #a3acba; }
/* invisible copy of the longest option so auto-width dropdowns (table filters) keep a stable width */
.ui-select-sizer { display: none; height: 0; overflow: hidden; visibility: hidden; white-space: nowrap; }
.dt-filters .ui-select-sizer, .dt-per .ui-select-sizer { display: block; width: 0; flex: none; }
.dt-filters .ui-select-btn, .dt-per .ui-select-btn { height: 36px; width: auto; }
.dt-filters .ui-select-btn { min-width: 130px; }
.dt-per .ui-select-btn { height: 30px; padding: 0 8px 0 10px; font-size: 13px; min-width: 62px; }
.ui-select.is-disabled .ui-select-btn { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.field.has-error .ui-select-btn { border-color: var(--danger); }
.ui-select-pop { position: fixed; z-index: 120; overflow-y: auto; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: ui-pop .12s ease-out; transform-origin: top; }
.ui-select-pop.is-up { transform-origin: bottom; }
@keyframes ui-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.ui-select-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text-2); cursor: pointer; line-height: 1.35; user-select: none; }
.ui-select-opt.is-grouped { padding-left: 18px; }
.ui-select-opt-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-opt .icon { width: 16px; height: 16px; flex: none; color: var(--primary); opacity: 0; }
.ui-select-opt.is-active { background: var(--bg); color: var(--text); }
.ui-select-opt.is-selected { color: var(--text); font-weight: 600; background: var(--primary-soft); }
.ui-select-opt.is-selected .icon { opacity: 1; }
.ui-select-opt.is-empty:not(.is-selected) { color: var(--muted); }
.ui-select-opt.is-disabled { opacity: .45; cursor: not-allowed; }
.ui-select-group { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .ui-select-pop { animation: none; } .ui-select-btn .icon { transition: none; } }
