/* =========================================================
   CONSOLE — design system for the nimkat operations panel
   ---------------------------------------------------------
   Replaces "Obsidian Aurora Glass". The panel is a night-shift
   instrument: the operator reads the bot's pulse, the money
   queue and the traffic of every tunnel. So the interface is
   built like equipment, not like a landing page.

   Rules of the system
   1. Flat graphite surfaces, 1px hairlines, no blur or glow.
   2. One signal colour (amber). Green/red/cold appear only as
      status, never as decoration.
   3. Numbers are readouts: tabular figures, mono where digits
      stand alone (ids, dates, quotas, counters).
   4. The single loud element is the header tally lamp.
   ========================================================= */

:root {
  /* surfaces */
  --ink: #0a0b0c;
  --panel: #0f1113;
  --raise: #15181b;
  --well: #0b0d0f;

  /* structure */
  --rule: #22262a;
  --rule-2: #2d3238;

  /* type */
  --chalk: #e9eaec;
  --dim: #9ca2a9;
  --faint: #6b7178;

  /* the one accent */
  --signal: #f2b23f;
  --signal-soft: rgba(242, 178, 63, 0.14);
  --signal-line: rgba(242, 178, 63, 0.45);

  /* status */
  --ok: #5dbfa0;
  --warn: #e3a94e;
  --bad: #e4757f;
  --cold: #86aecb;
  --sand: #c9a66b;

  --radius: 8px;
  --radius-sm: 6px;
}

/* --- Typography ------------------------------------------------------- */

html[lang="fa"], html[lang="fa"] body {
  --tblr-font-sans-serif: 'Vazirmatn FD', 'Vazirmatn', sans-serif !important;
  --tblr-font-monospace: 'JetBrains Mono', monospace !important;
  font-family: 'Vazirmatn FD', 'Vazirmatn', sans-serif !important;
  letter-spacing: 0 !important;
}
html[lang="fa"] *:not(.latin-code):not(.latin-code *):not(.font-mono):not(.font-mono *) {
  font-family: 'Vazirmatn FD', 'Vazirmatn', sans-serif !important;
  letter-spacing: 0 !important;
}
html[lang="en"], html[lang="en"] body {
  --tblr-font-sans-serif: 'Inter', -apple-system, sans-serif !important;
  font-family: 'Inter', -apple-system, sans-serif !important;
}
.latin-code, .font-mono {
  font-family: 'JetBrains Mono', 'Inter', monospace !important;
  direction: ltr !important;
  unicode-bidi: isolate;
  font-size: 0.86em;
  letter-spacing: -0.01em !important;
  font-variant-numeric: tabular-nums;
}

/* --- Canvas ----------------------------------------------------------- */

body {
  background-color: var(--ink) !important;
  color: var(--chalk) !important;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.page, .page-wrapper { position: relative; background: transparent !important; }

/* --- Sidebar rail ----------------------------------------------------- */

.navbar-vertical {
  background: var(--panel) !important;
  border-inline-end: 1px solid var(--rule) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  padding: 0 !important;
}
.navbar-vertical .container-fluid { padding: 0 0 14px !important; align-items: stretch; }
.navbar-vertical .navbar-brand {
  padding: 16px 14px 14px !important;
  margin: 0 0 6px !important;
  border-bottom: 1px solid var(--rule);
  min-height: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--chalk) !important;
  letter-spacing: 0;
}
.brand-badge {
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: var(--signal-soft);
  border: 1px solid var(--signal-line);
  color: var(--signal);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: none;
  flex-shrink: 0;
}
.brand-badge .icon { width: 14px; height: 14px; }

.nav-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--faint);
  padding: 16px 14px 5px !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  list-style: none;
}
html[lang="fa"] .nav-section-label {
  font-size: 0.7rem;
  letter-spacing: 0 !important;
  text-transform: none;
}

