:root {
    --bg: #0a0505;
    --panel: #1a0a0a;
    --card: #1f1111;
    --text: #f5e6e6;
    --muted: #a08080;
    --line: #3a1515;
    --accent: #e63946;
    --accent2: #d62828;
    --accent-glow: #ff4757;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --shadow: 0 20px 60px rgba(230, 57, 70, .2);
    --card-bg: #1f1111;
    --border-glow: rgba(230, 57, 70, 0.3);
    --input-bg: #1a0a0a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: #0a0505;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: 
        radial-gradient(circle at 20% 10%, rgba(204, 0, 0, 0.4), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(139, 0, 0, 0.3), transparent 40%),
        var(--bg);
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    background: rgba(18, 8, 8, 0.95);
    border: 1px solid rgba(204, 0, 0, 0.35);
    border-radius: 28px;
    padding: 34px;
    box-shadow: 0 30px 90px rgba(204, 0, 0, 0.2);
    backdrop-filter: blur(14px);
}

.login-mark, .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-weight: 900;
    box-shadow: 0 0 30px rgba(204, 0, 0, 0.3);
}

.login-card h1 { 
    margin: 18px 0 26px; 
    font-size: 30px;
    color: #fff;
    text-shadow: 0 0 30px rgba(204, 0, 0, 0.3);
}

