/*
    Admin panel styling.

    One static file, served by nginx without touching PHP, with no build step
    and no imports: the panel is opened a few times a quarter and has to work
    when it is. Bump the ?v= in templates/admin/base.html.twig after editing,
    otherwise a year-old copy stays in the browser cache.

    Light by default, dark when the system asks. Colours are declared once as
    custom properties; nothing below hardcodes a colour.
*/

/* ------------------------------------------------------------- tokens */

:root {
    color-scheme: light;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-sunken: #f1f5f9;

    --line: #e2e8f0;
    --line-strong: #cbd5e1;

    --text: #0f172a;
    --text-soft: #475569;
    --muted: #64748b;

    --brand: #2563eb;
    --brand-strong: #1d4ed8;
    --brand-soft: #eff6ff;
    --brand-ring: rgb(37 99 235 / 22%);

    --accent: #ea580c;
    --accent-strong: #c2410c;
    --accent-soft: #fff7ed;

    --good: #15803d;
    --good-soft: #f0fdf4;
    --good-line: #bbf7d0;

    --bad: #b91c1c;
    --bad-soft: #fef2f2;
    --bad-line: #fecaca;

    --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
    --shadow: 0 1px 3px rgb(15 23 42 / 8%), 0 1px 2px rgb(15 23 42 / 4%);
    --shadow-lg: 0 18px 40px -22px rgb(15 23 42 / 35%);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    --sidebar: 16.5rem;

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

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #080d19;
        --surface: #101a2e;
        --surface-muted: #0d1626;
        --surface-sunken: #0b1322;

        --line: #1e2b45;
        --line-strong: #334155;

        --text: #e6edf7;
        --text-soft: #c2cede;
        --muted: #8ea0ba;

        --brand: #60a5fa;
        --brand-strong: #93c5fd;
        --brand-soft: rgb(96 165 250 / 14%);
        --brand-ring: rgb(96 165 250 / 30%);

        --accent: #fb923c;
        --accent-strong: #fdba74;
        --accent-soft: rgb(251 146 60 / 14%);

        --good: #4ade80;
        --good-soft: rgb(74 222 128 / 10%);
        --good-line: rgb(74 222 128 / 30%);

        --bad: #f87171;
        --bad-soft: rgb(248 113 113 / 10%);
        --bad-line: rgb(248 113 113 / 32%);

        --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
        --shadow: 0 1px 3px rgb(0 0 0 / 45%);
        --shadow-lg: 0 18px 40px -22px rgb(0 0 0 / 70%);
    }
}

/* --------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

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

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

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

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

.muted { color: var(--muted); font-size: .875rem; }
.mono { font-family: var(--mono); font-size: .8125rem; word-break: break-all; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; }
.icon--sm { width: 1rem; height: 1rem; }

/* -------------------------------------------------------------- shell */

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100vh;
}

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

.content {
    width: 100%;
    max-width: 68rem;
    margin: 0 auto;
    padding: 2.25rem 2rem 5rem;
}

/* ------------------------------------------------------------ sidebar */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 1.25rem 1rem;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .35rem .4rem;
    color: var(--text);
}

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