.navbar-vertical .nav-link {
  border-radius: var(--radius-sm);
  margin: 1px 8px;
  padding: 7px 10px !important;
  color: var(--dim) !important;
  font-weight: 500;
  font-size: 0.84rem;
  border: 0;
  border-inline-start: 2px solid transparent !important;
  display: flex; align-items: center; gap: 10px;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.navbar-vertical .nav-link:hover {
  background: var(--raise) !important;
  color: var(--chalk) !important;
  transform: none;
}
html[lang="fa"] .navbar-vertical .nav-link:hover { transform: none; }
/* the active class lives on the <li> in _nav.html; keep both selectors */
.navbar-vertical .nav-link.active,
.navbar-vertical .nav-item.active > .nav-link {
  background: var(--raise) !important;
  color: var(--chalk) !important;
  border-inline-start-color: var(--signal) !important;
  box-shadow: none;
  font-weight: 600;
}
.navbar-vertical .nav-link.active .nav-link-icon,
.navbar-vertical .nav-link.active i,
.navbar-vertical .nav-item.active > .nav-link .nav-link-icon,
.navbar-vertical .nav-item.active > .nav-link i { color: var(--signal); }

/* mobile dropdown (flat nav items) */
.dropdown-menu .dropdown-item { color: var(--dim); font-size: 0.82rem; border-radius: var(--radius-sm); }
.dropdown-menu .dropdown-item:hover { background: var(--raise); color: var(--chalk); }
.dropdown-menu .dropdown-item.active {
  background: var(--raise) !important;
  color: var(--chalk) !important;
  box-shadow: inset 2px 0 0 var(--signal);
  font-weight: 600;
}
html[dir="rtl"] .dropdown-menu .dropdown-item.active { box-shadow: inset -2px 0 0 var(--signal); }
.dropdown-menu {
  background: var(--raise);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.dropdown-divider { border-color: var(--rule); }
.navbar-vertical .nav-link .icon { width: 16px; height: 16px; opacity: 0.9; }
.nav-link-icon { display: inline-flex; align-items: center; }
.nav-link-title { line-height: 1.2; }

.navbar-footer {
  margin-top: auto;
  padding: 12px 14px 0 !important;
  border-top: 1px solid var(--rule);
  position: relative;
}
.navbar-footer .entity-avatar { width: 26px; height: 26px; font-size: 0.7rem; }

/* --- Header bar ------------------------------------------------------- */

.top-glass-header {
  background: var(--ink) !important;
  backdrop-filter: none !important;
  border-bottom: 1px solid var(--rule) !important;
  position: sticky; top: 0; z-index: 30;
  min-height: 54px;
  padding: 0 22px !important;
}
.top-glass-header .navbar-brand,
.top-glass-header .h3 {
  font-size: 0.98rem !important;
  font-weight: 600 !important;
  color: var(--chalk) !important;
  letter-spacing: 0;
  margin-bottom: 0 !important;
}
.top-glass-header .text-secondary { color: var(--faint) !important; font-size: 0.74rem !important; }

/* Signature: studio-style tally lamp for the bot heartbeat. */
.tally {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--well);
}
.tally-lamp {
  width: 7px; height: 7px;
  border-radius: 1px;
  background: var(--faint);
  flex-shrink: 0;
}
.tally.is-live .tally-lamp {
  background: var(--ok);
  box-shadow: 0 0 0 1px rgba(93, 191, 160, 0.3), 0 0 9px rgba(93, 191, 160, 0.55);
}
.tally.is-dead .tally-lamp {
  background: var(--bad);
  box-shadow: 0 0 9px rgba(228, 117, 127, 0.5);
}
.tally-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  line-height: 1;
}
html[lang="fa"] .tally-label { letter-spacing: 0 !important; text-transform: none; font-size: 0.72rem; }

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

.page-body { padding: 20px 22px 40px !important; }

/* Filter bars: the search field stays a field, not a full-width banner. */
@media (min-width: 768px) {
  .page-header form { flex-wrap: nowrap; }
  .page-header .input-group { flex: 0 0 auto; }
  .page-header .input-group .form-control { flex: 0 0 auto; width: 230px !important; }
}
.page-header { margin-bottom: 16px !important; }
.page-title {
  font-size: 1.05rem !important;
  font-weight: 600 !important;
  color: var(--chalk) !important;
  letter-spacing: 0;
}
.page-title .text-secondary { color: var(--faint) !important; font-weight: 500; }
.page-header .text-secondary, .subheader { color: var(--faint) !important; font-size: 0.76rem !important; }

/* --- Panels ----------------------------------------------------------- */

.card, .glass-card {
  position: relative;
  background: var(--panel) !important;
  border: 1px solid var(--rule) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transition: border-color 0.16s ease;
  overflow: hidden;
}
.card.spotlight-card::before { content: none !important; }
.card.spotlight-card:hover { border-color: var(--rule-2) !important; transform: none; }
.card > * { position: relative; z-index: 1; }

.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--rule) !important;
  padding: 11px 14px !important;
  min-height: 0;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.card-header .text-secondary { color: var(--faint) !important; font-size: 0.72rem !important; }
