:root {
    --ink: #0f1c24;
    --muted: #5b6b75;
    --accent: #0f766e;
    --accent-hover: #0d9488;
    --accent-dark: #115e59;
    --sidebar: #0b1220;
    --sidebar-2: #111827;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --line: #e2e8f0;
    --danger: #dc2626;
    --warn: #d97706;
    --ok: #059669;
    --info: #0284c8;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
    --radius: 12px;
    --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(15, 118, 110, 0.12), transparent 55%),
        radial-gradient(900px 500px at 100% 0%, rgba(2, 132, 200, 0.08), transparent 50%),
        var(--bg);
}
body.has-nav {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
}
a { color: inherit; }

.sidebar {
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #cbd5e1;
    min-height: 100vh;
    padding: 1.25rem 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.35rem 0.55rem 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.brand-mark {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    box-shadow: 0 6px 14px rgba(15, 118, 110, 0.35);
}
.brand strong {
    display: block;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: #f8fafc;
}
.brand span {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.72rem;
    color: #94a3b8;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.panel h2 {
    margin: 0 0 0.55rem;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}
.panel .note { margin-top: 0.65rem; }
.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}
.sidebar a {
    color: #94a3b8;
    text-decoration: none;
    padding: 0.62rem 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.sidebar a:hover { background: rgba(148, 163, 184, 0.1); color: #f1f5f9; }
.sidebar a.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35);
}
.sidebar-foot {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    padding-top: 0.75rem;
}
.sidebar-user {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-bottom: 0.45rem;
    padding: 0 0.55rem;
}
.sidebar-user strong { color: #e2e8f0; }
.sidebar-foot a { font-size: 0.85rem; opacity: 0.9; }

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
    padding: 0.85rem 1rem;
    background: rgba(255,255,255,0.78);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}
.topbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #ecfeff;
    color: var(--accent-dark);
    border: 1px solid #99f6e4;
}
.pill.neutral { background: #f8fafc; color: var(--muted); border-color: var(--line); }
.pill.warn { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.pill.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.pill.danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.main { padding: 1.25rem 1.4rem 2.25rem; min-width: 0; }
.page-head { margin-bottom: 1rem; }
h1 {
    margin: 0 0 0.3rem;
    font-size: 1.55rem;
    letter-spacing: -0.03em;
    font-weight: 750;
}
.sub { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
    margin-bottom: 0.85rem;
    padding: 0.65rem 0.85rem;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
}
.field label {
    display: block;
    font-size: 0.74rem;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
    width: 128px;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    font: inherit;
}
.field input.wide, .field textarea.wide, .field select.wide { width: 220px; }
.field textarea { min-height: 80px; width: 100%; max-width: 480px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid rgba(15, 118, 110, 0.25);
    border-color: var(--accent);
}

button, .btn {
    border: 0;
    padding: 0.55rem 1rem;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.88rem;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: transform 0.12s ease, background 0.12s ease;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button.secondary, .btn.secondary { background: #334155; }
button.secondary:hover, .btn.secondary:hover { background: #475569; }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
button.upload { background: var(--accent-dark); }

.stats {
    margin-bottom: 0.85rem;
    font-size: 0.92rem;
    color: var(--muted);
}
.stats strong { color: var(--accent-dark); }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.15rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.95rem 1rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
}
.card .label {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.card .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ink);
    margin-top: 0.3rem;
    letter-spacing: -0.03em;
}
.card .hint { margin-top: 0.25rem; font-size: 0.75rem; color: var(--muted); }

.progress-wrap {
    display: none;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.progress-wrap.active { display: block; }
.bar { height: 8px; background: #e2e8f0; overflow: hidden; margin-top: 0.45rem; border-radius: 999px; }
.bar > span {
    display: block; height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--info));
    transition: width 0.2s ease;
}

.error {
    display: none;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    color: #991b1b;
}
.error.active { display: block; }
.warn-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid var(--warn);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
}
.ok-box {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-left: 4px solid var(--ok);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.table-wrap {
    background: var(--surface);
    padding: 1rem;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
table.dataTable thead th {
    background: #0f172a !important;
    color: #f8fafc !important;
    white-space: nowrap;
    border: 0 !important;
}
table.dataTable tbody td { font-size: 0.86rem; vertical-align: middle; }
table.dataTable.no-footer { border-bottom: 0 !important; }
.thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.title-cell { max-width: 280px; white-space: normal; }
.row-check { width: 28px; }

pre.log, pre.upload-log, pre.raw-json {
    background: #0b1220;
    color: #a7f3d0;
    padding: 0.9rem;
    max-height: 280px;
    overflow: auto;
    font-size: 0.78rem;
    border-radius: 10px;
    font-family: var(--mono);
}
pre.upload-log { display: none; margin-top: 1rem; }
pre.upload-log.active { display: block; }
details.raw-box {
    margin-top: 1rem;
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}
details.raw-box summary { cursor: pointer; font-weight: 700; color: var(--accent-dark); }
.note { margin-top: 0.75rem; font-size: 0.82rem; color: var(--muted); }

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}
.login-card {
    width: min(420px, 100%);
    background: rgba(255,255,255,0.94);
    padding: 1.75rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}
.login-card h1 { font-size: 1.7rem; }
.login-card .field input { width: 100%; }
.login-card button { width: 100%; margin-top: 0.85rem; padding: 0.7rem 1rem; }
.login-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
    color: var(--accent-dark);
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

code {
    background: #f1f5f9;
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: var(--mono);
}
.badge {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.warn { background: #ffedd5; color: #9a3412; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #f1f5f9; color: #64748b; }
.badge.info { background: #e0f2fe; color: #075985; }

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
    width: min(460px, 100%);
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.modal h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.modal p { margin: 0 0 1rem; color: var(--muted); }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted);
}

@media (max-width: 900px) {
    body.has-nav { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        min-height: auto;
    }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
}