.brand__mark {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--brand) 0%, var(--brand-strong) 55%, var(--accent) 165%);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.brand__mark .icon { width: 1.35rem; height: 1.35rem; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand__text strong { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.brand__text small { color: var(--muted); font-size: .75rem; }

.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav + .nav { margin-top: 1rem; }

.nav__label {
    margin: 0 0 .35rem .65rem;
    color: var(--muted);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.nav__link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .65rem;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: .9rem;
    font-weight: 500;
}

.nav__link:hover {
    background: var(--surface-sunken);
    color: var(--text);
    text-decoration: none;
}

.nav__link .icon { color: var(--muted); transition: color .12s ease; }
.nav__link:hover .icon { color: var(--text-soft); }

.nav__link.is-active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
}

.nav__link.is-active .icon { color: var(--brand); }

.sidebar__foot {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.account {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .65rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    min-width: 0;
}

.account:hover { background: var(--surface-sunken); text-decoration: none; }

.account__avatar {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex: none;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: .8125rem;
    font-weight: 600;
    text-transform: uppercase;
}

.account__text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.account__text strong { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.account__text small { color: var(--muted); font-size: .72rem; }

/* ------------------------------------------------- mobile top bar */

.topbar { display: none; }

.burger {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
}

.scrim { display: none; }

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

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}

.page-head__text { min-width: 0; }
.page-head__text > .muted { margin-top: .3rem; }
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.section-head { margin: 2.25rem 0 .9rem; }
.section-head h2 + .muted { margin-top: .25rem; }

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

.card, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card { padding: 1.1rem 1.25rem; margin-bottom: .75rem; }
.panel { padding: 1.25rem 1.35rem; }
.panel--flush { padding: 0; overflow: hidden; }

.panel__head {
    padding: 1rem 1.35rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
}

.panel__head h2 + .muted { margin-top: .2rem; }
.panel__body { padding: 1.25rem 1.35rem; }

.panel__foot {
    padding: .9rem 1.35rem;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
    color: var(--muted);
    font-size: .8125rem;
}

/* ------------------------------------------------------- application */

.app-card {
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}

.app-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow);
}

.app-card__icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: none;
    border-radius: 10px;
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 1.15rem;
    font-weight: 600;
    text-transform: uppercase;
    overflow: hidden;
}

.app-card__icon img { width: 100%; height: 100%; object-fit: cover; }
.app-card__body { min-width: 0; flex: 1; }

.app-card__title {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}

.app-card__title a { color: var(--text); }
.app-card__title a:hover { color: var(--brand); text-decoration: none; }
.app-card__body .mono { display: block; color: var(--muted); margin-top: .1rem; }
.app-card__body .summary { margin: .45rem 0 0; color: var(--text-soft); font-size: .9rem; }
.app-card__go { align-self: center; color: var(--line-strong); }
.app-card:hover .app-card__go { color: var(--brand); }

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

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: .75rem;
    margin-bottom: 1.75rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat__icon {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    flex: none;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
}

.stat--accent .stat__icon { background: var(--accent-soft); color: var(--accent); }
.stat--good .stat__icon { background: var(--good-soft); color: var(--good); }
.stat__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.stat__value { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.stat__label { color: var(--muted); font-size: .78rem; }

/* ------------------------------------------------------------ badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .18rem .5rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: .375rem;
    height: .375rem;
    border-radius: 50%;
    background: currentColor;
    opacity: .75;
}

.badge.live { background: var(--good-soft); border-color: var(--good-line); color: var(--good); }
.badge.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.badge--plain::before { display: none; }

/* ------------------------------------------------------------ flashes */

.flash {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .8rem 1rem;
    margin: 0 0 .6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-soft);
    font-size: .9rem;
    box-shadow: var(--shadow-sm);
}

.flash .icon { margin-top: .1rem; }
.flash.success { background: var(--good-soft); border-color: var(--good-line); color: var(--good); }
.flash.error { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.flashes { margin-bottom: 1.25rem; }
.flashes:empty { display: none; }

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

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .5rem .95rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font: 500 .875rem/1.4 var(--font);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}

button:hover, .btn:hover { background: var(--brand-strong); color: #fff; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }

.btn--accent { background: var(--accent); }
.btn--accent:hover { background: var(--accent-strong); }

button.secondary, .btn--secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--text-soft);
}

button.secondary:hover, .btn--secondary:hover {
    background: var(--surface-sunken);
    border-color: var(--muted);
    color: var(--text);
}

button.danger, .btn--danger {
    background: var(--surface);
    border-color: var(--bad-line);
    color: var(--bad);
}

button.danger:hover, .btn--danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

