/*
  Admin panel styles.

  A tool used all day: dense enough to see many rows at once, but calm enough to read for hours.
  Light theme only, deliberately - the previous version followed prefers-color-scheme and flipped
  to dark on most machines, which made the panel look inconsistent from one desk to the next.

  The palette is a single blue accent against warm greys. Colour is reserved for meaning (status,
  destructive actions), never decoration, so a red badge always means something is wrong.
*/

:root {
    color-scheme: light;

    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #eff4ff;
    --accent-ring: rgba(37, 99, 235, .18);

    --ink: #111827;
    --ink-soft: #374151;
    --ink-muted: #6b7280;
    --ink-faint: #9ca3af;

    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --surface: #ffffff;
    --surface-alt: #f9fafb;
    --ground: #f3f4f6;

    --sidebar: #111827;
    --sidebar-ink: #9ca3af;
    --sidebar-ink-bright: #f9fafb;
    --sidebar-line: #1f2937;

    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --warning: #a16207;
    --warning-soft: #fffbeb;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --info-soft: #eff6ff;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 10px 24px rgba(16, 24, 40, .08), 0 2px 6px rgba(16, 24, 40, .04);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--ground);
    -webkit-font-smoothing: antialiased;
}

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

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

/* ---- Sign-in and error pages ---------------------------------------------------------------- */

body.bare {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--ground);
}

.bare-panel {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}

.bare-panel h1 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.01em;
}

/* ---- Shell ---------------------------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    padding: 20px 12px 32px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.logo {
    display: block;
    color: var(--sidebar-ink-bright);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.01em;
    padding: 4px 12px 18px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--sidebar-line);
}

.logo:hover { text-decoration: none; }

.nav-heading {
    margin: 20px 0 6px;
    padding: 0 12px;
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #6b7280;
}

.nav-item {
    display: block;
    padding: 7px 12px;
    border-radius: 6px;
    color: var(--sidebar-ink);
    font-size: 13.5px;
    line-height: 1.4;
    transition: background .12s ease, color .12s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: var(--sidebar-ink-bright);
    text-decoration: none;
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
    font-weight: 550;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--ink);
}

.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-muted); }
.topbar-user form { margin: 0; }

.content { padding: 28px; max-width: 1440px; width: 100%; }

@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; padding-bottom: 16px; }
    .content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
}

/* ---- Panels and headings -------------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 650;
    letter-spacing: -.005em;
}

.page-header,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-header h1,
.section-head h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -.02em;
    color: var(--ink);
}

.section-head .button { flex: none; }

/* ---- Tables --------------------------------------------------------------------------------- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: auto;
    box-shadow: var(--shadow-sm);
}

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

/* Not inside .table-wrap so a bare <table> still reads correctly. */
th, td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-muted);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-alt); }

td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; margin: 0; }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }

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

.field { margin-bottom: 16px; }

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 8px 11px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: #9ca3af; }

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

/* Checkboxes sit inline with their label rather than stretching across the row. */
.field input[type="checkbox"],
.field input[type="radio"] { width: auto; margin-right: 8px; vertical-align: middle; }

.field label input[type="checkbox"] { margin-top: -2px; }

.field-hint { display: block; margin-top: 5px; font-size: 12px; color: var(--ink-muted); }
.field-error { display: block; margin-top: 5px; font-size: 12px; color: var(--danger); }

.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 200px; margin-bottom: 16px; }

.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.filters input,
.filters select {
    padding: 7px 11px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
}

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

.filters input[type="search"] { min-width: 240px; }
.filters label { font-size: 13px; color: var(--ink-muted); }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; }
.inline { display: inline; }

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 15px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 550;
    line-height: 1.3;
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.button:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; }
.button:active { box-shadow: none; }

.button-quiet {
    color: var(--ink-soft);
    background: var(--surface);
    border-color: var(--line-strong);
}

.button-quiet:hover { background: var(--surface-alt); border-color: #9ca3af; color: var(--ink); }

.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-danger:hover { background: #991b1b; border-color: #991b1b; }

.button-small { padding: 5px 10px; font-size: 12.5px; }

.button[disabled], .button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ---- Alerts and badges ---------------------------------------------------------------------- */

.alert {
    padding: 11px 15px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 18px;
    font-size: 13.5px;
}

.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #713f12; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: .01em;
    background: var(--ground);
    border: 1px solid var(--line-strong);
    color: var(--ink-muted);
    white-space: nowrap;
}

.badge-success { background: var(--success-soft); border-color: #bbf7d0; color: var(--success); }
.badge-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.badge-warning { background: var(--warning-soft); border-color: #fde68a; color: var(--warning); }
.badge-info { background: var(--info-soft); border-color: #bfdbfe; color: var(--accent-dark); }

/* ---- Dashboard ------------------------------------------------------------------------------ */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.stat strong {
    display: block;
    font-size: 26px;
    font-weight: 650;
    letter-spacing: -.02em;
    line-height: 1.2;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.stat span {
    display: block;
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--ink-muted);
}

.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.attention-list { list-style: none; margin: 0; padding: 0; }

.attention-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}

.attention-list li:last-child { border-bottom: 0; }
.attention-list a { font-weight: 550; }

/* ---- Utilities ------------------------------------------------------------------------------ */

.muted { color: var(--ink-muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.numeric { font-variant-numeric: tabular-nums; }

code, .mono { font-family: var(--font-mono); font-size: 12.5px; }

.empty {
    padding: 40px 24px;
    text-align: center;
    color: var(--ink-muted);
    background: var(--surface);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
}

.pager { display: flex; gap: 8px; align-items: center; margin-top: 18px; font-size: 13px; }

.thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface-alt);
    display: block;
}

.progress {
    height: 6px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
    min-width: 90px;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
}