.card-title {
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  color: var(--chalk) !important;
  letter-spacing: 0;
  margin: 0 !important;
  display: inline-flex; align-items: center;
}
html[lang="en"] .card-title {
  font-size: 0.68rem !important;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim) !important;
}
.card-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 14px !important; }

/* --- KPI readouts ----------------------------------------------------- */

.kpi-icon-box {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid currentColor;
  color: var(--dim);
  background: transparent;
  flex-shrink: 0;
  box-shadow: none;
}
.kpi-icon-box .icon { width: 15px; height: 15px; }
.kpi-indigo  { color: var(--cold);   border-color: rgba(134, 174, 203, 0.34); background: rgba(134, 174, 203, 0.08); }
.kpi-emerald { color: var(--ok);     border-color: rgba(93, 191, 160, 0.34);  background: rgba(93, 191, 160, 0.08); }
.kpi-amber   { color: var(--warn);   border-color: rgba(227, 169, 78, 0.36);  background: rgba(227, 169, 78, 0.08); }
.kpi-rose    { color: var(--bad);    border-color: rgba(228, 117, 127, 0.36); background: rgba(228, 117, 127, 0.08); }
.kpi-cyan    { color: var(--cold);   border-color: rgba(134, 174, 203, 0.34); background: rgba(134, 174, 203, 0.08); }

.kpi-value {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--chalk);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}
.kpi-value .subheader { font-size: 0.8rem !important; }
.kpi-urgent {
  border-color: rgba(228, 117, 127, 0.4) !important;
  box-shadow: inset 2px 0 0 var(--bad) !important;
}

/* --- Entrance motion -------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
.anim-in {
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  animation-delay: calc(var(--stagger, 0) * 26ms);
}

/* --- Shift sheet (dashboard) ------------------------------------------ */

