/* ============================================================
   ATPROTO COMMAND CENTER — wire-desk terminal
   One ruled surface. Hairlines are shared (1px grid gaps over a
   line-colored backdrop), so nested borders cannot occur.
   No border-radius. No per-row boxes. Amber on warm black.
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #111110;
  --bg-raised: #181816;
  --line: #2a2a28;
  --line-strong: #44423d;
  --text: #b8b6b0;
  --bright: #f5f4f0;
  --dim: #8a8880;
  --faint: #5c5a54;
  --signal: #ff3b1f;
  --bar: #72706a;
  --up: #f5f4f0;
  --down: #ff3b1f;
  --mid: #8a8880;
  --mono: ui-monospace, "SF Mono", "Berkeley Mono", "Iosevka", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #0a0a09;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
  /* faint CRT scanline — texture without chrome */
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.012) 0 1px,
    transparent 1px 3px
  );
}

button,
input,
select {
  font: inherit;
}

::selection {
  background: var(--bright);
  color: #111110;
}

/* ------------------------------------------------------------
   Frame: the single outer border. Everything inside divides
   itself with shared hairlines only.
   ------------------------------------------------------------ */

.frame {
  width: min(1880px, 100%);
  margin: 0 auto;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   Masthead — inverse-video slug, wire-service style
   ------------------------------------------------------------ */

.masthead {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line-strong);
}

.slug {
  margin: 0;
  background: var(--bright);
  color: #111110;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 7px 12px 6px;
  white-space: nowrap;
}

