:root {
    --brand: #3b82f6;
    --brand-dark: #2563eb;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f5f7fb;
    --card: #ffffff;
    --danger: #ef4444;
    --ok: #16a34a;
}

* { box-sizing: border-box; }

body.login-body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 100%);
    font-family: "PingFang SC", "Noto Sans SC", sans-serif;
    color: var(--ink);
}

.login-card {
    width: 380px;
    background: var(--card);
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.brand {
    font-family: "Snell Roundhand", "Segoe Script", cursive;
    color: var(--brand);
    font-size: 32px;
    margin: 0 0 8px;
    text-align: center;
}

.login-card h1 {
    margin: 0 0 24px;
    font-size: 18px;
    text-align: center;
    font-weight: 600;
}

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: #fef2f2; color: #b91c1c; }
.alert-ok { background: #f0fdf4; color: #166534; }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.field textarea { min-height: 140px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    background: var(--brand);
    color: #fff;
}
.btn:hover { background: var(--brand-dark); }
.btn-ghost { background: #eef2ff; color: var(--brand-dark); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-block { width: 100%; padding: 12px; font-weight: 600; }

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px 1fr;
    background: var(--bg);
    font-family: "PingFang SC", "Noto Sans SC", sans-serif;
    color: var(--ink);
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar .brand {
    text-align: left;
    font-size: 28px;
    margin: 0 4px 8px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 24px;
}

.sidebar nav a {
    display: block;
    text-decoration: none;
    color: var(--ink);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: #eff6ff;
    color: var(--brand-dark);
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
.topbar h2 { margin: 0; font-size: 16px; }
.user-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

.content { padding: 24px; min-width: 0; }
.card {
    background: var(--card);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
td.actions { white-space: nowrap; }

.row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}
.row-actions form {
    display: inline-flex;
    margin: 0;
}

.thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
    background: #e2e8f0;
}
.thumb-lg { width: 120px; height: 80px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-vip { background: #fee2e2; color: #dc2626; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #f1f5f9; color: #64748b; }
.badge-warn { background: #fef3c7; color: #b45309; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 28px; }
.errors { color: #b91c1c; font-size: 13px; margin-bottom: 12px; }
.preview { margin-top: 8px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
    min-width: 0;
}
.kpi {
    background: var(--card);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.kpi-label { margin: 0; font-size: 13px; color: var(--muted); }
.kpi-value { margin: 8px 0 4px; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.kpi-sub { margin: 0; font-size: 12px; color: var(--muted); }

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 16px;
    min-width: 0;
}
.dash-grid > .card {
    min-width: 0;
    overflow: hidden;
}
.card-title { margin: 0 0 16px; font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }

.bars {
    display: flex;
    align-items: stretch;
    gap: 6px;
    height: 180px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
}
.bar {
    flex: 1 0 32px;
    min-width: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.bar-count { font-size: 11px; color: var(--muted); }
.bar-fill {
    width: 100%;
    max-width: 28px;
    min-height: 4px;
    border-radius: 8px 8px 4px 4px;
    background: var(--brand);
}
.bar-fill-green { background: #22c55e; }
.bar-label {
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.dist { margin-bottom: 12px; }
.dist-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    margin-bottom: 6px;
}
.dist-track {
    height: 8px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}
.dist-fill {
    height: 100%;
    background: var(--brand);
    border-radius: 999px;
    min-width: 0;
}
.date-filter { margin-bottom: 16px; }
.date-filter .filters { flex-wrap: wrap; }
.date-filter .filters label { font-size: 13px; color: var(--muted); }
.date-filter .filters input[type="date"] { width: auto; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.btn.active-preset { background: var(--brand); color: #fff; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .kpi-grid, .dash-grid { grid-template-columns: 1fr; }
}
