/*
 * Rights Manager — internal tool styling.
 *
 * Hand-authored and served directly: no build step, so deploying is "copy the
 * files". The visual priorities come straight from the brief — status must be
 * unmissable, the match report is the strongest thing on screen, and nothing
 * decorative competes with either.
 */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fbfcfd;
    --border: #dfe3e8;
    --border-strong: #c6ccd4;

    --text: #1b2027;
    --text-muted: #5c6673;
    --text-faint: #838d9a;

    --accent: #1f5fd0;
    --accent-hover: #17499f;
    --accent-soft: #e8f0fd;

    --danger: #c1262d;
    --danger-soft: #fdecec;
    --danger-border: #f3bfc1;

    --warn: #9a6205;
    --warn-soft: #fdf3e2;
    --warn-border: #f0d9a8;

    --ok: #1c7346;
    --ok-soft: #e6f5ec;
    --ok-border: #b6dfc7;

    --radius: 6px;
    --shadow: 0 1px 2px rgba(20, 25, 33, 0.06), 0 1px 3px rgba(20, 25, 33, 0.04);

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --surface: #1b1f26;
        --surface-2: #21262e;
        --border: #2e343d;
        --border-strong: #3d444f;

        --text: #e6e9ee;
        --text-muted: #a3acb9;
        --text-faint: #7d8794;

        --accent: #6ea8fe;
        --accent-hover: #8fbcff;
        --accent-soft: #1c2a44;

        --danger: #ff8085;
        --danger-soft: #33191b;
        --danger-border: #5c2b2e;

        --warn: #e8b563;
        --warn-soft: #33280f;
        --warn-border: #5c4720;

        --ok: #6fd39b;
        --ok-soft: #12291d;
        --ok-border: #274d37;

        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.25;
    font-weight: 620;
    letter-spacing: -0.01em;
}

h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ---------------------------------------------------------------- layout */

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

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 52px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 680;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -0.015em;
    white-space: nowrap;
}

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

.brand span {
    color: var(--accent);
}

.nav {
    display: flex;
    gap: 2px;
    flex: 1;
    flex-wrap: wrap;
}

.nav a {
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-weight: 500;
}

.nav a:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.nav a[aria-current="page"] {
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-divider {
    width: 1px;
    background: var(--border);
    margin: 8px 6px;
    align-self: stretch;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.role-tag {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-faint);
    padding: 1px 5px;
    border-radius: 3px;
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

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

.page-head p {
    margin: 4px 0 0;
    color: var(--text-muted);
}

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

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

.card + .card { margin-top: 16px; }

.card-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-body { padding: 16px; }

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ stat */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    color: var(--text-faint);
    font-weight: 650;
}

.stat-value {
    font-size: 26px;
    font-weight: 660;
    letter-spacing: -0.02em;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-value.is-alert { color: var(--danger); }
.stat-value.is-ok { color: var(--ok); }

.stat-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

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

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

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

th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    font-weight: 650;
    padding: 9px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--surface-2); }

.num { font-variant-numeric: tabular-nums; }

.mono {
    font-family: var(--mono);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
}