.masthead-feed {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.14em;
  border-left: 1px solid var(--line);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.masthead-meta {
  display: flex;
  align-items: stretch;
}

.status-pill,
.clock,
.byline {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.byline {
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.byline:hover {
  color: var(--signal);
}

.status-pill {
  gap: 6px;
  color: var(--dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--faint);
}

.status-live {
  color: var(--bright);
}

.status-live .status-dot {
  background: var(--signal);
  animation: blink 1.6s steps(2, start) infinite;
}

.status-connecting {
  color: var(--dim);
}

.status-connecting .status-dot {
  background: var(--dim);
  animation: blink 0.7s steps(2, start) infinite;
}

.status-error {
  background: var(--signal);
  color: #111110;
}

.status-error .status-dot {
  background: #111110;
}

@keyframes blink {
  50% { opacity: 0.25; }
}

.clock span {
  color: var(--bright);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------
   Controls — one dense toolbar, fields underlined not boxed
   ------------------------------------------------------------ */

.controls {
  border-bottom: 1px solid var(--line-strong);
}

.control-row {
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 6px 12px 7px;
}

.control-row + .control-row {
  border-top: 1px solid var(--line);
}

.field {
  display: block;
  min-width: 0;
}

.field.grow {
  flex: 1;
}

.field > span {
  display: block;
  margin-bottom: 2px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 22px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--bright);
  padding: 2px 0;
  outline: none;
}

select {
  cursor: pointer;
}

input::placeholder {
  color: var(--faint);
}

input:focus,
select:focus {
  border-bottom-color: var(--signal);
}

.field select {
  min-width: 88px;
}

button {
  min-height: 22px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  padding: 2px 10px;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

button:hover:not(:disabled) {
  border-color: var(--bright);
  color: var(--bright);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

button.primary {
  border-color: var(--signal);
  background: var(--signal);
  color: #111110;
}

button.primary:hover:not(:disabled) {
  background: var(--bright);
  border-color: var(--bright);
  color: #111110;
}

button.primary:disabled {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--faint);
  opacity: 1;
}

.button-group {
  display: flex;
  gap: 6px;
}

.preset-row {
  display: flex;
}

.preset {
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  color: var(--dim);
  padding: 2px 8px;
  min-height: 22px;
}

.preset:hover:not(:disabled) {
  border-bottom-color: var(--signal);
}

.preset.active {
  background: var(--bright);
  border-bottom-color: var(--bright);
  color: #111110;
}

.src-field {
  max-width: 380px;
  min-width: 180px;
}

.connection-url {
  overflow: hidden;
  min-height: 22px;
  color: var(--faint);
  font-size: 10px;
  line-height: 22px;
  border-bottom: 1px solid transparent;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   KPI strip — one row, vertical rules, no tiles
   ------------------------------------------------------------ */

.kpi-strip {
  display: grid;
  grid-template-columns: 1.5fr repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-strong);
}

/* lead metric dominates — the room's one big number */
.kpi:first-child {
  background: var(--bg-raised);
}

.kpi:first-child strong {
  color: var(--bright);
  font-size: clamp(24px, 2.2vw, 34px);
}

.kpi {
  padding: 7px 12px 8px;
  overflow: hidden;
}

.kpi + .kpi {
  border-left: 1px solid var(--line);
}

.kpi span,
.kpi small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.kpi span {
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin: 3px 0 2px;
  color: var(--bright);
  font-size: clamp(17px, 1.5vw, 24px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.kpi small {
  color: var(--dim);
  font-size: 10px;
}

/* ------------------------------------------------------------
   Board — shared hairlines via 1px gap over line backdrop.
   Panels are flat regions, not cards.
   ------------------------------------------------------------ */

.board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line-strong);
}

.panel {
  min-height: 190px;
  background: var(--bg);
  padding: 0 0 6px;
  overflow: hidden;
  min-width: 0;
}

.span-2 {
  grid-column: span 3;
}

.col-2 {
  grid-column: span 2;
}

.col-4 {
  grid-column: span 4;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px 5px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

h2 {
  margin: 0;
  color: var(--bright);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* terminal function code — the panel's "ticker symbol" */
h2 b {
  display: inline-block;
  margin-right: 8px;
  color: var(--signal);
  font-weight: 800;
  letter-spacing: 0.1em;
}

h2 b::after {
  content: " ❯";
  color: var(--line-strong);
}

.panel-head small {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  gap: 10px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  vertical-align: -1px;
}

.sw-events { background: var(--bright); }
.sw-posts  { background: var(--mid); }
.sw-follows { background: var(--signal); }

canvas {
  display: block;
  width: calc(100% - 24px);
  height: 218px;
  margin: 2px 12px 0;
  background: transparent;
}

/* ------------------------------------------------------------
   Flat data rows — zebra only, zero per-row chrome
   ------------------------------------------------------------ */

.growth-list,
.operation-bars,
.rank-bars,
.repo-list {
  display: block;
}

.repo-list {
  max-height: 300px;
  overflow: auto;
}

.growth-row,
.op-row,
.rank-row,
.repo-row {
  padding: 3px 12px;
}

.growth-row:nth-child(even),
.rank-row:nth-child(even),
.repo-row:nth-child(even),
.signal-card:nth-child(even) {
  background: rgba(255, 255, 255, 0.022);
}

.growth-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.growth-row strong,
.op-top strong,
.rank-top strong,
.repo-top strong {
  color: var(--bright);
  font-weight: 700;
}

.growth-row > strong {
  font-size: 12px;
}

.growth-row small {
  display: block;
  color: var(--faint);
  font-size: 10px;
}

.delta-up { color: var(--up); }
.delta-down { color: var(--down); }
.delta-flat { color: var(--dim); }

.op-top,
.rank-top,
.repo-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
}

.rank-top span,
.repo-top span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 3px;
  margin-top: 3px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--bar);
}

.op-row:first-child .bar-fill {
  background: var(--bright);
}

.micro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}

.micro-grid div {
  padding: 6px 12px 2px;
}

.micro-grid div + div {
  border-left: 1px solid var(--line);
}

.micro-grid span {
  display: block;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.micro-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--bright);
  font-size: 15px;
  line-height: 1;
}

.micro-grid small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   Table — rules + zebra, no wrapper box
   ------------------------------------------------------------ */

.table-wrap {
  overflow: auto;
  max-height: 300px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 3px 8px;
  text-align: left;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  padding-left: 12px;
}

th:last-child,
td:last-child {
  padding-right: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line-strong);
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

td {
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
}

td:first-child {
  color: var(--bright);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.022);
}

