/* ==========================================================================
   SportTickets Link Manager — "floodlit console"
   A dark operations surface for a tool that stays open all day. One signal
   colour (sodium-vapour amber) marks what is live; everything else stays
   quiet so 40 rows can be scanned at a glance.
   ========================================================================== */

:root {
    --bg:          #101216;
    --surface:     #181b21;
    --surface-2:   #1f232b;
    --surface-3:   #272c35;
    --line:        #2a2f39;
    --line-soft:   #21252d;

    --text:        #e7e9ec;
    --text-dim:    #99a1ae;
    --text-faint:  #6b7381;

    /* The only saturated colour in the system: live things, primary actions. */
    --signal:      #f5b23d;
    --signal-ink:  #1a1307;
    --signal-wash: rgba(245, 178, 61, 0.12);
    --signal-edge: rgba(245, 178, 61, 0.35);

    --danger:      #e26d63;
    --danger-wash: rgba(226, 109, 99, 0.12);
    --ok:          #64c98a;
    --ok-wash:     rgba(100, 201, 138, 0.12);

    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --radius: 8px;
    --radius-sm: 5px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

a { color: var(--signal); }

/* Wider than a reading measure on purpose: this is a dense operations
   table, and the row actions have to stay reachable without scrolling. */
.container { max-width: 1440px; margin: 0 auto; padding: 0 24px; }

/* Keyboard users must always be able to see where they are. */
:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 2px;
    border-radius: 3px;
}

/* --------------------------------------------------------------- masthead */

header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

/* The floodlight: a hairline of signal colour under the masthead. */
header::after {
    content: "";
    display: block;
    height: 2px;
    background: linear-gradient(90deg, var(--signal) 0%, rgba(245, 178, 61, 0) 62%);
}

header .container {
    display: flex;
    align-items: center;
    gap: 28px;
    height: 56px;
}

.brand {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
}
.brand a { color: var(--text); text-decoration: none; }
.brand span { color: var(--text-faint); font-weight: 500; }

header nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }

header nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 11px;
    border-radius: var(--radius-sm);
}
header nav a:hover { color: var(--text); background: var(--surface-2); }

.nav-user {
    color: var(--text-faint);
    font-size: 12px;
    font-family: var(--font-mono);
    padding-left: 14px;
    margin-left: 8px;
    border-left: 1px solid var(--line);
}

.btn-link {
    background: none;
    border: 0;
    color: var(--text-dim);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 11px;
    border-radius: var(--radius-sm);
}
.btn-link:hover { color: var(--text); background: var(--surface-2); }

main { padding: 28px 0 64px; }

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

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-head .spacer { margin-left: auto; }

h2 {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.015em;
}

h3 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 12px;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
}
.eyebrow b { color: var(--text-dim); font-weight: 600; }

/* ------------------------------------------------------------------ flash */

.flash {
    max-width: 1440px;
    margin: 18px auto 0;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--ok-wash);
    color: var(--ok);
    border: 1px solid rgba(100, 201, 138, 0.25);
}
.flash-error {
    background: var(--danger-wash);
    color: var(--danger);
    border-color: rgba(226, 109, 99, 0.28);
}

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

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

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

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }

/* The gate rail — the signature. A lit edge means the link is answering
   requests; unlit means it is closed. It is the fastest read on the page. */
tbody td:first-child {
    border-left: 3px solid var(--line);
    padding-left: 12px;
}
tbody tr.is-live td:first-child {
    border-left-color: var(--signal);
}
tbody tr.is-closed { color: var(--text-dim); }
tbody tr.is-closed .cell-name { color: var(--text-dim); }

/* Names run long ("Order No. 287995780 - Longside Lower 29 - iOS"). Keeping
   every row one line high is what makes a 40-row table scannable; the full
   value stays available on hover. */
.cell-name {
    font-weight: 600;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-name em { color: var(--text-faint); font-style: normal; font-family: var(--font-mono); }

.code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--signal);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.code:hover { text-decoration: underline; }

.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--text-faint); }
.nowrap { white-space: nowrap; }

.actions { white-space: nowrap; text-align: right; }
.actions > * { margin-left: 4px; }

