:root {
    --bg-primary: #0F1020;
    --bg-secondary: #171830;
    --surface: #1E1F38;
    --surface-2: #262848;
    --divider: #2D2F52;
    --text: #FFFFFF;
    --text-muted: #B8BAD1;
    --text-dim: #7C7E99;
    --brand: #7C5CFF;
    --brand-2: #FF4FA3;
    --error: #FF5C7A;
    --ok: #3DDC97;
    --warning: #FFB547;
}
* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg-primary);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100%;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }

/* Auth screen */
.auth {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
    background: radial-gradient(circle at 20% 20%, #2a1f5a, var(--bg-primary) 60%);
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--surface); border-radius: 24px; padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-card h1 { margin: 12px 0 4px; font-size: 22px; }
.auth-card p.lead { margin: 0 0 18px; color: var(--text-muted); font-size: 13px; }
.auth-card label { display: block; margin: 14px 0 6px; color: var(--text-muted); font-size: 13px; }
.auth-card input {
    width: 100%; padding: 14px 16px; border-radius: 14px;
    background: var(--bg-secondary); border: 1px solid var(--divider);
    color: var(--text); font-size: 15px;
}
.auth-card input:focus { outline: none; border-color: var(--brand); }

button.primary, .btn-primary {
    display: inline-block; width: 100%; margin-top: 18px; padding: 14px 18px;
    background: linear-gradient(45deg, var(--brand), var(--brand-2));
    color: white; border: none; border-radius: 14px;
    font-weight: 700; font-size: 15px; cursor: pointer; text-align: center;
}
.btn-secondary {
    display: inline-block; padding: 10px 14px; border-radius: 10px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--divider); font-size: 13px; cursor: pointer; text-align: center;
}
.btn-danger {
    background: rgba(255,92,122,0.12); border: 1px solid var(--error); color: var(--error);
    padding: 8px 12px; border-radius: 10px; font-size: 12px; cursor: pointer;
}

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 14px; }
.brand-dot {
    width: 36px; height: 36px; border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 6px 20px rgba(124,92,255,0.45);
}
.brand-title { font-weight: 700; }
.brand-sub { color: var(--text-muted); font-size: 12px; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--divider);
    padding: 0 14px 14px;
    display: flex; flex-direction: column;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-btn {
    background: transparent; border: none; color: var(--text-muted);
    text-align: left; padding: 12px 14px; border-radius: 12px;
    font-size: 14px; font-weight: 600; text-decoration: none;
}
.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn.active {
    background: linear-gradient(45deg, rgba(124,92,255,0.25), rgba(255,79,163,0.15));
    color: var(--text);
}
.sidebar-footer { margin-top: auto; padding-top: 14px; }
.user { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; padding-left: 14px; }

.content { flex: 1; padding: 28px; }
header.page-head h2 { margin: 0 0 6px; font-size: 26px; }
header.page-head p { margin: 0 0 18px; color: var(--text-muted); }

/* Cards */
.card {
    background: var(--surface); border-radius: 20px; padding: 22px;
    margin-bottom: 22px; border: 1px solid var(--divider);
}
.card h3 { margin: 0 0 16px; font-size: 16px; }

/* Forms */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row.single { grid-template-columns: 1fr; }
.field label { display: block; margin: 0 0 6px; color: var(--text-muted); font-size: 12px; }
.field input, .field select {
    width: 100%; padding: 12px 14px; border-radius: 12px;
    background: var(--bg-secondary); border: 1px solid var(--divider);
    color: var(--text); font-size: 14px;
}
.field input[type=file] { padding: 8px; }

/* Stats / dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--divider); border-radius: 18px; padding: 18px; }
.stat-card .num { font-size: 28px; font-weight: 800; }
.stat-card .lbl { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border-radius: 18px; overflow: hidden; border: 1px solid var(--divider); display: flex; flex-direction: column; }
.tile .thumb { aspect-ratio: 9/12; background: var(--surface-2) center/cover no-repeat; position: relative; }
.tile .badge { position: absolute; top: 10px; left: 10px; padding: 4px 8px; border-radius: 999px; font-size: 10px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.15); }
.tile .meta { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.tile .meta .title { font-weight: 700; font-size: 14px; }
.tile .meta .sub { color: var(--text-muted); font-size: 12px; }
.tile .actions { display: flex; gap: 8px; padding: 0 12px 12px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 14px; }
.flash-ok { background: rgba(61,220,151,0.12); border: 1px solid var(--ok); color: var(--ok); }
.flash-err { background: rgba(255,92,122,0.12); border: 1px solid var(--error); color: var(--error); }

@media (max-width: 720px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .row { grid-template-columns: 1fr; }
}

/* Native <dialog> element — only style the backdrop, let browser handle positioning */
dialog::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
}
