:root {
    --bg:#0B0B0C;
    --surface:#17171a;
    --surface-2:#1e1e22;
    --border:#2a2a2d;
    --accent:#6878E4;
    --accent-hover:#515EB2;
    --accent-orange:#F66909;
    --text:#f2f2f4;
    --text-dim:#9a9aa0;
    --text-faint:#6b6b70;
    --radius:14px;
    --radius-sm:9px;
}

* { box-sizing:border-box; }

body {
    font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
    background:var(--bg);
    color:var(--text);
    margin:0;
    line-height:1.6;
    font-size:15px;
}

.page {
    max-width:1080px;
    margin:0 auto;
    padding:48px 40px 100px;
}

.page-narrow {
    max-width:640px;
    margin:0 auto;
    padding:48px 32px 100px;
}

.topbar {
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:48px;
    gap:20px;
}

.topbar h1 {
    margin:0;
    font-size:21px;
    font-weight:600;
    letter-spacing:-0.01em;
}

.nav-links {
    display:flex;
    align-items:center;
    gap:28px;
}

.nav-links a {
    color:var(--text-dim);
    text-decoration:none;
    font-size:14px;
    transition:color 0.15s;
}
.nav-links a:hover { color:var(--text); }

a { color:var(--accent); }

.card {
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:32px;
    margin-bottom:28px;
}

.card-title {
    color:var(--accent);
    font-size:12px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:0.06em;
    margin:0 0 20px 0;
}

label {
    display:block;
    margin-top:20px;
    margin-bottom:8px;
    font-size:13.5px;
    color:var(--text-dim);
}
label:first-child { margin-top:0; }

input[type=text], input[type=file], select, textarea {
    width:100%;
    padding:12px 14px;
    border-radius:var(--radius-sm);
    border:1px solid var(--border);
    background:var(--surface-2);
    color:var(--text);
    box-sizing:border-box;
    font-family:inherit;
    font-size:14.5px;
    transition:border-color 0.15s;
}
input[type=text]:focus, select:focus, textarea:focus {
    outline:none;
    border-color:var(--accent);
}
textarea { resize:vertical; min-height:64px; }

.checkbox-row {
    display:flex;
    align-items:center;
    gap:10px;
    margin-top:18px;
}
.checkbox-row label { margin:0; color:var(--text); font-size:14.5px; }
.checkbox-row input[type=checkbox] { width:18px; height:18px; accent-color:var(--accent); }

button, .btn {
    padding:13px 26px;
    border-radius:var(--radius-sm);
    border:none;
    background:var(--accent);
    color:#c5c5c5;
    font-weight:600;
    font-size:14.5px;
    cursor:pointer;
    text-decoration:none;
    display:inline-flex;
    align-items:center;
    gap:8px;
    transition:background 0.15s;
}
button:hover, .btn:hover { background:var(--accent-hover); }

.btn-secondary {
    background:transparent;
    border:1px solid var(--border);
    color:var(--text);
}
.btn-secondary:hover { background:var(--surface-2); border-color:var(--text-dim); }

.hint { color:var(--text-faint); font-size:12.5px; margin-top:10px; }
.error {
    background:rgba(0,0,0,.9);
    border:1px solid rgba(246, 105, 9, 0.3);
    color:#c5c5c5;
    padding:14px 18px;
    border-radius:var(--radius-sm);
    margin-bottom:28px;
    font-size:14px;
}

.empty-state {
    text-align:center;
    padding:80px 20px;
    color:var(--text-dim);
}
.empty-state a { display:inline-block; margin-top:16px; }

/* Loading overlay */
#loading-overlay {
    display:none;
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.9);
    z-index:999;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:20px;
}
.spinner {
    width:44px;
    height:44px;
    border:3px solid var(--border);
    border-top-color:var(--accent);
    border-radius:50%;
    animation:spin 0.8s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }
#loading-overlay p { color:var(--text-dim); font-size:14.5px; }
#loading-overlay .loading-title { color:var(--text); font-size:16px; font-weight:600; }

/* History table — fixed-size thumbnails regardless of the actual creative's
   aspect ratio, so rows stay a consistent height no matter what mix of
   square/portrait/landscape/widescreen creatives are showing. */
.history-table-wrap { overflow-x:auto; }
.history-table { width:100%; border-collapse:collapse; }
.history-table th {
    text-align:left; font-size:11px; font-weight:600; text-transform:uppercase;
    letter-spacing:0.04em; color:var(--text-faint); padding:10px 14px;
    border-bottom:1px solid var(--border);
}
.history-table td {
    padding:10px 14px; border-bottom:1px solid var(--border); vertical-align:middle;
    font-size:13.5px;
}
.history-table tr:hover td { background:rgba(0,0,0,.9); }
.history-thumb-cell { width:64px; }
.history-thumb {
    width:56px; height:56px; border-radius:6px; object-fit:cover;
    display:block; cursor:pointer; border:1px solid var(--border);
}
.history-table .headline-cell { color:var(--text-dim); max-width:260px; overflow:hidden;
    text-overflow:ellipsis; white-space:nowrap; }

/* Dashboard "recent creatives" — a simple fixed-size thumbnail strip, not a
   full gallery (that's what History is for). */
