:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --text: #1a1d24;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #c2410c;       /* admin = warm orange */
    --accent-dark: #9a2f08;
    --accent-soft: #fff1ea;
    --ok-bg: #d1fae5;
    --ok-fg: #065f46;
    --miss-bg: #fee2e2;
    --miss-fg: #991b1b;
    --tag-bg: #f1f5f9;
    --tag-fg: #334155;
    --radius: 8px;
}
* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg); color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.numeric { font-variant-numeric: tabular-nums; text-align: right; }

/* Header */
.admin-header {
    background: #1a1d24; color: #fff;
    border-bottom: 3px solid var(--accent);
    position: sticky; top: 0; z-index: 10;
}
.admin-header .container {
    display: flex; align-items: center; justify-content: space-between;
    height: 54px;
}
.admin-header .brand {
    color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -.01em;
}
.admin-header .nav a {
    color: #d1d5db; margin-left: 16px; font-weight: 500; font-size: 14px;
}
.admin-header .nav a:hover { color: #fff; text-decoration: none; }
.admin-header .nav a.logout { color: var(--accent); }

/* Buttons */
.btn {
    display: inline-block; padding: 10px 18px;
    border-radius: var(--radius);
    font-weight: 600; border: 1px solid transparent; cursor: pointer;
    font-size: 14px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-small { padding: 6px 12px; font-size: 13px; background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #fdba74; }
.btn-small:hover { background: #ffe1d1; text-decoration: none; }

/* Login */
.login-body { background: linear-gradient(135deg, #1a1d24 0%, #2c2f3a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-main { width: 100%; max-width: 380px; padding: 0 24px; }
.login-form {
    background: #fff; border-radius: 12px; padding: 28px;
    box-shadow: 0 12px 32px rgba(0,0,0,.3);
    display: flex; flex-direction: column; gap: 16px;
}
.login-form h1 { margin: 0 0 4px; font-size: 22px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.login-form input {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 12px; font-size: 15px;
}
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-error {
    background: var(--miss-bg); color: var(--miss-fg);
    padding: 8px 12px; border-radius: var(--radius); font-size: 14px; margin: 0;
}

/* Page head */
.page-head { padding: 28px 0 16px; }
.page-head h1 { margin: 6px 0 4px; font-size: 24px; }

/* Table */
.admin-table {
    width: 100%; background: var(--panel);
    border-radius: var(--radius); overflow: hidden;
    border-collapse: collapse;
    border: 1px solid var(--border);
}
.admin-table th, .admin-table td {
    padding: 10px 14px; text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table thead th {
    background: #fafbfc; font-size: 12px;
    text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #fafbfc; }
.thumb-cell { width: 140px; }
.thumb-cell img {
    width: 120px; height: 68px; object-fit: cover;
    border-radius: 6px; display: block;
    background: #e5e7eb;
}
.thumb-placeholder { width: 120px; height: 68px; background: #e5e7eb; border-radius: 6px; }
.row-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.row-actions { text-align: right; white-space: nowrap; }

/* Status flags */
.status-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flag {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 999px;
    text-transform: lowercase;
}
.flag.ok    { background: var(--ok-bg);   color: var(--ok-fg); }
.flag.missing { background: var(--miss-bg); color: var(--miss-fg); }

.badge {
    background: var(--accent-soft); color: var(--accent-dark);
    padding: 1px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    margin-top: 4px; display: inline-block;
    text-transform: lowercase;
}

/* Set-thumbnail page */
.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.thumb-tile {
    margin: 0; padding: 0;
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .12s, transform .12s;
}
.thumb-tile.is-default {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.thumb-btn {
    background: none; border: none; padding: 0; margin: 0;
    width: 100%; display: block; cursor: pointer;
    text-align: left;
}
.thumb-btn img {
    width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block;
    background: #e5e7eb;
}
.thumb-btn:hover img { opacity: .9; }
.thumb-tile-meta {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; font-size: 13px;
}
.thumb-tile-meta strong { font-weight: 600; }
.thumb-default-badge {
    background: var(--accent); color: #fff;
    padding: 2px 8px; border-radius: 999px;
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
}

/* File-list cells (audio + subtitles) */
.file-list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex; flex-direction: column;
    gap: 4px;
    font-size: 13px;
}
.file-list li {
    display: flex; align-items: center; gap: 8px;
    white-space: nowrap;
}
.file-list a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 13px; font-weight: 700;
    text-decoration: none;
}
.file-list a:hover { background: #ffe1d1; }
.file-meta { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 56px; }

.subs-details summary {
    cursor: pointer;
    font-weight: 600;
    padding: 2px 0;
    font-size: 13px;
}
.subs-details[open] summary { margin-bottom: 6px; }
.subs-details .file-list { padding-left: 8px; }

/* Flash message */
.flash-ok {
    background: var(--ok-bg); color: var(--ok-fg);
    padding: 10px 14px; border-radius: var(--radius);
    margin-top: 12px; font-size: 14px;
}

.link { color: var(--accent); }
