/* ============================================================================
   Pulse admin panel — restyle in Pulse house style (dark + cyan).
   DROP-IN replacement for pulse-license-current/admin/admin.css.

   Scope: LOOK ONLY. No DOM ids/classes are renamed here — this file targets the
   exact hooks admin.js/index.html already use (#admin-token, #license-form,
   #policy, #notice, #result, #history-*, .error, .secondary, .compact, table…).
   Do NOT change admin.js or the API contract; this is purely presentational.

   Palette + type mirror the Pulse site (styles.css / navisworks-launch-preview.css):
   bg #020305, cyan accent #6FD2FF, Archivo (display) + JetBrains Mono (labels).

   Fonts: the site self-hosts Archivo + JetBrains Mono (GDPR-safe, no CDN). To use
   them here, copy the site's fonts/ + a fonts.css into admin/ and add
   <link rel="stylesheet" href="/admin/fonts.css"> to index.html (Codex: adjust the
   @font-face url() paths to be relative to /admin/). Until then the stack falls back
   to system fonts gracefully — no layout shift, just different glyphs.
   ============================================================================ */

:root {
  color-scheme: dark;

  --bg:            #020305;
  --bg-band:       #07090c;
  --card-bg:       rgba(255, 255, 255, 0.02);
  --card-border:   rgba(255, 255, 255, 0.10);
  --hairline:      rgba(255, 255, 255, 0.08);

  --accent:        #6fd2ff;   /* cyan */
  --accent-soft:   #9be0ff;
  --accent-glow:   rgba(111, 210, 255, 0.13);

  --text-head:     #f0f5f9;
  --text-card:     #eaf2f8;
  --text-body:     rgba(228, 238, 246, 0.62);
  --text-muted:    rgba(228, 238, 246, 0.42);

  --danger:        #ff9b91;
  --danger-bg:     rgba(255, 155, 145, 0.10);
  --ok:            #7fe0b0;
  --warn:          #ffd487;

  --font-display:  'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:     'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius:        14px;
  --radius-sm:     9px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 82% -8%, rgba(111, 210, 255, 0.06), transparent 55%),
    var(--bg);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding: 40px 20px 72px;
}

.wrap, main, .container { /* whatever the outer container is; harmless if unused */
  max-width: 960px;
  margin: 0 auto;
}

/* ---- Header / eyebrow / titles ------------------------------------------- */

.eyebrow {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

h1 {
  color: var(--text-head);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.05;
  margin: 0 0 6px;
}

h2 {
  color: var(--text-head);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 18px;
  margin: 0 0 14px;
}

p { color: var(--text-body); }
a { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  margin: 0 0 22px;
}

.login-screen {
  min-height: calc(100vh - 112px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: clamp(28px, 6vw, 76px);
  align-items: center;
}

.login-brand {
  max-width: 560px;
}

.login-brand h1 {
  font-size: clamp(34px, 6vw, 64px);
}

#app-shell[hidden] {
  display: none;
}

.login-screen[hidden] {
  display: none;
}

.panel-nav,
.filters,
.form-grid,
.wizard {
  display: grid;
  gap: 14px;
}

.panel-nav {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  max-width: 520px;
}

.panel-nav a {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--text-body);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: none;
  text-decoration: none;
}

.panel-nav a span {
  display: block;
  color: var(--text-muted);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.panel-nav a.active {
  border-color: rgba(111, 210, 255, 0.55);
  background: rgba(111, 210, 255, 0.10);
  color: var(--accent-soft);
}

.panel-nav a.active span {
  color: var(--accent);
}

.filters {
  grid-template-columns: minmax(240px, 1.45fr) repeat(3, minmax(150px, 1fr));
  align-items: end;
  margin: 18px 0 16px;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.018);
}

.form-grid,
.wizard {
  grid-template-columns: 1fr;
}

.login-card {
  border-color: rgba(111, 210, 255, 0.22);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin: 0 0 12px;
}

.section-head p {
  max-width: 420px;
  margin: 0;
}

.product-picker {
  min-width: 220px;
  margin: 0;
}

.issue-card {
  border-color: rgba(111, 210, 255, 0.16);
}

.panel[hidden],
.login-card[hidden] {
  display: none;
}

/* ---- Cards --------------------------------------------------------------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin: 0 0 20px;
  backdrop-filter: blur(2px);
}

/* ---- Forms --------------------------------------------------------------- */