/* Shell */
.shell { min-height: 100vh; display: flex; background: #0a0505; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a0a0a 0%, #2a1515 100%);
    color: #fff;
    padding: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 2px solid rgba(230, 57, 70, 0.25);
    box-shadow: 4px 0 40px rgba(230, 57, 70, 0.15);
}

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.brand-title { font-weight: 900; font-size: 19px; color: #fff; }
.brand-subtitle { color: #8a6a6a; font-size: 13px; margin-top: 2px; }

.nav { display: grid; gap: 4px; }
.nav a {
    color: #b09090;
    padding: 11px 14px;
    border-radius: 12px;
    transition: .18s ease;
    font-weight: 500;
    font-size: 14px;
}
.nav a:hover { 
    color: #fff; 
    background: rgba(204, 0, 0, 0.15);
    box-shadow: 0 0 20px rgba(204, 0, 0, 0.05);
}
.nav a.active {
    color: #fff;
    background: rgba(204, 0, 0, 0.2);
    border-left: 3px solid var(--accent);
}
.nav a.nav-logout {
    margin-top: 20px;
    border-top: 1px solid rgba(204, 0, 0, 0.15);
    padding-top: 20px;
}
.nav a.nav-logout:hover {
    background: rgba(204, 0, 0, 0.25);
}

/* Content */
.content { 
    flex: 1; 
    padding: 30px; 
    max-width: 1200px; 
    background: #0a0505;
    min-height: 100vh;
}

.topbar { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(204, 0, 0, 0.12);
}

h1 { 
    margin: 0; 
    font-size: 28px; 
    letter-spacing: -.03em;
    color: #fff;
    text-shadow: 0 0 30px rgba(204, 0, 0, 0.1);
}

h2 { 
    margin: 0 0 18px; 
    font-size: 19px; 
    letter-spacing: -.02em;
    color: #dcc0c0;
}

/* Cards */
.card {
    background: linear-gradient(135deg, #1f1111 0%, #2a1515 100%);
    border: 1px solid rgba(230, 57, 70, 0.2);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.card.narrow { max-width: 560px; }

/* Grids */
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: linear-gradient(135deg, #1f1111 0%, #2a1515 100%);
    border: 1px solid rgba(230, 57, 70, 0.25);
    border-radius: 18px;
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 30px rgba(230, 57, 70, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    opacity: 0;
    transition: opacity 0.3s ease;
}
.stat-card:hover {
    border-color: rgba(230, 57, 70, 0.5);
    box-shadow: 0 8px 40px rgba(230, 57, 70, 0.2);
    transform: translateY(-3px);
    background: linear-gradient(135deg, #2a1515 0%, #3a1f1f 100%);
}
.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    font-size: 26px;
    background: linear-gradient(135deg, rgba(230, 57, 70, 0.15), rgba(214, 40, 40, 0.1));
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(230, 57, 70, 0.2);
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(230, 57, 70, 0.1);
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-number {
    font-size: 26px;
    font-weight: 900;
    color: #fff;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

/* Forms */
label { 
    display: block; 
    font-weight: 600; 
    font-size: 13px; 
    margin: 0 0 6px;
    color: #b09090;
}

input[type="text"], 
input[type="password"], 
input[type="url"], 
input[type="date"], 
input[type="email"],
input[type="number"],
input[type="file"] {
    width: 100%;
    border: 1px solid rgba(204, 0, 0, 0.18);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    outline: none;
    background: rgba(0, 0, 0, 0.4);
    color: #e8d4d4;
    transition: all 0.3s ease;
}

input:focus { 
    border-color: var(--accent); 
    box-shadow: 0 0 0 4px rgba(204, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.5);
}

input::placeholder {
    color: #554040;
}

select {
    width: 100%;
    border: 1px solid rgba(204, 0, 0, 0.18);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    outline: none;
    background: rgba(0, 0, 0, 0.4);
    color: #e8d4d4;
    transition: all 0.3s ease;
}
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(204, 0, 0, 0.1);
}
select option {
    background: #120808;
    color: #e8d4d4;
}

/* Buttons */
button, .secondary, .small, .api-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 4px 20px rgba(204, 0, 0, 0.2);
    transition: all 0.3s ease;
}

button:hover, .secondary:hover, .small:hover, .api-link:hover { 
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 6px 30px rgba(204, 0, 0, 0.3);
}

.secondary { 
    background: rgba(204, 0, 0, 0.1);
    color: #d0b0b0;
    box-shadow: none;
}
.secondary:hover {
    background: rgba(204, 0, 0, 0.2);
    color: #fff;
}

.danger { 
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    box-shadow: none;
}
.danger:hover {
    background: rgba(220, 38, 38, 0.35);
    color: #fff;
}

.small { padding: 7px 12px; border-radius: 10px; font-size: 12px; }

.actions { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-top: 18px;
    flex-wrap: wrap;
}

.checkline { 
    display: inline-flex; 
    align-items: center; 
    gap: 10px; 
    margin-top: 14px; 
    color: var(--muted);
    cursor: pointer;
}
.checkline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Alerts */
.alert { 
    padding: 13px 16px; 
    border-radius: 14px; 
    margin: 0 0 18px; 
    font-weight: 600; 
}
.alert.success { 
    color: #86efac; 
    background: rgba(22, 163, 74, 0.12);
    border: 1px solid rgba(22, 163, 74, 0.2);
}
.alert.error { 
    color: #fca5a5; 
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(220, 38, 38, 0.2);
}
.alert.warning { 
    color: #fcd34d; 
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Tables */
.table-wrap { 
    overflow-x: auto; 
    border: 1px solid rgba(204, 0, 0, 0.1);
    border-radius: 16px;
}
table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 700px; 
}
th, td { 
    padding: 12px 14px; 
    text-align: left; 
    border-bottom: 1px solid rgba(204, 0, 0, 0.06); 
    vertical-align: middle; 
}
th { 
    color: var(--muted); 
    font-size: 11px; 
    text-transform: uppercase; 
    letter-spacing: .08em; 
    background: rgba(204, 0, 0, 0.04);
}
tr:last-child td { border-bottom: 0; }
tr:hover td {
    background: rgba(204, 0, 0, 0.03);
}

.right { text-align: right; }
.action-buttons { 
    display: flex; 
    justify-content: flex-end; 
    align-items: center; 
    gap: 6px;
    flex-wrap: wrap;
}
.action-buttons form { display: inline; margin: 0; }

/* Misc */
code, .json-preview { 
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #d0b0b0;
    font-size: 13px;
}

.pill { 
    display: inline-flex; 
    border-radius: 999px; 
    padding: 5px 10px; 
    font-size: 11px; 
    font-weight: 700; 
}
.pill.on { 
    color: #86efac; 
    background: rgba(22, 163, 74, 0.12);
}
.pill.off { 
    color: #fca5a5; 
    background: rgba(220, 38, 38, 0.12);
}
.pill.expired { 
    color: #fbbf24; 
    background: rgba(251, 191, 36, 0.12);
}
.pill.warning { 
    color: #f59e0b; 
    background: rgba(245, 158, 11, 0.12);
    animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

/* Blink Alert */
.blink-alert {
    animation: blink-bg 1.2s ease-in-out infinite;
    padding: 8px 14px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 12px;
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

@keyframes blink-bg {
    0%, 100% { 
        background: rgba(245, 158, 11, 0.15);
        box-shadow: 0 0 10px rgba(245, 158, 11, 0.05);
    }
    50% { 
        background: rgba(245, 158, 11, 0.3);
        box-shadow: 0 0 30px rgba(245, 158, 11, 0.15);
    }
}

.empty { 
    color: var(--muted); 
    padding: 18px; 
    text-align: center; 
    border: 1px dashed rgba(204, 0, 0, 0.12);
    border-radius: 14px; 
}

.preview-box {
    height: 160px;
    border-radius: 16px;
    border: 1px solid rgba(204, 0, 0, 0.12);
    background: #0a0505;
    display: grid;
    place-items: center;
    overflow: hidden;
    margin-bottom: 10px;
}
.preview-box img { max-width: 100%; max-height: 100%; display: block; }
.background-preview img { width: 100%; height: 100%; object-fit: cover; }
.small-empty { margin-bottom: 10px; }

/* Chart style card */
.chart-card {
    background: linear-gradient(135deg, #1f1111 0%, #2a1515 100%);
    border: 1px solid rgba(230, 57, 70, 0.2);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 22px;
    box-shadow: 0 8px 30px rgba(230, 57, 70, 0.1);
}

/* Responsive */
@media (max-width: 900px) {
    .shell { display: block; }
    .sidebar { 
        width: 100%; 
        height: auto; 
        position: static; 
        border-right: none; 
        border-bottom: 1px solid rgba(204, 0, 0, 0.12);
        padding: 16px;
    }
    .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .content { padding: 18px; }
    .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
    .topbar { display: block; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

@media (max-width: 620px) {
    .nav { grid-template-columns: 1fr 1fr; }
    .action-buttons { justify-content: flex-start; flex-wrap: wrap; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 36px; height: 36px; font-size: 18px; }
    .stat-number { font-size: 20px; }
}