.shift {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 0 2px 11px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
}
.shift-meta { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.shift-meta .kv {
  display: inline-flex; align-items: baseline; gap: 5px;
  font-size: 0.72rem; color: var(--faint);
}
.shift-meta .kv b {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500; font-size: 0.73rem; color: var(--dim);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.shift-readouts { margin-inline-start: auto; display: flex; gap: 20px; }
.mini { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; }
.mini:hover .mini-l { color: var(--signal); }
.tally-lg { padding: 5px 10px; }
.tally-lg .tally-lamp { width: 9px; height: 9px; }
.tally-lg .tally-label { font-size: 0.72rem; }
.mini-v { font-size: 0.92rem; font-weight: 600; color: var(--chalk); font-variant-numeric: tabular-nums; }
.mini-l { font-size: 0.7rem; color: var(--faint); }

/* readouts: the figure carries the design, the label just names it */
.figure {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--chalk);
  font-variant-numeric: tabular-nums;
}
.figure.is-zero { color: var(--faint); }
.figure-sm { font-size: 0.95rem; font-weight: 600; color: var(--chalk); font-variant-numeric: tabular-nums; }

/* Censored money reads as a redaction, not as a typo: the mask becomes a bar. */
.income-censored .income-value {
  display: inline-block;
  background: var(--rule-2);
  color: transparent !important;
  border-radius: 2px;
  padding: 0 0.16em;
  min-width: 5ch;
  user-select: none;
}
.figure-note { font-size: 0.7rem; color: var(--faint); font-weight: 500; }

.spark { display: block; width: 100%; height: 56px; margin: 12px 0 2px; overflow: visible; }
.spark-axis {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.64rem; color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.fig-r {
  display: inline-flex; align-items: baseline; gap: 7px;
  color: var(--dim); font-variant-numeric: tabular-nums;
}
.fig-r .sep { color: var(--rule-2); }
.spark-line {
  fill: none; stroke: var(--signal); stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round; stroke-linecap: round;
}
.spark-base { stroke: var(--rule-2); stroke-width: 1; vector-effect: non-scaling-stroke; }

.ledger-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-top: 9px; margin-top: 6px;
  border-top: 1px solid var(--rule);
  font-size: 0.74rem; color: var(--faint);
}

/* queue: rows are the actions, so they behave like buttons */
.card.is-urgent { border-inline-start: 2px solid var(--bad) !important; }
.qrow {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--rule);
  color: var(--chalk); text-decoration: none;
  font-size: 0.82rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.qrow:last-child { border-bottom: 0; padding-bottom: 2px; }
.qrow:hover { background: rgba(255, 255, 255, 0.022); color: var(--chalk); }
.qbar { width: 2px; height: 15px; border-radius: 1px; background: var(--rule-2); flex-shrink: 0; }
.qbar.is-rose { background: var(--bad); }
.qbar.is-amber { background: var(--warn); }
.qbar.is-cold { background: var(--cold); }
.qrow-n { margin-inline-start: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.qrow-n.is-zero { color: var(--faint); font-weight: 500; }
.qrow-go { color: var(--faint); display: inline-flex; }
.qrow-more { color: var(--faint); }
.qrow-more:hover { color: var(--chalk); }
.qrow:hover .qrow-go { color: var(--signal); }

.chart-container.is-tape { height: 200px; }

@media (min-width: 992px) {
  /* the sheet is the whole screen on a desk, so the figure carries the page */
  .figure { font-size: 2.6rem; font-weight: 900; }
}
@media (max-width: 575.98px) {
  .figure { font-size: 1.75rem; }
  .shift { gap: 10px; }
  .shift-readouts { margin-inline-start: 0; gap: 14px; }
}

/* --- Day strip: a fortnight of takings, as ruled cells ----------------- */

.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.day {
  background: var(--panel);
  padding: 8px 9px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 0;
  text-align: center;
  transition: background-color 0.12s ease;
}
.day:hover { background: var(--raise); }
.day-d {
  font-size: 0.64rem; color: var(--faint);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  width: 100%;
}
.day-plot { height: 40px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.day-bar {
  width: 100%; max-width: 26px; min-height: 2px;
  background: var(--signal);
  border-radius: 1px;
  opacity: 0.92;
  transition: opacity 0.12s ease;
}
.day:hover .day-bar { opacity: 1; }
.day.is-empty .day-bar { background: var(--rule-2); }
.day-v {
  font-size: 0.72rem; font-weight: 600; color: var(--chalk);
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* censored: the amount becomes a redaction stub, so the cell keeps its shape
   instead of collapsing into an empty hole */
.income-censored .day-v {
  display: block;
  color: transparent;
  background: var(--rule-2);
  border-radius: 2px;
  width: 56%; height: 7px;
  margin: 3px auto;
}
@media (max-width: 767.98px) {
  .days { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .day-plot { height: 24px; }
}

/* --- Command palette -------------------------------------------------- */

.pal-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--well);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  color: var(--faint);
  font: inherit;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.pal-trigger:hover { color: var(--chalk); border-color: var(--rule-2); }
.pal-trigger kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem; color: var(--faint);
  border: 1px solid var(--rule-2); border-radius: 3px;
  padding: 0 4px;
}

.palette { position: fixed; inset: 0; z-index: 1500; display: grid; place-items: start center; padding-top: 11vh; }
.palette[hidden] { display: none; }
.palette-scrim { position: absolute; inset: 0; background: rgba(4, 5, 6, 0.74); }
.palette-box {
  position: relative;
  width: min(560px, calc(100vw - 26px));
  background: var(--raise);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: rise 0.14s ease-out;
}
.palette-input {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--faint);
}
.palette-input input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--chalk); font-size: 0.9rem;
  font-family: inherit;
}
.palette-input input::placeholder { color: var(--faint); }
.palette-kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem; color: var(--faint);
  border: 1px solid var(--rule-2); border-radius: 3px;
  padding: 1px 5px;
}
.palette-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.palette-group {
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--faint);
  padding: 9px 10px 4px;
}
html[lang="fa"] .palette-group { text-transform: none; letter-spacing: 0 !important; font-size: 0.68rem; }
.pal-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border-inline-start: 2px solid transparent;
  color: var(--dim); text-decoration: none;
  font-size: 0.84rem;
}
.pal-item[hidden] { display: none; }
.pal-dot { width: 3px; height: 12px; border-radius: 1px; background: var(--rule-2); flex-shrink: 0; }
.pal-hint { margin-inline-start: auto; font-size: 0.7rem; color: var(--faint); font-family: 'JetBrains Mono', monospace; }
.pal-item.is-active, .pal-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--chalk);
  border-inline-start-color: var(--signal);
}
.pal-item.is-active .pal-dot, .pal-item:hover .pal-dot { background: var(--signal); }
.palette-empty { padding: 16px 12px; color: var(--faint); font-size: 0.82rem; text-align: center; }
.palette-foot {
  border-top: 1px solid var(--rule);
  padding: 7px 14px;
  font-size: 0.68rem; color: var(--faint);
}

/* --- Tables -----------------------------------------------------------
   Read at speed: tighter rows, quiet header, and the row you are on is the
   only one that gets marked. */

