/* Kali dashboard — shared styles.
   Quiet, dense, tool-like: a top bar, a module pane, a settings pane and a
   status bar, separated by hairlines rather than cards and shadows. */

:root {
  --bg: #0e1013;
  --panel: #13161a;
  --panel-2: #181c21;
  --row-hover: #1c2127;
  --line: #242a31;
  --line-2: #303740;
  --ink: #d7dbe0;
  --ink-2: #a4abb4;
  --muted: #7a828c;
  --acc: #5cc8de;
  --acc-dim: rgba(92, 200, 222, .12);
  --acc-line: rgba(92, 200, 222, .45);
  --ok: #7fc59a;
  --bad: #e07a63;
  --warn: #d8b05a;
  --r: 4px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bar: 44px;
  --status: 30px;
  --side: 248px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
code, kbd, .mono { font-family: var(--mono); font-size: 12px; }
code { color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
::selection { background: var(--acc-dim); }
:focus-visible { outline: 1px solid var(--acc); outline-offset: 1px; }
[hidden] { display: none !important; }

/* ── Labels ─────────────────────────────────────────────── */
.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.label b { color: var(--ink-2); font-weight: 400; letter-spacing: .04em; text-transform: none; margin-left: 8px; }
.muted { color: var(--muted); }
.dim { color: var(--ink-2); }

/* ── Top bar ────────────────────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar);
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 20px; height: 20px; border-radius: 3px; }
.tabs { display: flex; gap: 2px; }
.tabs a { color: var(--ink-2); padding: 5px 10px; border-radius: var(--r); white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: var(--panel-2); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--acc); }
.bar__spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 8px; color: var(--ink-2); white-space: nowrap; }
.user img { width: 22px; height: 22px; border-radius: 50%; background: var(--panel-2); }

/* Server picker sits in the bar */
.picker { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker img { width: 20px; height: 20px; border-radius: 50%; background: var(--panel-2); flex: none; }
.picker select { width: 230px; max-width: 42vw; }

/* ── Status dots / glyphs ───────────────────────────────── */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot--on { background: var(--ok); }
.dot--off { background: var(--warn); }
.dot--bad { background: var(--bad); }
.dot--unset { background: transparent; box-shadow: inset 0 0 0 1px var(--muted); }

/* ── App shell ──────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  height: calc(100vh - var(--bar) - var(--status));
  height: calc(100dvh - var(--bar) - var(--status));
}
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane__head {
  height: 34px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.pane__body { flex: 1 1 0%; overflow: auto; min-height: 0; }

/* Module list */
.mods { list-style: none; margin: 0; padding: 6px 0; }
.mods__group { padding: 14px 14px 6px; }
.mods a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  color: var(--ink-2);
  border-left: 2px solid transparent;
}
.mods a:hover { background: var(--row-hover); color: var(--ink); text-decoration: none; }
.mods a[aria-current="page"] { color: var(--ink); background: var(--panel-2); border-left-color: var(--acc); }
.mods .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mods .dot { margin-right: 2px; }
.mods__mobile { display: none; padding: 10px 14px; border-bottom: 1px solid var(--line); }

/* ── Content ───────────────────────────────────────────── */
.content { max-width: 860px; padding: 26px 28px 60px; container-type: inline-size; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 64ch; }

.sec { margin-top: 26px; }
.sec:first-of-type { margin-top: 0; }
.sec__h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  gap: 12px 28px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.row--wide { grid-template-columns: minmax(0, 1fr); }
.row__l label, .row__l .t { display: block; font-weight: 500; color: var(--ink); }
.row__l p { color: var(--ink-2); margin-top: 3px; max-width: 58ch; }
.row__l p + p { margin-top: 6px; }
.row__r { min-width: 0; }
.row__r .hint { margin-top: 6px; color: var(--muted); font-size: 12px; }
/* Stack label and control when the settings column itself is narrow (side
   panel open on a small laptop, split screen), not only on phones */
@container (max-width: 600px) {
  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

/* Plain key/value list (overview, read-only data) */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); }
.kv > * { padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.kv dd { margin: 0; }

/* Module status table on the overview */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list a, .list .item {
  display: grid;
  grid-template-columns: 14px 150px minmax(0, 1fr) auto;
  gap: 12px; align-items: baseline;
  padding: 10px 6px;
  color: var(--ink);
}
.list a:hover { background: var(--row-hover); text-decoration: none; }
.list .dot { align-self: center; }
.list .what { color: var(--ink-2); min-width: 0; }
.list .state { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Form controls ─────────────────────────────────────── */
input[type=text], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%;
  height: 30px;
  padding: 0 9px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font: inherit;
}
textarea { height: auto; min-height: 80px; padding: 7px 9px; resize: vertical; }
select {
  appearance: none;
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 13px, calc(100% - 9px) 13px;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
select:disabled, input:disabled { opacity: .55; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acc-line); }

input[type=range] { width: 100%; accent-color: var(--acc); }
.inline { display: flex; align-items: center; gap: 10px; }
.inline > input[type=range] { flex: 1; }
.inline .val { font-family: var(--mono); font-size: 12px; color: var(--ink-2); min-width: 40px; text-align: right; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 30px; height: 17px; border-radius: 9px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--ink-2); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--acc-line); }
.switch input:checked + .track::after { transform: translateX(13px); background: var(--acc); }
.switch input:focus-visible + .track { outline: 1px solid var(--acc); outline-offset: 2px; }