.inline-bar {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  align-items: center;
}

.inline-bar span {
  width: 100%;
  max-width: 180px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.inline-bar i {
  display: block;
  height: 100%;
  background: var(--bar);
}

.empty {
  padding: 10px 12px;
  color: var(--faint);
  text-align: left;
}

/* ------------------------------------------------------------
   Accounts — chips become slash-separated text
   ------------------------------------------------------------ */

.repo-meta {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: lowercase;
}

.repo-meta span + span::before {
  content: " / ";
  color: var(--line-strong);
}

.repo-top a,
.signal-card strong a {
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repo-top a {
  color: var(--bright);
}

.repo-top a:hover,
.signal-card strong a:hover {
  color: var(--signal);
  text-decoration: underline;
}

/* ------------------------------------------------------------
   Content signals — ruled cells, not cards
   ------------------------------------------------------------ */

.signal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signal-card {
  padding: 5px 12px 6px;
  overflow: hidden;
}

.signal-card:nth-child(even) {
  border-left: 1px solid var(--line);
}

.signal-card span {
  display: block;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.signal-card strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--bright);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-card small {
  display: block;
  overflow: hidden;
  color: var(--dim);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   Event tape — flat ticker rows
   ------------------------------------------------------------ */

.event-tape {
  overflow: auto;
  max-height: 300px;
}

.event-row {
  display: grid;
  grid-template-columns: 64px 52px minmax(150px, 1fr) minmax(140px, 0.8fr) minmax(120px, 0.7fr);
  gap: 10px;
  align-items: baseline;
  padding: 2px 12px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
}

.event-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.022);
}

.event-kind {
  color: var(--bright);
  text-transform: uppercase;
  font-weight: 700;
  font-size: 10px;
}

.event-collection,
.event-did,
.event-extra {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-time {
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  white-space: nowrap;
}

.event-did {
  color: var(--dim);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.toggle input {
  width: auto;
  min-height: auto;
  accent-color: var(--signal);
  margin: 0;
}

/* ------------------------------------------------------------
   Footline
   ------------------------------------------------------------ */

.footline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 12px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.footline span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

@media (max-width: 1460px) {
  .board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .span-2,
  .col-4 {
    grid-column: span 2;
  }

  .col-2 {
    grid-column: span 1;
  }
}

@media (max-width: 1170px) {
  .control-row {
    flex-wrap: wrap;
  }

  .kpi-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .kpi:nth-child(n + 5) {
    border-top: 1px solid var(--line);
  }

  .kpi:nth-child(5) {
    border-left: 0;
  }
}

@media (max-width: 1100px) {
  .board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .masthead {
    flex-wrap: wrap;
  }

  .field.grow,
  .src-field {
    flex: 1 1 100%;
    max-width: none;
  }

  .masthead-feed {
    display: none;
  }

  .masthead-meta {
    margin-left: auto;
  }

  .board {
    grid-template-columns: 1fr;
  }

  .span-2,
  .col-2,
  .col-4 {
    grid-column: auto;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .kpi:nth-child(odd) {
    border-left: 0;
  }

  .event-row {
    grid-template-columns: 60px 48px minmax(120px, 1fr);
  }

  .event-did,
  .event-extra {
    display: none;
  }

  .footline {
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 470px) {
  .signal-grid,
  .micro-grid {
    grid-template-columns: 1fr;
  }

  .signal-card:nth-child(even),
  .micro-grid div + div {
    border-left: 0;
  }

  canvas {
    height: 176px;
  }
}