button.link {
    padding: .2rem .35rem;
    background: none;
    border: 0;
    box-shadow: none;
    color: var(--brand);
    font-weight: 500;
}

button.link:hover { background: var(--brand-soft); color: var(--brand-strong); }
.btn--sm { padding: .32rem .6rem; font-size: .8125rem; }
.btn--block { width: 100%; }

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

.field { margin-bottom: 1.1rem; }
.field:last-of-type { margin-bottom: 0; }

label {
    display: block;
    margin-bottom: .35rem;
    color: var(--text);
    font-size: .875rem;
    font-weight: 500;
}

label .muted { font-weight: 400; }

input[type=text],
input[type=email],
input[type=password],
textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    box-shadow: var(--shadow-sm);
    transition: border-color .12s ease, box-shadow .12s ease;
}

input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}

textarea { min-height: 5.5rem; resize: vertical; }
::placeholder { color: var(--muted); opacity: 1; }

input[type=file] {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--muted);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}

input[type=file]:hover { border-color: var(--brand); background: var(--brand-soft); }

input[type=file]::file-selector-button {
    margin-right: .75rem;
    padding: .35rem .7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-soft);
    font: 500 .8125rem var(--font);
    cursor: pointer;
}

input[type=file]::file-selector-button:hover { background: var(--surface-sunken); }

.form-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: 1.4rem;
}

.field-hint { margin-top: .35rem; color: var(--muted); font-size: .8125rem; }

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

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th, td {
    text-align: left;
    padding: .7rem 1.35rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

thead th {
    background: var(--surface-muted);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-muted); }
td.numeric, th.numeric { font-variant-numeric: tabular-nums; }
td form { margin: 0; }

.panel:not(.panel--flush) th,
.panel:not(.panel--flush) td { padding-left: 0; padding-right: 0; }

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

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }
.empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); }
.empty .icon { width: 2rem; height: 2rem; margin-bottom: .6rem; color: var(--line-strong); }
.empty p { margin-bottom: .9rem; }
.note { margin-top: .85rem; color: var(--muted); font-size: .8125rem; line-height: 1.55; }

.danger-zone { border-color: var(--bad-line); }
.danger-zone .panel__head { background: var(--bad-soft); border-bottom-color: var(--bad-line); }
.danger-zone .panel__head h2 { color: var(--bad); }

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

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background:
        radial-gradient(60rem 30rem at 50% -10%, var(--brand-soft), transparent 70%),
        var(--bg);
}

.auth__box { width: 100%; max-width: 23rem; }

.auth__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth__brand .brand__mark { width: 2.75rem; height: 2.75rem; border-radius: 12px; }
.auth__brand .brand__mark .icon { width: 1.6rem; height: 1.6rem; }
.auth__brand h1 { font-size: 1.35rem; }
.auth .panel { box-shadow: var(--shadow-lg); }
.auth__foot { margin-top: 1.25rem; text-align: center; color: var(--muted); font-size: .78rem; }

/* -------------------------------------------------------- narrow view */

@media (max-width: 60rem) {
    .shell { grid-template-columns: minmax(0, 1fr); }

    .sidebar {
        position: fixed;
        z-index: 30;
        top: 0;
        left: 0;
        width: var(--sidebar);
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: var(--shadow-lg);
    }

    .nav-toggle:checked ~ .shell .sidebar { transform: translateX(0); }

    .nav-toggle:checked ~ .scrim {
        display: block;
        position: fixed;
        z-index: 20;
        inset: 0;
        background: rgb(15 23 42 / 45%);
    }

    .topbar {
        display: flex;
        align-items: center;
        gap: .75rem;
        position: sticky;
        top: 0;
        z-index: 10;
        padding: .7rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
    }

    .content { padding: 1.5rem 1rem 4rem; }
    .page-head { margin-bottom: 1.25rem; }
    h1 { font-size: 1.3rem; }
    th, td { padding-left: 1rem; padding-right: 1rem; }
}

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