.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

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

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.badge-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.badge-alert { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.badge-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.badge-busy { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.badge-busy::before { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
    .badge-busy::before { animation: none; }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 560;
    font-size: 13.5px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

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

.btn-sm { padding: 4px 9px; font-size: 12.5px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

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

.field { margin-bottom: 14px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

input:focus, select:focus, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }

.error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }

/* --------------------------------------------------------------- alerts */

.alert {
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 16px;
}

.alert-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.alert-info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.alert strong { font-weight: 680; }

/* ---------------------------------------------------------------- notice */

/*
 * Used wherever the interface has to be explicit about a rule rather than
 * leave the user to infer it — that the original file is gone, or that a
 * counterpart video is visible only because of this match.
 */
.notice {
    display: flex;
    gap: 9px;
    font-size: 12.5px;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    line-height: 1.45;
}

.notice-icon { flex: none; font-weight: 700; color: var(--text-faint); }

/* ------------------------------------------------------------- dropzone */

.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.dropzone:hover, .dropzone.is-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dropzone-title { font-size: 16px; font-weight: 620; margin-bottom: 4px; }
.dropzone-sub { color: var(--text-muted); font-size: 13px; }

.file-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    background: var(--surface-2);
    margin-top: 14px;
}

.file-name { font-weight: 600; word-break: break-all; }
.file-meta { color: var(--text-muted); font-size: 12.5px; }

/* ------------------------------------------------------------- progress */

.progress {
    height: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width 0.3s ease;
}

.progress-bar.is-done { background: var(--ok); }
.progress-bar.is-alert { background: var(--danger); }

/* Upload → Processing → Fingerprinting → Checking matches → Complete */
.stages {
    display: flex;
    gap: 0;
    margin: 16px 0 0;
    list-style: none;
    padding: 0;
    flex-wrap: wrap;
}

.stage {
    flex: 1;
    min-width: 108px;
    font-size: 12px;
    color: var(--text-faint);
    padding: 8px 4px 0;
    border-top: 3px solid var(--border);
    font-weight: 560;
}

.stage.is-active { color: var(--accent); border-top-color: var(--accent); }
.stage.is-done { color: var(--ok); border-top-color: var(--ok); }
.stage.is-failed { color: var(--danger); border-top-color: var(--danger); }

/* ------------------------------------------------------------- timeline */

/*
 * The match timeline. A matched region has to read instantly against the full
 * length of the video, so it is a solid saturated block on a plain track.
 */
.timeline {
    position: relative;
    height: 34px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.timeline-region {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--danger);
    opacity: 0.85;
    border-left: 1px solid var(--danger);
    border-right: 1px solid var(--danger);
    min-width: 2px;
}

.timeline-region.is-possible { background: var(--warn); }

.timeline-region-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
}

.timeline-scale {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- match report */

.match-banner {
    border: 1px solid var(--danger-border);
    background: var(--danger-soft);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.match-banner.is-possible {
    border-color: var(--warn-border);
    border-left-color: var(--warn);
    background: var(--warn-soft);
}

.match-banner-title {
    font-size: 13px;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--danger);
}

.match-banner.is-possible .match-banner-title { color: var(--warn); }

.match-banner-headline {
    font-size: 21px;
    font-weight: 640;
    letter-spacing: -0.015em;
    margin-top: 5px;
    color: var(--text);
}

.match-banner-headline strong { font-variant-numeric: tabular-nums; }

.match-banner-sub {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 13px;
}

.side-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    font-weight: 700;
    color: var(--text-faint);
}

.side-title {
    font-size: 16px;
    font-weight: 620;
    margin-top: 2px;
    word-break: break-word;
}

.side-owner { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.timestamp {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.evidence-strip {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.evidence-strip img {
    height: 74px;
    width: auto;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    flex: none;
}

.evidence-frame { position: relative; flex: none; }

.evidence-time {
    position: absolute;
    bottom: 3px;
    left: 3px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 10px;
    font-family: var(--mono);
    padding: 1px 4px;
    border-radius: 3px;
}

.thumb {
    width: 92px;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: block;
}

.thumb-placeholder {
    width: 92px;
    height: 52px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    font-size: 10.5px;
    text-align: center;
    line-height: 1.2;
}

/* ----------------------------------------------------------- misc bits */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 3px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.filters {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filters .field { margin-bottom: 0; min-width: 150px; }

.pagination-wrap { margin-top: 16px; }

.pagination-wrap nav { display: flex; gap: 12px; align-items: center; }

.secret {
    font-family: var(--mono);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    padding: 6px 10px;
    border-radius: var(--radius);
    display: inline-block;
    user-select: all;
    font-size: 13.5px;
}
