/* EasyAI Control — Saif's own panel. EasyAI's palette (Brand/), state
   colours that only ever mean state, Barlow Condensed for what is counted. */

@font-face {
  font-family: "Barlow Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/barlow-condensed-600.woff") format("woff");
}

:root {
  --deep: #1d2d3d;
  --steel: #5980a6;
  --signal: #94bce3;
  --mist: #b4c3d1;
  --paper: #f2f2f3;
  --ink: #1d1f20;
  --bg: var(--paper);
  --surface: #ffffff;
  --line: #dde3e9;
  --text: var(--ink);
  --text-2: #55606b;
  --up: #1f8a5b;
  --warn: #b7791f;
  --down: #c2412d;
  --idle: #8a95a1;
  --r: 10px;
  --figure: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111a23;
    --surface: #182533;
    --line: #26374a;
    --text: #e8edf2;
    --text-2: #9fb0c1;
    --up: #45c08a;
    --warn: #e0a64a;
    --down: #f0705c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── The bar ── */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); background: var(--deep); color: var(--paper);
}
.bar__home { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.bar__home img { height: 34px; width: auto; display: block; }
.bar__word { font: 600 1.35rem/1 var(--figure); letter-spacing: .06em; text-transform: uppercase; color: var(--signal); }
.bar__keys { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.key {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--deep); color: var(--paper); font-weight: 600; cursor: pointer;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
}
.key:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 45%, transparent); }
.key:active { transform: scale(.97); }
.key:disabled { opacity: .45; cursor: default; box-shadow: none; }
.key:focus-visible, .row:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--signal); outline-offset: 2px;
}
.key--light { background: var(--signal); color: var(--deep); }
.key--ghost { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
.key--danger { background: var(--down); color: #fff; }
.key--small { min-height: 32px; padding: 0 12px; font-size: .875rem; }
.view .key--ghost { color: var(--text); }
@media (prefers-color-scheme: dark) {
  .view .key:not(.key--ghost):not(.key--danger):not(.key--light) { background: var(--steel); color: #fff; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; row-gap: 8px; }
  .bar__keys { width: 100%; justify-content: flex-start; }
  .bar .key { min-height: 34px; padding: 0 12px; font-size: .875rem; }
  .totals { grid-template-columns: 1fr 1fr; }
}

.view { max-width: 1240px; margin: 0 auto; padding: 20px 16px 64px; outline: none; }

/* ── Sign in ── */
.signin { max-width: 360px; margin: 12vh auto 0; background: var(--surface); border-radius: var(--r); padding: 28px; box-shadow: 0 1px 0 var(--line), 0 12px 32px rgba(29,45,61,.08); }
.signin h1 { margin: 0 0 4px; font: 600 2rem/1 var(--figure); letter-spacing: .02em; }
.signin p { margin: 0 0 20px; color: var(--text-2); }

/* ── Forms ── */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: .8125rem; font-weight: 600; color: var(--text-2); }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.error { color: var(--down); font-weight: 600; min-height: 1.4em; margin: 4px 0 0; }

/* ── Totals ── */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.total { background: var(--surface); border-radius: var(--r); padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--line); }
.total b { display: block; font: 600 2.1rem/1 var(--figure); letter-spacing: .01em; }
.total span { font-size: .8125rem; color: var(--text-2); }
.total--down b { color: var(--down); }
.total--warn b { color: var(--warn); }

/* ── Clients ── */
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 12px; flex-wrap: wrap; }
.head h1 { margin: 0; font: 600 2.4rem/1 var(--figure); letter-spacing: .01em; }
.muted { color: var(--text-2); }
.notice { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }

.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 2fr) minmax(110px, .7fr) minmax(140px, .9fr);
  gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  text-decoration: none; transition: box-shadow .2s ease, transform .12s ease;
}
.row:hover { box-shadow: inset 0 0 0 1px var(--steel), 0 6px 18px rgba(29,45,61,.08); }
.row:active { transform: scale(.995); }
.row__name b { display: block; font: 600 1.35rem/1.1 var(--figure); letter-spacing: .01em; }
.row__name small { color: var(--text-2); }
.row__services { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--bg); font-size: .8125rem; font-weight: 600; }
.cell small { display: block; font-size: .75rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.cell span { font-weight: 600; }
.fig { font-family: var(--figure); font-size: 1.15rem; letter-spacing: .01em; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; background: var(--idle); vertical-align: middle; }
.dot--up { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); }
.dot--down { background: var(--down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 22%, transparent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--down) 8%, transparent); } }
@media (prefers-reduced-motion: reduce) { .dot--down { animation: none; } }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--line); color: var(--text-2); }
.pill--active, .pill--ok, .pill--done, .pill--lead { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.pill--trial, .pill--due, .pill--running, .pill--queued, .pill--building, .pill--paused { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill--suspended, .pill--overdue, .pill--failed { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }

@media (max-width: 900px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row__name, .row__services { grid-column: 1 / -1; }
}

/* ── One client ── */
.back { display: inline-block; margin-bottom: 10px; color: var(--steel); font-weight: 600; text-decoration: none; }
.panes { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.pane { background: var(--surface); border-radius: var(--r); padding: 16px 18px; box-shadow: inset 0 0 0 1px var(--line); }
.pane h2 { margin: 0 0 12px; font: 600 1.45rem/1 var(--figure); letter-spacing: .02em; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pane--wide { grid-column: 1 / -1; }
.pane h3 { margin: 16px 0 8px; font: 600 1.15rem/1 var(--figure); letter-spacing: .03em; text-transform: uppercase; color: var(--text-2); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 28px; }
.edit { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.edit summary, .pane__summary { cursor: pointer; font-weight: 700; color: var(--steel); }
.pane__summary { font: 600 1.45rem/1 var(--figure); letter-spacing: .02em; color: var(--text); }
.edit .key--danger { margin-top: 10px; }
.space-top { margin-top: 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--text-2); font-size: .875rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; background: var(--bg); }
.list li > div { min-width: 0; }
.list--spaced { margin-top: 12px; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.token { font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; color: var(--text-2); }
.log { margin: 10px 0 0; max-height: 320px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: #0f1720; color: #cfe0f1; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; font-weight: 600; }
.check input { width: 18px; min-height: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 999px;
  background: var(--deep); color: var(--paper); font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: rise .25s cubic-bezier(.16, 1, .3, 1);
}
.toast--bad { background: var(--down); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
