/* Operator dashboard — hand-written, RTL-first. No framework, no build step.
   Everything is vendored: the font below is served from /static/fonts. */

@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/static/fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e242c;
  --line: #2a323d;
  --ink: #e6eaf0;
  --muted: #94a1b2;
  --accent: #4c9aff;
  --ok: #3fb950;
  --warn: #d29922;
  --crit: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  direction: rtl;
}

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

/* --- layout --------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 220px; flex: 0 0 220px;
  background: var(--panel);
  border-inline-start: 1px solid var(--line);
  padding: 18px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand {
  font-weight: 700; font-size: 15px; padding: 0 18px 16px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.side nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 18px; color: var(--ink); border-inline-start: 3px solid transparent;
}
.side nav a:hover { background: var(--panel-2); text-decoration: none; }
.side nav a.on { border-inline-start-color: var(--accent); background: var(--panel-2); }
.side .who {
  margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}

.main { flex: 1; padding: 22px 26px; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.sub { color: var(--muted); font-size: 12px; margin-bottom: 18px; }

/* --- tiles ---------------------------------------------------------- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px;
}
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tile .n { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tile.crit { border-color: var(--crit); }
.tile.crit .v { color: var(--crit); }
.tile.warn { border-color: var(--warn); }
.tile.warn .v { color: var(--warn); }
.tile.ok .v { color: var(--ok); }

/* --- attention ------------------------------------------------------ */
.attention { margin-bottom: 18px; }
.att {
  display: flex; gap: 10px; align-items: center;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 6px;
  border: 1px solid var(--line); background: var(--panel);
}
.att.crit { border-inline-start: 4px solid var(--crit); }
.att.warn { border-inline-start: 4px solid var(--warn); }
.att.calm { border-inline-start: 4px solid var(--ok); color: var(--muted); }

/* --- tables --------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tr:hover td { background: var(--panel-2); }
.table-wrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow-x: auto;
}
td.num, th.num { font-variant-numeric: tabular-nums; }

/* --- pills ---------------------------------------------------------- */
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 11px; border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.crit { color: var(--crit); border-color: var(--crit); }

/* --- bars ----------------------------------------------------------- */
.bar { background: var(--panel-2); border-radius: 999px; height: 6px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar > i.warn { background: var(--warn); }
.bar > i.crit { background: var(--crit); }

/* --- forms ---------------------------------------------------------- */
input, select, textarea, button {
  font-family: inherit; font-size: 13px;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px;
}
/* Inputs stay LTR+ASCII: Persian digits break int() and copy-paste. */
input[type=text], input[type=number], input[type=password], input.ascii {
  direction: ltr; text-align: left;
}
input.fa, textarea { direction: rtl; text-align: right; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
button, .btn {
  cursor: pointer; background: var(--accent); border-color: var(--accent);
  color: #06121f; font-weight: 500;
}
button:hover { filter: brightness(1.1); }
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger, .btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 11px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card.danger { border-color: var(--crit); }
.card h3 { margin: 0 0 10px; font-size: 14px; }

.error {
  background: rgba(248,81,73,.1); border: 1px solid var(--crit);
  color: #ffb4ae; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
}
.notice {
  background: rgba(76,154,255,.08); border: 1px solid var(--accent);
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
}

/* --- tabs ----------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 14px 0 18px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

/* --- break-glass ---------------------------------------------------- */
.bg-banner {
  background: rgba(210,153,34,.12); border: 1px solid var(--warn);
  color: #f2cd6b; padding: 11px 15px; border-radius: var(--radius);
  margin-bottom: 14px; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; flex-wrap: wrap;
}
/* The watermark is intentionally unmissable: a screenshot of a customer's
   ledger must carry the name of whoever took it. */
.watermark {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700; color: rgba(230,234,240,.055);
  transform: rotate(-24deg); white-space: pre; text-align: center;
  line-height: 2.6;
}

/* --- pagination ----------------------------------------------------- */
.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink);
}
.pager .on { background: var(--accent); color: #06121f; border-color: var(--accent); }

/* --- misc ----------------------------------------------------------- */
.mask { font-family: ui-monospace, monospace; letter-spacing: 1px; direction: ltr; display: inline-block; }
.muted { color: var(--muted); }
.right { margin-inline-start: auto; }
.stack > * + * { margin-top: 10px; }
details summary { cursor: pointer; color: var(--muted); }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator { opacity: 1; }
pre.trace {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 10px; overflow-x: auto; direction: ltr; text-align: left;
  font-size: 11px; max-height: 220px;
}
.center-page { max-width: 380px; margin: 8vh auto; }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 46px; }
.spark i { flex: 1; background: var(--accent); min-height: 2px; border-radius: 2px 2px 0 0; }
