/* Nexus UI — the Keez idiom from docs/referinte/macheta-cerinte.html:
   dark brand top bar, module sidebar with counters, coloured stat tiles,
   dense tables with status pills, one primary action top-right.
   Tokens are lifted from the mockup so the two look like the same product. */

:root {
  --f-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --f-disp: "Source Serif 4", Georgia, "Times New Roman", serif;
  --ground: #f6f8f6; --surface: #ffffff; --surface-2: #eef3ef; --surface-3: #e6ece8;
  --ink: #14211d; --ink-2: #3d4d47; --muted: #6b7a74; --line: #d7e1db; --line-2: #c3d1c9;
  --brand-bg: #14392a; --brand-fg: #eaf4ee;
  --accent: #1c5c44; --accent-soft: #e3f0e9; --accent-line: #a9cfbc;
  --rose: #b62b56; --rose-soft: #fbe6ec; --rose-line: #e9b6c6;
  --amber: #94660c; --amber-soft: #faf0d9; --amber-line: #e3c98c;
  --blue: #255a83; --blue-soft: #e3edf6; --blue-line: #aec9de;
  --purple: #6b5b95;
  --r: 10px;
  --shadow: 0 1px 2px rgba(20,57,42,.06), 0 6px 18px -10px rgba(20,57,42,.22);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0d1512; --surface: #151f1b; --surface-2: #1b2924; --surface-3: #22322c;
    --ink: #e7efeb; --ink-2: #b6c6bf; --muted: #8a9a93; --line: #2a3b34; --line-2: #374b43;
    --brand-bg: #0f2b20; --brand-fg: #dcece3;
    --accent: #7cc7a3; --accent-soft: #17332a; --accent-line: #2f5b48;
    --rose: #f08bab; --rose-soft: #361a24; --rose-line: #5e2c3d;
    --amber: #e0b464; --amber-soft: #31270f; --amber-line: #57431a;
    --blue: #8ebde3; --blue-soft: #152736; --blue-line: #2b4459;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 22px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-family: var(--f-ui); font-size: 14px; color: var(--ink); background: var(--ground); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--f-disp); font-weight: 600; margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Shell */
.app-top { background: var(--brand-bg); color: var(--brand-fg); display: flex; align-items: center;
  justify-content: space-between; padding: 10px 16px; gap: 12px; }
.app-top .brand { font-family: var(--f-disp); font-size: 17px; letter-spacing: .2px; color: var(--brand-fg); }
.app-top .who { font-size: 12.5px; display: flex; align-items: center; gap: 10px; }
.app-top .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-line); color: var(--brand-bg);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.app-top .env { font-family: var(--f-mono); font-size: 10px; background: var(--amber); color: #fff; border-radius: 4px; padding: 1px 6px; }
.app-top form { display: inline; }
.app-top button.link { background: none; border: 0; color: var(--brand-fg); opacity: .8; cursor: pointer; font: inherit; font-size: 12px; padding: 0; }
.app-top button.link:hover { opacity: 1; text-decoration: underline; }
.app-body { display: grid; grid-template-columns: 196px minmax(0, 1fr); flex: 1; }
.app-side { background: var(--surface-2); border-right: 1px solid var(--line); padding: 8px 0; }
.app-side .sect { font-size: 9.5px; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); padding: 12px 14px 5px; }
.app-side a { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-left: 3px solid transparent;
  padding: 8px 14px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.app-side a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.app-side a.on { background: var(--surface); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.app-side .badge { font-family: var(--f-mono); font-size: 10px; background: var(--rose); color: #fff; border-radius: 9px; padding: 1px 6px; line-height: 1.5; }
.app-main { padding: 16px 18px 22px; min-width: 0; }
.app-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; padding: 8px 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.card + .card { margin-top: 12px; }
.btn { font: inherit; font-size: 12.5px; font-weight: 600; border-radius: 7px; padding: 8px 14px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { font-size: 15px; padding: 14px 18px; width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 11px; white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--rose-soft); color: var(--rose); }
.pill.neutral { background: var(--surface-3); color: var(--muted); }
.pill.info { background: var(--blue-soft); color: var(--blue); }
.code { font-family: var(--f-mono); font-size: 11px; background: var(--surface-3); border-radius: 4px; padding: 1px 6px; }
.alert { display: flex; gap: 9px; align-items: flex-start; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px; border: 1px solid; }
.alert.bad { background: var(--rose-soft); border-color: var(--rose-line); color: var(--rose); }
.alert.ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.alert.warn { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.alert strong { display: block; margin-bottom: 2px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.tile { border-radius: 8px; overflow: hidden; border: 1px solid var(--line); color: inherit; }
.tile:hover { text-decoration: none; box-shadow: var(--shadow); }
.tile .t-h { padding: 7px 11px; font-size: 11.5px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 6px; }
.tile .t-v { padding: 10px 11px; background: var(--surface); font-family: var(--f-mono); font-size: 21px; font-variant-numeric: tabular-nums; }
.tile .t-v small { font-size: 11px; color: var(--muted); font-family: var(--f-ui); margin-left: 3px; }
.tile.a .t-h { background: #b8860b; }
.tile.g .t-h { background: #2d7a5f; }
.tile.b .t-h { background: #3c7fae; }
.tile.p .t-h { background: #6b5b95; }
.tile.r .t-h { background: #b62b56; }
.tile.n .t-h { background: #4d5d57; }

.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 10.5px; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 8px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; background: var(--surface-2); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t td.mono, table.t td .mono { font-family: var(--f-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.t tfoot td { font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--line-2); }
table.t a.row-link { color: inherit; font-weight: 600; }
.empty { color: var(--muted); font-size: 13px; padding: 18px; text-align: center; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 10.5px; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea { font: inherit; font-size: 14px; padding: 9px 10px; border: 1px solid var(--line-2);
  border-radius: 7px; background: var(--surface); color: var(--ink); width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-line); border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.counter-preview { font-family: var(--f-mono); font-size: 26px; padding: 6px 0; color: var(--accent); }
.counter-preview small { font-family: var(--f-ui); font-size: 12px; color: var(--muted); }
.errorlist { color: var(--rose); font-size: 12px; margin: 0; padding-left: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.seg a { padding: 7px 12px; font-size: 12.5px; color: var(--ink-2); }
.seg a.on { background: var(--brand-bg); color: var(--brand-fg); }
.seg a:hover { text-decoration: none; }

/* Two-column page: content + side panel */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; font-size: 12.5px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Login */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 24px; background: var(--ground); }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { font-family: var(--f-disp); font-size: 24px; color: var(--accent); margin-bottom: 2px; }

/* Meter (self-monitoring) */
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter.warn > span { background: var(--amber); }
.meter.bad > span { background: var(--rose); }

/* Phone: the therapist records standing up, between appointments. */
@media (max-width: 760px) {
  .app-body { grid-template-columns: 1fr; }
  .app-side { display: flex; overflow-x: auto; padding: 4px 6px; gap: 2px; border-right: 0; border-bottom: 1px solid var(--line); }
  .app-side .sect { display: none; }
  .app-side a { border-left: 0; border-bottom: 3px solid transparent; padding: 8px 10px; }
  .app-side a.on { border-bottom-color: var(--accent); background: transparent; }
  .app-main { padding: 12px; }
  .split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  table.t { font-size: 13.5px; }
  table.t td, table.t th { padding: 10px 8px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field input, .field select, .field textarea { font-size: 16px; padding: 12px; } /* no zoom on iOS */
  .hide-phone { display: none; }
}
.htmx-request .btn.primary { opacity: .6; }
