/* ==========================================================================
   GUHSO STUDIO
   A control room, not a dashboard template.
   Signature: the thread rail — a hairline of spider silk running down the
   left edge, knotting at every section. Anansi is the house mascot; the web
   is the only ornament in the room.
   ========================================================================== */

:root {
  --void:      #0B0D16;
  --panel:     #131726;
  --panel-hi:  #1A1F32;
  --line:      #262C42;
  --thread:    #3B4266;
  --gold:      #E9B44C;
  --gold-dim:  #8A6B2C;
  --jade:      #3FBF9A;
  --rust:      #E2593F;
  --violet:    #8C7BE8;
  --text:      #E8E6DE;
  --muted:     #8D93AB;

  --rail:      2.25rem;   /* width of the thread rail gutter */
  --radius:    3px;

  --display: "Bricolage Grotesque", "Archivo", system-ui, sans-serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font: 15px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

/* Faint web texture — two crossing hairlines, barely there. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg, transparent 0 118px, rgba(59,66,102,.16) 118px 119px),
    repeating-linear-gradient(65deg,  transparent 0 118px, rgba(59,66,102,.10) 118px 119px);
  z-index: 0;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11,13,22,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .55rem;
}
.wordmark:hover { text-decoration: none; }
.wordmark em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: .22em;
  font-size: .68rem;
}

/* The on-air lamp: amber when the queue is working, dim otherwise. */
.lamp {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--thread);
  box-shadow: 0 0 0 3px rgba(59,66,102,.25);
  flex: 0 0 auto;
}
.lamp.live { background: var(--gold); box-shadow: 0 0 0 3px rgba(233,180,76,.18); animation: pulse 1.8s ease-in-out infinite; }
.lamp.warn { background: var(--rust); box-shadow: 0 0 0 3px rgba(226,89,63,.18); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.nav { display: flex; gap: .15rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: .4rem .6rem;
  border-radius: var(--radius);
}
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a[aria-current] { color: var(--void); background: var(--gold); }

/* ------------------------------------------------------------------ page */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 5rem;
}

/* The thread rail. Sections hang off it like knots in a web. */
.rail { position: relative; padding-left: var(--rail); }
.rail::before {
  content: "";
  position: absolute;
  left: .55rem; top: .5rem; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, var(--thread), transparent 96%);
}

.section { position: relative; margin-bottom: 2.5rem; }
.section::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--rail) + .3rem);
  top: .48rem;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--void);
  border: 1px solid var(--thread);
}
.section.is-live::before { border-color: var(--gold); background: var(--gold); }

h1 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.015em;
  margin: 0 0 .25rem;
}

h2 {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .9rem;
}

h3 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 .2rem;
}

.lede { color: var(--muted); margin: 0 0 1.5rem; max-width: 46rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono  { font-family: var(--mono); }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.card + .card { margin-top: .9rem; }
.card-head {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }

.grid { display: grid; gap: .9rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* --------------------------------------------------------------- metrics */

.stat { padding: .95rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat .k {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: .35rem;
}
.stat .v {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
}
.stat .v.ok   { color: var(--jade); }
.stat .v.bad  { color: var(--rust); }
.stat .v.warn { color: var(--gold); }
.stat .sub { display: block; margin-top: .35rem; font-size: .78rem; color: var(--muted); }

/* --------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; }
th {
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0 .6rem .5rem 0;
  border-bottom: 1px solid var(--line);
}
td {
  padding: .6rem .6rem .6rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: .88rem;
}
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; padding-right: 0; font-family: var(--mono); }

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .18rem .45rem;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.pill.up, .pill.done   { color: var(--jade); }
.pill.down, .pill.failed { color: var(--rust); }
.pill.queued, .pill.running { color: var(--gold); }
.pill.unknown, .pill.off { color: var(--muted); }
.pill.solid { background: currentColor; }
.pill.solid span { color: var(--void); }

/* --------------------------------------------------------------- sparks */

.spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.spark i {
  display: block;
  width: 3px;
  background: var(--thread);
  border-radius: 1px;
  min-height: 2px;
}
.spark i.ok  { background: var(--jade); }
.spark i.bad { background: var(--rust); }

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

label { display: block; margin-bottom: 1rem; }
.field-label {
  display: block;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .35rem;
}
.field-help { display: block; margin-top: .3rem; font-size: .78rem; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%;
  padding: .55rem .65rem;
  background: var(--void);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: .9rem;
}
input[type=password], .mono-input { font-family: var(--mono); font-size: .85rem; }
textarea { font-family: var(--body); line-height: 1.55; resize: vertical; min-height: 5.5rem; }
input::placeholder, textarea::placeholder { color: #545B78; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.check { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: 1rem; }
.check input { margin: .25rem 0 0; accent-color: var(--gold); width: 15px; height: 15px; }
.check span { font-size: .9rem; }

button, .btn {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .5rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-hi);
  color: var(--text);
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--thread); background: #212742; text-decoration: none; }
button.primary { background: var(--gold); border-color: var(--gold); color: var(--void); font-weight: 600; }
button.primary:hover { background: #F2C063; border-color: #F2C063; }
button.ghost { background: transparent; }
button.danger { color: var(--rust); border-color: rgba(226,89,63,.4); background: transparent; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- notices */

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  background: var(--panel);
  padding: .75rem .9rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: .88rem;
  white-space: pre-wrap;
}
.notice.ok  { border-left-color: var(--jade); }
.notice.bad { border-left-color: var(--rust); }
.notice code, .notice .mono { font-family: var(--mono); font-size: .84rem; }

/* ------------------------------------------------------------ settings */

.tabs {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: .6rem;
}
.tabs a {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: .4rem .7rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
}
.tabs a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.tabs a[aria-current] { color: var(--gold); border-color: var(--line); background: var(--panel); }

.stored {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--jade);
  border: 1px solid rgba(63,191,154,.3);
  padding: .1rem .35rem;
  border-radius: 2px;
}
.unset {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: .1rem .35rem;
  border-radius: 2px;
}

/* ------------------------------------------------------------ job/answer */

.answer {
  background: var(--void);
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  white-space: pre-wrap;
  font-size: .89rem;
  line-height: 1.62;
  overflow-x: auto;
}

.log-line {
  display: grid;
  grid-template-columns: 8.5rem 9rem 1fr;
  gap: .75rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .78rem;
}
.log-line:last-child { border-bottom: 0; }
.log-line .t { color: var(--muted); }
.log-line .a { color: var(--gold); }

/* ------------------------------------------------------------ login page */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}
.login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
}
.login-card .wordmark { margin-bottom: .35rem; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 640px) {
  :root { --rail: 1.4rem; }
  .rail::before { left: .25rem; }
  .section::before { left: calc(-1 * var(--rail) + .05rem); }
  .shell { padding: 1.25rem .9rem 4rem; }
  .topbar-inner { padding: .7rem .9rem; }
  .nav { width: 100%; margin-left: 0; }
  .nav a { padding: .35rem .45rem; font-size: .68rem; }
  .log-line { grid-template-columns: 1fr; gap: .1rem; }
  .stat .v { font-size: 1.4rem; }
  table { display: block; overflow-x: auto; }
}

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