/* subcore console — visual system.
 *
 * The subject is a network operations desk: servers, inbounds, quotas in bytes, expiry dates.
 * Two decisions drive everything below.
 *
 * 1. The ground is deep slate-TEAL, not black. Operators sit in this for hours next to a
 *    terminal; enamel-green instrument panels are the vernacular of the gear this product
 *    actually manages, and they are easier to read against than pure black.
 * 2. THE MONO IS THE DISPLAY FACE. Addresses, uuids, ports, byte counts and tokens are not
 *    incidental values in this tool -- they ARE the content. So they get the typographic
 *    emphasis (tabular figures, real size, letterspaced small-caps labels as instrument
 *    legends) and the Persian chrome stays quiet around them. No webfont: the CSP forbids a
 *    CDN, and the system stack renders Persian well on the operator's machine.
 *
 * Colour is a status-lamp language, used sparingly: amber means LOOK, mint means healthy,
 * red means broken. A page with no amber on it is a page with nothing to do.
 */

:root {
  --ground: #0f1719;
  --panel: #162124;
  --panel-hi: #1c2b2f;
  --line: #26383c;
  --line-soft: #1d2b2e;
  --ink: #dde8e9;
  --dim: #7c9599;
  --dimmer: #55696d;

  --signal: #f0a63c;   /* attention */
  --live: #4fcfa6;     /* healthy */
  --fault: #e8685d;    /* broken */
  --link: #74c4dd;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: ui-sans-serif, -apple-system, "SF Arabic", "Segoe UI", Tahoma, sans-serif;

  --rail: 15rem;
  --r: 7px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
}

/* Technical values: LTR, tabular, selectable in one click. These are copy-paste targets. */
.tech {
  font-family: var(--mono);
  direction: ltr;
  unicode-bidi: isolate;
  user-select: all;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Instrument legend: the small letterspaced label above a value. */
.legend {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dimmer);
  direction: ltr;
}

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

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── shell ─────────────────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 1fr var(--rail); min-height: 100vh; }

.rail {
  background: var(--panel);
  border-inline-start: 1px solid var(--line);
  padding: 1rem .9rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.brand { display: flex; align-items: baseline; gap: .5rem; }
.brand b { font-size: 15px; letter-spacing: .02em; }
.brand .ver { font-family: var(--mono); font-size: 10px; color: var(--dimmer); }

.rail nav { display: flex; flex-direction: column; gap: .1rem; }
.rail nav a {
  color: var(--dim);
  padding: .34rem .55rem;
  border-radius: var(--r);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}
.rail nav a:hover { background: var(--panel-hi); color: var(--ink); text-decoration: none; }
.rail nav a[aria-current="page"] {
  background: var(--panel-hi);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--signal);
}
.rail nav a .n { font-family: var(--mono); font-size: 11px; color: var(--dimmer); }

.rail .foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; }
.rail .who { color: var(--dim); font-size: 12px; }

main { padding: 1.4rem 1.6rem 4rem; min-width: 0; }

/* ── page head ─────────────────────────────────────────────────────────────── */

.head { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
h1 { font-size: 1.2rem; font-weight: 650; margin: 0; letter-spacing: .01em; }
.head .stamp { margin-inline-start: auto; }
.stamp { font-family: var(--mono); font-size: 11px; color: var(--dimmer); direction: ltr; }
.hint { color: var(--dim); margin: 0 0 .9rem; }

/* ── meters: the console's signature ───────────────────────────────────────────
 * One track carries BOTH axes. The filled bar is quota consumed; the hairline notch is how
 * far through the cycle the clock is. When the bar is past the notch the subscription runs
 * out of data before it runs out of days -- which is the question a column of bytes cannot
 * answer, and the reason this element exists at all.
 */

.meter { position: relative; height: 7px; background: var(--line-soft); border-radius: 99px; overflow: visible; }
.meter .fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 99px; background: var(--live); }
.meter.hot .fill { background: var(--signal); }
.meter.over .fill { background: var(--fault); }
.meter .clock {
  position: absolute;
  inset-block: -3px;
  width: 2px;
  background: var(--ink);
  opacity: .55;
  border-radius: 2px;
}
.meter-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center; }
.meter-cap { font-family: var(--mono); font-size: 11px; color: var(--dim); direction: ltr; white-space: nowrap; }