label {
  display: block;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 7px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-card);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder { color: var(--text-muted); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select:disabled,
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.static-field {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
}

.static-field span {
  display: block;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.static-field strong {
  display: block;
  color: var(--text-card);
  font-family: var(--font-body);
  font-size: 15px;
}

.static-field small {
  display: block;
  color: var(--text-muted);
  margin-top: 6px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

select option {
  background: #f7fbff;
  color: #101820;
}

select option:checked {
  background: #8fc8f4;
  color: #071016;
}

.field, .row, .form-row { margin: 0 0 16px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }

/* ---- Buttons ------------------------------------------------------------- */

button {
  appearance: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 13px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #020305;
  transition: filter 0.15s ease, transform 0.05s ease, background 0.15s ease;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

/* Ghost / secondary buttons (admin.js adds .secondary to some action buttons). */
button.secondary,
.secondary {
  background: transparent;
  border-color: rgba(111, 210, 255, 0.45);
  color: var(--accent-soft);
}
button.secondary:hover { background: rgba(111, 210, 255, 0.08); filter: none; }
button.secondary.warning {
  border-color: rgba(255, 212, 135, 0.45);
  color: var(--warn);
}
button.secondary.warning:hover { background: rgba(255, 212, 135, 0.09); }
button.secondary.danger {
  border-color: rgba(255, 155, 145, 0.50);
  color: var(--danger);
}
button.secondary.danger:hover { background: var(--danger-bg); }
button.secondary.success {
  border-color: rgba(127, 224, 176, 0.45);
  color: var(--ok);
}
button.secondary.success:hover { background: rgba(127, 224, 176, 0.09); }

/* Compact buttons in table action cells (admin.js adds .compact). */
button.compact,
.compact {
  padding: 7px 13px;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: 8px;
  padding: 0;
  border-radius: 999px;
  border-color: rgba(111, 210, 255, 0.35);
  background: rgba(111, 210, 255, 0.06);
  color: var(--accent-soft);
  font-size: 13px;
  letter-spacing: 0;
}

.icon-button:hover {
  background: rgba(111, 210, 255, 0.14);
  filter: none;
}

/* ---- Notice / result ----------------------------------------------------- */

#notice,
#result {
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  margin: 14px 0 0;
  font-size: 13px;
}

#result {
  background: rgba(111, 210, 255, 0.06);
  border: 1px solid rgba(111, 210, 255, 0.22);
  color: var(--text-card);
}
#result-meta { font-family: var(--font-mono); font-size: 12px; color: var(--text-body); }

/* Error state (admin.js toggles .error on #notice). Preserve this class name. */
#notice.error,
.error {
  background: var(--danger-bg);
  border: 1px solid rgba(255, 155, 145, 0.35);
  color: var(--danger);
}

/* ---- History table ------------------------------------------------------- */

#history-table-wrap {
  overflow-x: auto;                 /* wide table scrolls in its own box */
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-band);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-body);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
tbody td:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key-cell {
  white-space: nowrap;
  min-width: 116px;
}

.key-cell-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

td .key-mask,
.key-mask { font-family: var(--font-mono); color: var(--text-muted); letter-spacing: 0.05em; }

#history-empty { color: var(--text-muted); padding: 18px 2px; }

/* ---- Status + policy badges (OPTIONAL, additive) -------------------------
   admin.js renders state text via labelForState() and the policy code as text.
   IF Codex wraps those in a <span class="badge badge--state ..."> the classes
   below style them. Data-driven so unknown states/policies still get a neutral
   pill — no fragile hardcoding. Purely additive: plain text still works.

   Suggested usage (Codex, in admin.js, no contract change):
     `<span class="badge badge--${item.state}">${labelForState(item)}</span>`
     `<span class="badge badge--policy">${item.policyCode}</span>`
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-body);
  white-space: nowrap;
}

/* State colours — keyed on the six backend states (unchanged contract). */
.badge--delivered          { color: var(--ok);     border-color: rgba(127, 224, 176, 0.35); background: rgba(127, 224, 176, 0.10); }
.badge--delivery_pending   { color: var(--warn);   border-color: rgba(255, 212, 135, 0.35); background: rgba(255, 212, 135, 0.10); }
.badge--pending            { color: var(--warn);   border-color: rgba(255, 212, 135, 0.30); background: rgba(255, 212, 135, 0.08); }
.badge--processing         { color: var(--accent); border-color: rgba(111, 210, 255, 0.30); background: rgba(111, 210, 255, 0.08); }
.badge--awaiting_recipient { color: var(--accent-soft); border-color: rgba(155, 224, 255, 0.30); background: rgba(155, 224, 255, 0.07); }
.badge--blocked            { color: var(--danger); border-color: rgba(255, 155, 145, 0.35); background: var(--danger-bg); }
.badge--license-active     { color: var(--ok);     border-color: rgba(127, 224, 176, 0.35); background: rgba(127, 224, 176, 0.10); }
.badge--license-suspended  { color: var(--warn);   border-color: rgba(255, 212, 135, 0.35); background: rgba(255, 212, 135, 0.10); }
.badge--license-revoked    { color: var(--danger); border-color: rgba(255, 155, 145, 0.35); background: var(--danger-bg); }

/* Policy pill — one accent style; the 4 Navis slugs share it, so a new slug from
   the backend needs no CSS change (rule: no fragile per-slug hardcoding). */
.badge--policy {
  color: var(--accent-soft);
  border-color: rgba(111, 210, 255, 0.28);
  background: rgba(111, 210, 255, 0.06);
}

/* ---- Responsive (desktop / tablet) --------------------------------------- */

@media (max-width: 720px) {
  body { padding: 24px 14px 56px; }
  .card { padding: 20px 18px; }
  .hero,
  .login-screen {
    grid-template-columns: 1fr;
  }
  .panel-nav,
  .filters {
    grid-template-columns: 1fr;
    border-radius: var(--radius);
  }
  .section-head {
    display: block;
  }
  .product-picker {
    min-width: 0;
    margin-top: 16px;
  }
  thead th, tbody td { padding: 10px 11px; }
}