.col-check { width: 34px; }
input[type="checkbox"] {
    width: 15px; height: 15px; cursor: pointer;
    accent-color: var(--signal);
}

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text-dim);
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--surface-3); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.btn-primary {
    background: var(--signal);
    color: var(--signal-ink);
    border-color: var(--signal);
    font-weight: 600;
}
.btn-primary:hover { background: #ffc453; border-color: #ffc453; color: var(--signal-ink); }

.btn-warning:hover { background: var(--signal-wash); color: var(--signal); border-color: var(--signal-edge); }
.btn-danger:hover  { background: var(--danger-wash); color: var(--danger); border-color: rgba(226,109,99,.4); }
.btn-ok:hover      { background: var(--ok-wash); color: var(--ok); border-color: rgba(100,201,138,.4); }

.is-copied { color: var(--ok); border-color: rgba(100, 201, 138, 0.4); }

/* ----------------------------------------------------------------- status */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.pill::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
}
.pill-live    { color: var(--signal); background: var(--signal-wash); border-color: var(--signal-edge); }
.pill-closed  { color: var(--text-faint); background: var(--surface-2); border-color: var(--line); }
.pill-danger  { color: var(--danger); background: var(--danger-wash); border-color: rgba(226,109,99,.3); }
.pill-plain   { color: var(--text-dim); background: var(--surface-2); border-color: var(--line); }
.pill-plain::before, .pill-flat::before { display: none; }
.pill-flat    { color: var(--text-dim); background: var(--surface-2); border-color: var(--line); }

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

.form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 620px;
}
.form-inline {
    max-width: none;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.form-inline .form-group { margin-bottom: 0; flex: 1 1 200px; }
.form-inline button { flex: 0 0 auto; }

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 6px;
}
.form-group .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; text-transform: none; letter-spacing: 0; }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}
.form-group textarea { font-family: var(--font-mono); font-size: 13px; resize: vertical; }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-faint); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--signal);
    box-shadow: 0 0 0 3px var(--signal-wash);
}
.form-group input:disabled { opacity: 0.45; }

.form-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
}

/* ------------------------------------------------------------------- auth */

.auth {
    max-width: 380px;
    margin: 8vh auto 0;
}
.auth .brand-lockup {
    text-align: center;
    margin-bottom: 24px;
}
.auth .brand-lockup .mark {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text);
}
.auth .brand-lockup .sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.auth .form { max-width: none; }
.auth button { width: 100%; }

/* ------------------------------------------------------------------ stats */

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.metric .label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 8px;
}
.metric .value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.metric .value.sm { font-size: 15px; font-weight: 500; }
.metric .value a { text-decoration: none; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}

/* Distribution rows: label, count, and a bar sharing one baseline. */
.dist { display: grid; gap: 7px; }
.dist-row {
    display: grid;
    grid-template-columns: 1fr auto 96px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.dist-row .k { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-row .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }
.track { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
/* display:block matters — as an inline span the bar would collapse and only
   the empty track would show. */
.track .bar { display: block; height: 100%; background: var(--signal); border-radius: 2px; min-width: 2px; }

.json-display {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
}

/* --------------------------------------------------------------- key grant
   Shown once, immediately after a key is minted. Loud on purpose: this is the
   only moment the secret exists in readable form. */

.grant {
    border: 1px solid var(--signal-edge);
    background: var(--signal-wash);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 22px;
}
.grant .label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--signal);
    margin-bottom: 10px;
}
.grant .secret {
    display: block;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
    margin-bottom: 10px;
}
.grant p { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.grant p:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------- bulk actions */

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    margin-bottom: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--signal);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.bulk-bar .count { font-family: var(--font-mono); color: var(--text); margin-right: auto; }

/* -------------------------------------------------------------- utilities */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    font-size: 13px;
}
.page-info { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }

.empty {
    text-align: center;
    padding: 72px 24px;
    color: var(--text-faint);
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; font-weight: 600; }

.stack > * + * { margin-top: 22px; }

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

@media (max-width: 900px) {
    .container { padding: 0 16px; }
    header .container { gap: 12px; height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
    header nav { margin-left: 0; width: 100%; overflow-x: auto; }
    .nav-user { border-left: 0; padding-left: 0; margin-left: auto; }

    /* The table is the densest thing here; let it scroll rather than crush. */
    .panel { overflow-x: auto; }
    table { min-width: 760px; }

    .truncate { max-width: 160px; }
    .dist-row { grid-template-columns: 1fr auto 60px; }
}

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