/* ── stat tiles ────────────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .7rem; margin-bottom: 1.4rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .85rem; }
.tile .v { font-family: var(--mono); font-size: 1.45rem; font-variant-numeric: tabular-nums; line-height: 1.15; direction: ltr; }
.tile .v.sig { color: var(--signal); }
.tile .sub { font-size: 11px; color: var(--dim); margin-top: .1rem; }

/* ── panels + tables ───────────────────────────────────────────────────────── */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 1.2rem; }
.panel > header { display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem; border-bottom: 1px solid var(--line); }
.panel > header h2 { font-size: .92rem; font-weight: 600; margin: 0; }
.panel > .body { padding: .85rem; }

.scroll { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: .38rem .7rem; text-align: start; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
.grid th {
  position: sticky; top: 0; background: var(--panel);
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--dimmer); font-weight: 500; direction: ltr;
}
.grid tbody tr:hover { background: var(--panel-hi); }
.grid td.wrap { white-space: pre-wrap; max-width: 42rem; }
.grid tbody tr:last-child td { border-bottom: 0; }

.ok { color: var(--live); }
.bad { color: var(--fault); }
.warn { color: var(--signal); }

/* Status lamp — a filled dot, the same language as the gear this manages. */
.lamp { display: inline-block; width: 7px; height: 7px; border-radius: 99px; background: var(--dimmer); margin-inline-end: .4rem; vertical-align: baseline; }
.lamp.on { background: var(--live); box-shadow: 0 0 6px -1px var(--live); }
.lamp.off { background: var(--fault); }
.lamp.idle { background: var(--signal); }

/* ── forms ─────────────────────────────────────────────────────────────────── */