/* Colour input pair */
.color { display: flex; gap: 8px; }
.color input[type=color] { width: 36px; height: 30px; padding: 2px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer; }
.color input[type=text] { font-family: var(--mono); }

/* Searchable checklist (replaces <select multiple>) */
.ms { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel-2); }
.ms__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 9px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--muted); }
.ms__bar button { all: unset; cursor: pointer; color: var(--acc); }
.ms__search { border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; background: transparent !important; }
.ms__list { max-height: 210px; overflow: auto; padding: 3px 0; }
.ms__row { display: flex; align-items: center; gap: 8px; padding: 4px 9px; cursor: pointer; color: var(--ink-2); }
.ms__row:hover { background: var(--row-hover); color: var(--ink); }
.ms__row input { accent-color: var(--acc); margin: 0; }
.ms__row.is-on { color: var(--ink); }
.ms__empty { padding: 10px 9px; color: var(--muted); }

/* Chips (Q&A categories) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 8px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel-2); font-size: 12px; }
.chip button { all: unset; cursor: pointer; color: var(--muted); padding: 0 4px; }
.chip button:hover { color: var(--bad); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 30px; padding: 0 12px;
  font: inherit; font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn--acc { color: var(--acc); background: var(--acc-dim); border-color: var(--acc-line); }
.btn--acc:hover { background: rgba(92, 200, 222, .2); }
.btn--sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn--quiet { border-color: transparent; color: var(--ink-2); }
.btn--quiet:hover { color: var(--ink); }

.actions {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  margin-top: 26px; padding: 12px 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.actions .note { color: var(--muted); font-size: 12px; }
.actions .note.is-dirty { color: var(--warn); }

/* ── Notices ───────────────────────────────────────────── */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-2); border-left: 2px solid var(--acc); border-radius: var(--r); background: var(--panel); color: var(--ink-2); margin-bottom: 18px; }
.notice--warn { border-left-color: var(--warn); }
.notice--bad { border-left-color: var(--bad); }
.notice b { color: var(--ink); font-weight: 500; }
.empty { padding: 40px 0; color: var(--ink-2); max-width: 52ch; }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; }
.stats > div { padding: 10px 12px; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats .n { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Status bar ────────────────────────────────────────── */
.status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: var(--status);
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.status__msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status__msg.ok { color: var(--ok); }
.status__msg.bad { color: var(--bad); }
.status__msg.warn { color: var(--warn); }
.status a { color: var(--acc); }

/* Loading skeleton line */
.loading { color: var(--muted); font-family: var(--mono); font-size: 12px; padding: 18px 0; }
.loading::after { content: "…"; animation: blink 1s steps(3) infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 960px) {
  .tabs { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; }
  .app > .pane:first-child { display: none; }
  .pane + .pane { border-left: 0; }
  .mods__mobile { display: block; }
  .content { padding: 18px 16px 70px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .user span { display: none; }
  .picker select { width: 100%; max-width: none; }
  .picker { flex: 1; }
  .picker ~ .bar__spacer { display: none; }
  /* The page scrolls as a whole on phones, so the save bar sticks to the viewport */
  .pane__body { overflow: visible; }
  .actions { bottom: var(--status); }
  .bar { gap: 10px; }
  .list a, .list .item { grid-template-columns: 14px minmax(0, 1fr) auto; }
  .list .state { grid-column: 3; grid-row: 1; }
  .list .what { grid-column: 2 / -1; grid-row: 2; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:nth-child(3) { border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