.table > :not(caption) > * > * {
  padding-top: 0.56rem;
  padding-bottom: 0.56rem;
  border-bottom: 1px solid var(--rule);
}
.table thead th {
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--rule-2);
}
html[lang="fa"] .table thead th { text-transform: none; letter-spacing: 0; font-size: 0.73rem; }
.table tbody tr { transition: background-color 0.1s ease; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--signal); }
html[dir="rtl"] .table tbody tr:hover td:first-child { box-shadow: inset -2px 0 0 var(--signal); }
.table .row-go { opacity: 0.72; transition: opacity 0.12s ease, border-color 0.12s ease; }

/* Phones: a six-column ops table cannot fit in 390px, so the table scrolls —
   but the identifier column stays pinned, otherwise you lose track of which
   row you are reading halfway across the scroll. */
@media (max-width: 575.98px) {
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table { font-size: 0.78rem; }
  .table > :not(caption) > * > * { padding: 0.45rem 0.4rem; }
  .table th, .table td, .table .cell-stack { min-width: 0 !important; }
  .table thead th { font-size: 0.6rem; padding-inline-end: 24px; }
  .table th:first-child,
  .table td:first-child {
    position: sticky;
    inset-inline-start: 0;
    z-index: 2;
    background: var(--panel);
    box-shadow: inset -1px 0 0 var(--rule);
  }
  html[dir="rtl"] .table th:first-child,
  html[dir="rtl"] .table td:first-child { box-shadow: inset 1px 0 0 var(--rule); }
  .table tbody tr:hover td:first-child { background: var(--raise); }
  /* a cut-off column reads as broken data; a fade reads as "there is more
     this way", which is what a horizontally scrolling table actually is */
  .card:has(.table-responsive) { position: relative; }
  html[dir="rtl"] .card:has(.table-responsive)::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 26px;
    background: linear-gradient(to right, var(--panel), transparent);
    pointer-events: none;
  }
  html[dir="ltr"] .card:has(.table-responsive)::after {
    content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 26px;
    background: linear-gradient(to left, var(--panel), transparent);
    pointer-events: none;
  }
}
/* lock/unlock is a warning state, not an error state: it only raises its voice
   on the row you are actually on */