.recent-thumbs { display:flex; flex-wrap:wrap; gap:14px; }
.recent-thumb-item { width:96px; text-decoration:none; }
.recent-thumb-item img {
    width:96px; height:96px; border-radius:var(--radius-sm); object-fit:cover;
    display:block; border:1px solid var(--border);
}
.recent-thumb-item .recent-thumb-brand {
    display:block; margin-top:6px; font-size:11px; color:var(--text-faint);
    text-align:center; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

.history-item-meta { padding:14px 16px; }
.history-item-meta .brand-tag {
    display:inline-block;
    font-size:11px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:0.04em;
    color:var(--accent);
    margin-bottom:6px;
}
.history-item-meta .who-when { color:var(--text-faint); font-size:12.5px; }

/* ===== App shell with sidebar ===== */
.app-shell {
    display:flex;
    min-height:100vh;
}
.sidebar {
    width:220px;
    flex-shrink:0;
    background:var(--surface);
    border-right:1px solid var(--border);
    display:flex;
    flex-direction:column;
    padding:28px 20px;
    position:sticky;
    top:0;
    height:100vh;
}
.sidebar-logo {
    font-weight:700;
    font-size:17px;
    letter-spacing:-0.01em;
    margin-bottom:36px;
    padding:0 8px;
}
.sidebar-nav {
    display:flex;
    flex-direction:column;
    gap:2px;
    flex:1;
}
.sidebar-nav a {
    color:var(--text-dim);
    text-decoration:none;
    padding:10px 12px;
    border-radius:var(--radius-sm);
    font-size:14.5px;
    font-weight:500;
    transition:background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background:var(--surface-2); color:var(--text); }
.sidebar-nav a.active { background:var(--accent); color:#c5c5c5; }
.sidebar-footer {
    border-top:1px solid var(--border);
    padding-top:16px;
    margin-top:16px;
}
.sidebar-username {
    font-size:13px;
    color:var(--text-dim);
    padding:0 8px 12px;
}
.content {
    flex:1;
    min-width:0;
    padding:44px 48px 100px;
}
.content-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:8px;
}
.content-header h1 { margin:0; font-size:22px; font-weight:600; }
.content-subtitle { color:var(--text-dim); margin:6px 0 36px; font-size:15px; }

/* ===== Stat cards (admin overview) ===== */
.stat-grid {
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(150px, 1fr));
    gap:16px;
    margin-bottom:32px;
}
.stat-card {
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:20px 22px;
}
.stat-card .stat-value { font-size:26px; font-weight:700; }
.stat-card .stat-label { color:var(--text-dim); font-size:12.5px; margin-top:4px; }

/* ===== Tables (admin users, reports) ===== */
table.data-table { width:100%; border-collapse:collapse; font-size:14px; }
table.data-table th {
    text-align:left; color:var(--text-dim); font-weight:500; font-size:12.5px;
    text-transform:uppercase; letter-spacing:0.04em; padding:10px 14px; border-bottom:1px solid var(--border);
}
table.data-table td { padding:12px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
table.data-table tr:last-child td { border-bottom:none; }
table.data-table .tag {
    display:inline-block; background:var(--surface-2); border-radius:5px; padding:2px 8px;
    font-size:12px; color:var(--text-dim);
}
.action-links { display:flex; gap:14px; }
.action-links a, .action-links button {
    background:none; border:none; padding:0; color:var(--accent); font-size:13px;
    cursor:pointer; text-decoration:none; font-family:inherit;
}
.action-links .danger { color:var(--accent-orange); }

/* ===== History filter bar ===== */
.filter-bar {
    display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end;
    background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
    padding:20px 24px; margin-bottom:28px;
}
.filter-field { flex:1; min-width:140px; }
.filter-field label { margin:0 0 6px 0; }
.filter-actions { display:flex; gap:10px; }

/* ===== Pagination ===== */
.pagination { display:flex; gap:8px; align-items:center; margin-top:32px; }
.pagination a, .pagination span {
    padding:8px 13px; border-radius:var(--radius-sm); font-size:13.5px; text-decoration:none;
    color:var(--text-dim); border:1px solid var(--border);
}
.pagination a:hover { background:var(--surface-2); color:var(--text); }
.pagination .current { background:var(--accent); color:#c5c5c5; border-color:var(--accent); }

/* ===== Lightbox modal ===== */
.lightbox-overlay {
    display:none; position:fixed; inset:0; background:rgba(0,0,0,.9); z-index:1000;
    align-items:center; justify-content:center; padding:40px; flex-direction:column;
}
.lightbox-overlay.open { display:flex; }
.lightbox-overlay img { max-width:90vw; max-height:78vh; border-radius:8px; }
.lightbox-meta { color:var(--text-dim); margin-top:16px; font-size:13.5px; text-align:center; }
.lightbox-actions { margin-top:16px; display:flex; gap:12px; }
.lightbox-close {
    position:absolute; top:24px; right:32px; background:none; border:none; color:#c5c5c5;
    font-size:28px; cursor:pointer; line-height:1;
}

/* ===== Forms in cards, admin user form ===== */
.checkbox-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(120px, 1fr)); gap:8px; margin-top:10px; }
.checkbox-grid label { margin:0; display:flex; align-items:center; gap:6px; font-size:14px; color:var(--text); }

