/* Light, minimal: white surfaces, blue for actions, near-black ink, greys for structure and hover. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;       /* hover */
  --subtle: #fafafa;          /* table heads, code */
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #0a0a0a;
  --text-2: #404040;
  --muted: #737373;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #eff6ff;
  --good: #16a34a;
  --warning: #d97706;
  --critical: #dc2626;
  --critical-soft: #fef2f2;
  --code-bg: #fafafa;
  --shadow: none;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
a.btn { display: inline-block; text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--muted); }
.error { color: var(--critical); margin: 0; }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; text-decoration: none; }
.brand-lg { font-size: 26px; }
.chip-mark {
  width: 18px; height: 18px; border-radius: 4px; background: var(--accent); position: relative;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent);
}
.brand-lg .chip-mark { width: 24px; height: 24px; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
/* Same width and gutters as .main, so the logo and nav line up with the page content. */
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 24px;
}
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--text); white-space: nowrap; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a { transition: background .12s, color .12s; }
.nav a.active { background: #ececec; color: var(--text); }
.main { max-width: 1160px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; min-height: 38px; }
.h-sub { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.stack { display: grid; gap: 16px; }
.stack > *, .grid-2 > * { min-width: 0; }  /* let wide tables scroll inside their card */

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.tile .value small { font-size: 15px; color: var(--muted); font-weight: 500; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--subtle); white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--subtle); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td { white-space: nowrap; }
td:has(.tag) { white-space: normal; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

/* status */
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; white-space: nowrap; }
.status svg { flex: none; }
.status.good { color: var(--text); } .status.good svg { color: var(--good); }
.status.warning svg { color: var(--warning); }
.status.critical svg { color: var(--critical); }
.status.off { color: var(--muted); }
.status .detail { color: var(--muted); font-weight: 400; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-family: var(--mono); font-size: 12px; margin: 2px 4px 2px 0; white-space: nowrap;
}

/* chips list */
.meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); font-size: 13px; }
.meta b { color: var(--text-2); font-weight: 500; }
.chip-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chip-title h2 { margin: 0; font-size: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; flex-wrap: nowrap; }
.sm-only { display: none; }
.note { margin: 0; padding: 10px 20px; background: var(--critical-soft); color: var(--critical); font-size: 13px; border-bottom: 1px solid var(--border); }

/* buttons & forms */
.btn {
  font: inherit; font-weight: 500; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn { transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--critical); }
.btn.danger:hover { background: var(--critical-soft); border-color: #fecaca; }
.btn.danger-solid { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.danger-solid:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }
input:hover { border-color: var(--border-strong); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* code blocks */
.code {
  position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; padding-right: 64px; font-family: var(--mono); font-size: 12.5px; white-space: pre; overflow-x: auto; margin: 0;
}
.code .copy { position: absolute; top: 6px; right: 6px; }
.secret { border-color: var(--accent); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card p { margin: -8px 0 0; }

/* modal */
.modal {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(600px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 16px 40px rgba(0,0,0,.12);
}
.modal::backdrop { background: rgba(10,10,10,.25); }
.modal form, .modal .body { padding: 22px; display: grid; gap: 16px; }
.modal h2 { margin: 0; font-size: 17px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; }
.modal p { margin: 0; color: var(--text-2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; height: auto; flex-wrap: wrap; justify-content: space-between; gap: 0; }
  .topbar-inner .brand { height: 52px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 10px; }
  .sm-hide { display: none; }
  .sm-only { display: inline-flex; }
  td.wrap-sm { white-space: normal; }
  .main { padding: 20px 16px 48px; }
  th, td { padding: 9px 12px; }
  .card-head, .card-pad { padding-left: 14px; padding-right: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* card title row: heading left, small action right */
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }

/* modal fields */
.field { display: grid; gap: 6px; }
.field-label { font-weight: 500; font-size: 13px; }
details summary { cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text-2); }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 8px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.15);
}

/* top bar: tenant switcher + account menu */
.topbar-right { display: flex; align-items: center; gap: 8px; }
.select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 28px 7px 10px; width: 100%; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5 5 6.5 8 3.5' fill='none' stroke='%23737373' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select:hover { border-color: var(--border-strong); }
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select.small { width: auto; padding: 4px 26px 4px 10px; font-size: 13px; max-width: 180px; }
.menu { position: relative; }
.menu summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--surface-2); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 13px; overflow-wrap: anywhere; }
.menu-pop button {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; color: var(--text);
  background: none; border: 0; border-radius: 6px; padding: 7px 10px; cursor: pointer;
}
.menu-pop button:hover { background: var(--surface-2); }

/* forms */
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.checklist { display: grid; gap: 2px; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.checklist .check { padding: 6px 8px; border-radius: 6px; }
.checklist .check:hover { background: var(--surface-2); }
.login-card h2 { margin: 0; font-size: 16px; }
.tag.label { font-family: inherit; font-size: 12px; }
.tag.shared { background: var(--accent-soft); border-color: #dbeafe; color: var(--accent-hover); font-family: inherit; }

/* chip in dialog */
.weights { display: grid; gap: 6px; }
.weight-row { display: grid; grid-template-columns: 1fr 84px 44px 32px; align-items: center; gap: 8px; }
.weight-row input { padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.w-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.add-row { display: flex; gap: 8px; margin-top: 4px; }
.add-row input { text-transform: uppercase; font-family: var(--mono); }
.add-row input::placeholder { text-transform: none; font-family: inherit; }
.note-line { margin: 10px 0 0; font-size: 13px; }