.table tbody .btn-outline-danger { color: #b8656b; border-color: rgba(228, 117, 127, 0.22); }
.table tbody .btn-outline-success { color: #6a9e8c; border-color: rgba(93, 191, 160, 0.22); }
.table tbody tr:hover .btn-outline-danger { color: #eb9ba3; border-color: rgba(228, 117, 127, 0.55); }
.table tbody tr:hover .btn-outline-success { color: #7fd3b8; border-color: rgba(93, 191, 160, 0.55); }
.table tr:hover .row-go,
.table .row-go:focus-visible { opacity: 1; }

.table {
  --tblr-table-bg: transparent;
  --tblr-table-color: var(--chalk);
  --tblr-table-border-color: var(--rule);
  margin-bottom: 0 !important;
}
.table thead th {
  background: var(--well) !important;
  color: var(--faint) !important;
  font-size: 0.66rem !important;
  font-weight: 600 !important;
  padding: 9px 14px !important;
  white-space: nowrap !important;
  border-bottom: 1px solid var(--rule) !important;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  position: sticky; top: 0; z-index: 2;
}
html[lang="fa"] .table thead th {
  font-size: 0.74rem !important;
  letter-spacing: 0 !important;
  text-transform: none;
}
.table tbody tr { transition: background-color 0.12s ease; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.022) !important; }
.table tbody td {
  padding: 9px 14px !important;
  vertical-align: middle !important;
  border-bottom: 1px solid var(--rule) !important;
  font-size: 0.82rem;
  color: var(--chalk);
}
.table tbody tr:last-child td { border-bottom: 0 !important; }
.table a { color: var(--chalk); text-decoration: none; }
.table a:hover { color: var(--signal); text-decoration: underline; text-underline-offset: 2px; }

/* Row actions are secondary: amber belongs to the page, not to every line. */
.table .btn-primary, .card-table .btn-primary {
  background: transparent !important;
  border: 1px solid var(--rule) !important;
  color: var(--dim) !important;
  font-weight: 500 !important;
}
.table .btn-primary:hover, .card-table .btn-primary:hover {
  background: var(--raise) !important;
  border-color: var(--signal-line) !important;
  color: var(--signal) !important;
}

.cell-stack { display: flex; flex-direction: column; gap: 3px; }
.cell-main { font-weight: 600; color: var(--chalk); font-size: 0.84rem; line-height: 1.35; }
.cell-sub { font-size: 0.72rem; color: var(--faint); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* Entity plates: flat, no gradient bloom. */
.entity-avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.72rem; color: var(--chalk);
  flex-shrink: 0;
  border: 1px solid var(--rule-2);
  background: var(--raise);
  box-shadow: none;
}
.av-0 { background: rgba(134, 174, 203, 0.16); border-color: rgba(134, 174, 203, 0.3); color: #bcd6e6; }
.av-1 { background: rgba(93, 191, 160, 0.16);  border-color: rgba(93, 191, 160, 0.3);  color: #a8ddca; }
.av-2 { background: rgba(201, 166, 107, 0.16); border-color: rgba(201, 166, 107, 0.3); color: #e0c79c; }
.av-3 { background: rgba(227, 169, 78, 0.16);  border-color: rgba(227, 169, 78, 0.3);  color: #f0cf95; }
.av-4 { background: rgba(228, 117, 127, 0.16); border-color: rgba(228, 117, 127, 0.3); color: #f2b3b9; }
.av-5 { background: rgba(140, 140, 160, 0.16); border-color: rgba(140, 140, 160, 0.3); color: #cccdd6; }

/* Public Telegram photo layered over the initials plate: the plate paints
   instantly, the image replaces it as soon as it decodes, and a 404 (no photo)
   removes the img so the plate is the final state. */
.entity-avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; cursor: zoom-in; }
.entity-avatar-wrap:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: var(--radius-sm); }
.entity-avatar-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--rule-2);
  background: var(--raise);
}

/* --- Avatar gallery (full-size profile photos) ------------------------- */
.av-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  background: var(--sink, rgba(0, 0, 0, 0.25));
  overflow: hidden;
}
.av-main { display: block; max-width: 100%; max-height: 68vh; object-fit: contain; }
.av-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--rule-2);
  background: rgba(8, 10, 14, 0.62);
  color: var(--chalk); font-size: 1.25rem; line-height: 1;
  cursor: pointer;
}
.av-nav:hover { background: rgba(8, 10, 14, 0.85); }
.av-prev { inset-inline-start: 8px; }
.av-next { inset-inline-end: 8px; }
.av-strip {
  display: flex; gap: 6px; margin-top: 10px;
  overflow-x: auto; padding-bottom: 4px;
}
.av-strip-img {
  width: 56px; height: 56px; flex-shrink: 0;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-2);
  opacity: 0.55; cursor: pointer;
  transition: opacity .12s ease;
}
.av-strip-img:hover { opacity: 0.85; }
.av-strip-img.is-active { opacity: 1; border-color: var(--signal); }

/* --- Status plates ---------------------------------------------------- */

.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 0.7rem; font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.status-pill .icon { width: 12px; height: 12px; }
/* a pill is a label, not a field: inside a stacked cell the column would
   otherwise stretch it into something that reads like an empty input */
.cell-stack > .status-pill { align-self: flex-start; }
.pill-emerald { background: rgba(93, 191, 160, 0.1);  color: #7fd3b8; border-color: rgba(93, 191, 160, 0.26); }
.pill-amber   { background: rgba(227, 169, 78, 0.1);  color: #e8bd7c; border-color: rgba(227, 169, 78, 0.28); }
.pill-rose    { background: rgba(228, 117, 127, 0.1); color: #eb9ba3; border-color: rgba(228, 117, 127, 0.3); }
.pill-indigo  { background: rgba(134, 174, 203, 0.1); color: #a6c8de; border-color: rgba(134, 174, 203, 0.28); }
.pill-cyan    { background: rgba(134, 174, 203, 0.08); color: #9dc0d6; border-color: rgba(134, 174, 203, 0.24); }
.pill-slate   { background: rgba(255, 255, 255, 0.03); color: var(--dim); border-color: var(--rule-2); }

.pulse-dot {
  position: relative; width: 6px; height: 6px; border-radius: 1px;
  background: currentColor; display: inline-block; flex-shrink: 0;
}
.pulse-dot.is-live::after { content: none; }

/* --- Traffic bars ----------------------------------------------------- */

.traffic-bar {
  height: 4px;
  border-radius: 2px;
  background: #1b1e22;
  overflow: hidden;
  position: relative;
  min-width: 90px;
}
.traffic-bar-fill {
  height: 100%;
  border-radius: 2px;
  width: 0;
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
  background: var(--cold);
}
/* inside a table a meter is an indicator, so it recedes until you read it */
.table .traffic-bar { height: 3px; background: var(--rule); }
.table .traffic-bar-fill { opacity: 0.6; }
.table tr:hover .traffic-bar-fill { opacity: 0.95; }
.traffic-bar-fill.bar-emerald { background: var(--ok); }
.traffic-bar-fill.bar-amber   { background: var(--warn); }
.traffic-bar-fill.bar-rose    { background: var(--bad); }
.traffic-bar-fill.bar-indigo  { background: var(--cold); }
.traffic-bar-fill::after { content: none !important; animation: none !important; }

/* --- Controls --------------------------------------------------------- */

.btn {
  border-radius: var(--radius-sm) !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease !important;
  box-shadow: none !important;
}
.btn-sm { font-size: 0.74rem !important; padding: 3px 9px !important; }

.btn-primary {
  background: var(--signal) !important;
  border: 1px solid #f7c469 !important;
  color: #14100a !important;
}
.btn-primary:hover, .btn-primary:focus {
  background: #f8c25c !important;
  border-color: #ffd58a !important;
  color: #14100a !important;
  transform: none;
  filter: none;
}
.btn-primary .icon { color: #14100a; }

.btn-ghost-glass {
  background: transparent;
  border: 1px solid var(--rule) !important;
  color: var(--dim);
}
.btn-ghost-glass:hover {
  background: var(--raise);
  border-color: var(--rule-2) !important;
  color: var(--chalk);
}
.btn-danger {
  background: rgba(228, 117, 127, 0.12) !important;
  border: 1px solid rgba(228, 117, 127, 0.4) !important;
  color: #f0a8ae !important;
}
.btn-danger:hover { background: rgba(228, 117, 127, 0.2) !important; color: #ffd2d5 !important; }
.btn-warning {
  background: rgba(227, 169, 78, 0.12) !important;
  border: 1px solid rgba(227, 169, 78, 0.4) !important;
  color: #f0cf95 !important;
}
.btn-warning:hover { background: rgba(227, 169, 78, 0.2) !important; }

.form-control, .form-select {
  background-color: var(--well) !important;
  border: 1px solid var(--rule) !important;
  color: var(--chalk) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.82rem;
  padding-top: 0.34rem; padding-bottom: 0.34rem;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus {
  border-color: var(--signal-line) !important;
  box-shadow: 0 0 0 3px rgba(242, 178, 63, 0.14) !important;
  background-color: var(--well) !important;
}
.input-group-text {
  background: var(--raise) !important;
  border: 1px solid var(--rule) !important;
  color: var(--faint) !important;
  border-radius: var(--radius-sm) !important;
}
.form-label { font-size: 0.74rem; font-weight: 600; color: var(--dim); margin-bottom: 5px; }
.form-hint, .form-control + .form-hint { color: var(--faint); }

.modal-content {
  background: var(--raise) !important;
  border: 1px solid var(--rule-2) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: none !important;
}
.modal-header, .modal-footer { border-color: var(--rule) !important; }

.pagination { --tblr-pagination-border-color: var(--rule); }
.page-link {
  background: transparent !important;
  border: 1px solid var(--rule) !important;
  color: var(--dim) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.78rem;
  display: inline-flex; align-items: center; gap: 4px;
}
.page-link:hover { background: var(--raise) !important; color: var(--chalk) !important; }
.page-item.active .page-link { background: var(--raise) !important; color: var(--chalk) !important; border-color: var(--rule-2) !important; }
.page-item.disabled .page-link { color: var(--faint) !important; background: transparent !important; }

/* --- Empty states ----------------------------------------------------- */

.empty { padding: 34px 16px; text-align: center; margin: 0; }
.empty-icon {
  width: 34px; height: 34px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  color: var(--faint);
  display: flex; align-items: center; justify-content: center;
}
.empty-icon .icon { width: 16px; height: 16px; }
.empty-title { color: var(--dim) !important; font-size: 0.82rem; font-weight: 500; margin: 0; }
.empty-subtitle { color: var(--faint) !important; font-size: 0.76rem; }

/* --- Toasts ----------------------------------------------------------- */

.toast-stack {
  position: fixed; top: 14px; inset-inline-end: 14px;
  z-index: 1090; display: flex; flex-direction: column; gap: 8px;
  max-width: 380px; width: calc(100vw - 28px);
}
.glass-toast {
  background: var(--raise);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; gap: 10px;
  font-size: 0.8rem;
  animation: rise 0.2s ease-out;
  overflow: hidden; position: relative;
  color: var(--chalk);
}
.glass-toast.toast-success { border-inline-start: 2px solid var(--ok); }
.glass-toast.toast-danger  { border-inline-start: 2px solid var(--bad); }
.glass-toast.toast-info    { border-inline-start: 2px solid var(--cold); }
.toast-timer {
  position: absolute; bottom: 0; inset-inline-start: 0; height: 1px;
  background: var(--signal);
  animation: toastShrink 5.5s linear forwards;
}
@keyframes toastShrink { from { width: 100%; } to { width: 0%; } }

.chart-container { position: relative; height: 280px; }

/* --- Scrollbars ------------------------------------------------------- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a4046; }

/* --- Keyboard access -------------------------------------------------- */

.skip-link {
  position: fixed;
  top: -70px;
  inset-inline-start: 14px;
  z-index: 2000;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--signal);
  border: 1px solid #f7c469;
  color: #14100a;
  font-weight: 600;
  font-size: 0.78rem;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: top 0.14s ease;
}
.skip-link:focus { top: 12px; }
#content:focus { outline: none; }

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.page-link:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  box-shadow: none;
}

.table td, .cell-main, .cell-sub, .kpi-value { font-variant-numeric: tabular-nums; }

/* --- System readout rows (bot / worker pulse) ------------------------- */

.lamp {
  width: 7px; height: 7px;
  border-radius: 1px;
  background: var(--faint);
  flex-shrink: 0;
}
.lamp.is-live {
  background: var(--ok);
  box-shadow: 0 0 0 1px rgba(93, 191, 160, 0.3), 0 0 9px rgba(93, 191, 160, 0.5);
}
.lamp.is-dead {
  background: var(--bad);
  box-shadow: 0 0 9px rgba(228, 117, 127, 0.45);
}
.sys-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.sys-row:last-of-type { border-bottom: 0; padding-bottom: 4px; }
.sys-name { font-size: 0.82rem; font-weight: 600; color: var(--chalk); line-height: 1.3; }
.sys-meta { font-size: 0.72rem; color: var(--faint); font-variant-numeric: tabular-nums; }

/* --- Segmented control (language switch) ------------------------------ */

.seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--well);
}
.seg-item {
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--faint);
  text-decoration: none;
  line-height: 1.5;
  border-inline-start: 1px solid var(--rule);
  transition: background-color 0.14s ease, color 0.14s ease;
}
.seg-item:first-child { border-inline-start: 0; }
.seg-item:hover { background: var(--raise); color: var(--chalk); }
.seg-on { background: var(--signal); color: #14100a; }
.seg-on:hover { background: #f8c25c; color: #14100a; }

/* --- Sign-in ---------------------------------------------------------- */

.access {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
}
@media (min-width: 992px) {
  .access { grid-template-columns: 1fr 1fr; place-items: stretch; padding: 0; }
}
.access-panel {
  width: 100%; max-width: 400px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.access-head {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.access-body { padding: 20px 22px 22px; }
.access-foot {
  padding: 11px 22px;
  border-top: 1px solid var(--rule);
  background: var(--well);
  display: flex; align-items: center; gap: 7px;
  color: var(--faint);
  font-size: 0.72rem;
}
.access-title { font-size: 1rem; font-weight: 700; margin: 0; color: var(--chalk); }
@media (max-width: 575.98px) { .access-note { display: none; } }
.access-note { font-size: 0.74rem; color: var(--faint); margin: 2px 0 0; }


/* wide screens: the brand side of the sign-in sheet */
@media (min-width: 992px) {
  .access-brand {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 40px;
    border-inline-end: 1px solid var(--rule);
    background: var(--panel);
  }
  .access-brand-mid { max-width: 420px; }
  .access-brand h1 {
    font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px;
    color: var(--chalk);
  }
  .access-brand p { color: var(--dim); font-size: 0.86rem; line-height: 1.7; margin: 0; }
  .access-right { display: grid; place-items: center; padding: 40px; }
}
@media (max-width: 991.98px) {
  .access-brand { display: none; }
  .access-right { display: grid; place-items: center; width: 100%; }
}

/* --- Small screens ---------------------------------------------------- */

@media (max-width: 767.98px) {
  .page-body { padding: 14px 14px 32px !important; }
  .kpi-value { font-size: 1.25rem; }
  .table tbody td { padding: 8px 10px !important; font-size: 0.78rem; }
  .table thead th { padding: 8px 10px !important; }
  .top-glass-header { padding: 0 14px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .anim-in, .traffic-bar-fill, .skip-link { animation: none !important; transition: none !important; }
}
