/* The support panel. Peyda for words, Tanha FD for figures, IBM Plex Mono for codes (D-420). */

@font-face { font-family: "Peyda"; src: url("../fonts/Peyda-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Peyda"; src: url("../fonts/Peyda-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Peyda"; src: url("../fonts/Peyda-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Peyda"; src: url("../fonts/Peyda-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
/* Tanha FD draws the digits only, Latin and Persian alike, in the Persian shapes. */
@font-face { font-family: "Tanha FD"; src: url("../fonts/Tanha-FD-Digits.ttf") format("truetype"); unicode-range: U+0030-0039, U+06F0-06F9, U+0660-0669; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/IBMPlexMono-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/IBMPlexMono-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1d1b17;
  --ink-2: #4a463e;
  --muted: #7d776b;
  --line: #e7e2d7;
  --line-strong: #d6cfc0;
  --accent: #a87a1f;
  --accent-ink: #ffffff;
  --accent-soft: #f6ecd6;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #a2660a;
  --warn-soft: #fbf0d9;
  --bad: #b3372c;
  --bad-soft: #fbe6e3;
  --shadow: 0 1px 2px rgba(40, 32, 12, .05), 0 8px 24px -12px rgba(40, 32, 12, .12);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #100f0d;
  --surface: #191815;
  --surface-2: #1f1d1a;
  --ink: #f1ede4;
  --ink-2: #cdc7ba;
  --muted: #958f82;
  --line: #2a2823;
  --line-strong: #3a372f;
  --accent: #e0b04a;
  --accent-ink: #1a1508;
  --accent-soft: #2e2613;
  --ok: #5fc892;
  --ok-soft: #14291f;
  --warn: #e9b455;
  --warn-soft: #2e2410;
  --bad: #f08478;
  --bad-soft: #321a17;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 28px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tanha FD", "Peyda", Tahoma, sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.4; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #5b3d08));
  color: var(--accent-ink); font-weight: 700; font-size: 1.15rem;
}
.brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.brand-sub { color: var(--muted); font-size: .8rem; }

.nav-title { padding: 14px 12px 4px; color: var(--muted); font-size: .76rem; font-weight: 600; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.who { flex: 1; min-width: 0; }
.who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: .8rem; }

.main { padding: 28px 34px 60px; max-width: 1280px; width: 100%; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head p { color: var(--muted); }
.crumb { color: var(--muted); font-size: .86rem; }

/* ---------- pieces ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.card + .card, .grid + .card, .card + .grid { margin-top: 18px; }
.grid > .card { margin-top: 0; }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { display: block; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; }
.tile:hover { text-decoration: none; border-color: var(--line-strong); }
.tile span { color: var(--muted); font-size: .86rem; }
.tile b { display: block; font-size: 2rem; font-weight: 700; line-height: 1.35; }
.tile.warn b { color: var(--warn); }
.tile.bad b { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th { text-align: start; padding: 10px 22px; color: var(--muted); font-size: .8rem; font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.empty { padding: 28px 22px; color: var(--muted); text-align: center; }
.num { font-feature-settings: "tnum"; white-space: nowrap; }

.code {
  font-family: "Plex Mono", ui-monospace, Consolas, monospace;
  direction: ltr; unicode-bidi: isolate; letter-spacing: .04em; white-space: nowrap;
}
/* A code, or a name: what the record was written about. */
.subject { font-family: "Plex Mono", "Tanha FD", "Peyda", monospace; unicode-bidi: plaintext; }
.code-box {
  display: block; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  font-family: "Plex Mono", ui-monospace, Consolas, monospace; font-weight: 600; font-size: 1.1rem;
  direction: ltr; text-align: center; letter-spacing: .06em; word-spacing: .3em; line-height: 2; overflow-wrap: anywhere;
}
.code-box.big { font-size: 1.7rem; color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.off { color: var(--muted); background: var(--surface-2); }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }

.note { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.note.ok { color: var(--ok); background: var(--ok-soft); }
.note.bad { color: var(--bad); background: var(--bad-soft); }
.note.warn { color: var(--warn); background: var(--warn-soft); }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }

/* ---------- forms ---------- */

label { display: block; margin-bottom: 5px; color: var(--ink-2); font-size: .86rem; font-weight: 500; }

input[type="text"], input[type="password"], input[type="search"], input[type="url"], textarea, select {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input.code { letter-spacing: .08em; text-transform: uppercase; text-align: center; }
textarea { min-height: 90px; resize: vertical; }
.field + .field { margin-top: 12px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.fields .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; padding: 6px 8px; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 4px 11px; font-size: .86rem; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.search { display: flex; gap: 8px; }
.search input { min-width: 260px; }

.tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.tabs a { padding: 4px 14px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: .9rem; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }

details.more > summary { list-style: none; cursor: pointer; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { margin-bottom: 14px; }

.theme-dark-only, :root[data-theme="dark"] .theme-light-only { display: none; }
:root[data-theme="dark"] .theme-dark-only { display: inline; }

/* ---------- sign-in ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 85% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 30px 30px 26px; }
.auth-card .brand { padding: 0 0 22px; }
.auth-card h1 { font-size: 1.25rem; margin-bottom: 4px; }
.auth-card .btn.primary { width: 100%; margin-top: 18px; padding: 10px; }
.auth-top { position: fixed; top: 16px; inset-inline-end: 16px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.qr svg { width: 190px; height: 190px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side-foot { margin-top: 12px; }
  .main { padding: 20px 16px 48px; }
  .cols-2, .cols-3, .split, .fields { grid-template-columns: 1fr; }
  .card { overflow-x: auto; }
}