.lookup { display: flex; gap: .7rem; align-items: end; flex-wrap: wrap; margin-bottom: .9rem; }
.lookup label, .login label { display: block; color: var(--dim); font-size: 12px; }
input, select {
  display: block; margin-top: .25rem; padding: .4rem .55rem;
  background: var(--ground); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  font: inherit; min-width: 12rem;
}
input:focus { border-color: var(--dim); outline: none; }
button {
  padding: .42rem .95rem; border: 1px solid transparent; border-radius: var(--r);
  background: var(--signal); color: #21170a; font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.quiet { background: transparent; border-color: var(--line); color: var(--dim); font-weight: 400; }
button.quiet:hover { color: var(--ink); border-color: var(--dim); }

/* ── login ─────────────────────────────────────────────────────────────────── */

.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login { width: min(23rem, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem; }
.login h1 { margin-bottom: .2rem; }
.login .legend { margin-bottom: 1.1rem; display: block; }
.login label { margin-bottom: .8rem; }
.login input { width: 100%; }
.login button { width: 100%; margin-top: .3rem; }
.error { color: var(--fault); font-size: 12.5px; }

.tables-list { columns: 4; column-gap: 1.4rem; list-style: none; padding: 0; margin: 0; }
.tables-list li { break-inside: avoid; padding: .12rem 0; }
.pager { display: flex; gap: 1rem; margin-top: .9rem; }
.empty { color: var(--dim); padding: 1.4rem; text-align: center; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .rail { border-inline-start: 0; border-bottom: 1px solid var(--line); }
  .rail .foot { margin-top: 0; }
  .tables-list { columns: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Send box on the customer card. Deliberately plain: the operator is writing to a real person,
   and the only thing that should draw the eye is the text they are about to send. */
.sendbox { margin-top: 1rem; display: grid; gap: .45rem; }
.sendbox textarea {
  width: 100%; resize: vertical; padding: .55rem .65rem; border-radius: 6px;
  background: var(--panel-hi); color: var(--ink); border: 1px solid var(--line);
  font: inherit; line-height: 1.6;
}
.sendbox textarea:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.sendbox button { justify-self: start; }

/* One control per row: label, the current value as the input's default, and the button. Reads
   as a settings sheet rather than a form, because that is what it is. */
.ctl { display: flex; gap: .7rem; align-items: center; margin: .55rem 0; flex-wrap: wrap; }
.ctl label { min-width: 10rem; color: var(--dim); }
.ctl input, .ctl select {
  padding: .35rem .5rem; background: var(--panel-hi); color: var(--ink);
  border: 1px solid var(--line); border-radius: 5px; font: inherit; min-width: 9rem;
}
.ctl .v-inline { font-variant-numeric: tabular-nums; min-width: 5rem; }

/* ── data table ─────────────────────────────────────────────────────────────────────────────
   An operations table is read by scanning columns, so the work goes into alignment and into
   keeping the header available while the body scrolls. Everything else stays out of the way. */
.tablebar { display: flex; align-items: center; gap: .8rem; margin: .5rem 0 .8rem; flex-wrap: wrap; }
.tablebar .grow { flex: 1; }
.tablebar .count { font-variant-numeric: tabular-nums; color: var(--dim); }
.pg {
  padding: .25rem .7rem; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink); text-decoration: none;
}
.pg:hover { border-color: var(--link); }
.pg.off { opacity: .35; pointer-events: none; }

.tablewrap { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; }
/* The header must stay put: a 58-column table is unreadable if you lose the names on row 20. */
table.data thead th {
  position: sticky; top: 0; z-index: 2; background: var(--panel-hi);
  border-bottom: 1px solid var(--line); white-space: nowrap; padding: .45rem .6rem;
  text-align: start; vertical-align: bottom;
}
table.data td { border-bottom: 1px solid var(--line-soft); padding: 0; white-space: nowrap; }
table.data tbody tr:hover td { background: var(--panel-hi); }
.sortlink { color: var(--ink); text-decoration: none; display: inline-block; }
.sortlink.on { color: var(--link); }
.sortlink .arrow { font-size: .7em; margin-inline-start: .25rem; }

/* The affordance lives on the header, so "can I change this column" is answered before the
   click rather than by a refusal after it. */
.tag {
  display: block; font-size: .62rem; letter-spacing: .06em; text-transform: uppercase;
  margin-top: .2rem; font-weight: 500;
}
.tag.ed { color: var(--live); }
.tag.sv { color: var(--link); }

.cell { font-variant-numeric: tabular-nums; }
.cell > *:not(form) { display: block; padding: .35rem .6rem; }
td.cell:not(.ed) { padding: .35rem .6rem; }
/* A locked cell is not merely un-clickable — hovering says why. */
td.cell.lk { color: var(--dim); cursor: help; }
td.cell.ed form { display: flex; align-items: stretch; }
.cellinput {
  width: 100%; min-width: 7rem; border: 0; background: transparent; color: var(--ink);
  font: inherit; padding: .35rem .6rem; border-inline-start: 2px solid transparent;
}
.cellinput:hover { background: var(--panel-hi); }
.cellinput:focus {
  outline: none; background: var(--panel-hi); border-inline-start-color: var(--link);
}
/* The save button only appears once the row is engaged, so a wide table is not a wall of ticks. */
.save { opacity: 0; border: 0; background: transparent; color: var(--live); cursor: pointer; padding: 0 .4rem; }
td.cell.ed:hover .save, td.cell.ed:focus-within .save { opacity: 1; }

/* ── conversation thread ────────────────────────────────────────────────────────────────────
   The transcript is the screen support actually lives in, so it reads as the conversation the
   customer had rather than as rows from a table. Inbound and outbound take opposite sides;
   everything else is deliberately quiet so the words carry. */
.thread { display: flex; flex-direction: column; gap: .5rem; padding: .5rem 0; max-width: 62rem; }
.msg { display: flex; }
.msg.in { justify-content: flex-start; }
.msg.out { justify-content: flex-end; }
.bubble {
  max-width: 34rem; padding: .5rem .7rem; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); line-height: 1.65;
}
.msg.out .bubble { background: var(--panel-hi); border-color: var(--line); }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble time {
  display: block; margin-top: .3rem; font-family: var(--mono);
  font-size: .68rem; color: var(--dimmer); font-variant-numeric: tabular-nums;
}
.klabel {
  display: inline-block; margin-bottom: .25rem; font-size: .62rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--dim);
}
/* Receipts are the reason support keeps a second window open; the image belongs in the thread. */
.msg.receipt .bubble { border-color: var(--signal); }
.rlabel { font-size: .75rem; color: var(--signal); margin-bottom: .35rem; }
.rimg {
  display: block; max-width: 20rem; max-height: 26rem; width: auto; height: auto;
  border-radius: 5px; border: 1px solid var(--line);
}
.noimg { color: var(--dimmer); font-size: .8rem; }
.fineprint { color: var(--dimmer); font-size: .78rem; margin-top: 1rem; }
