:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1a1d26;
    --muted: #6b7280;
    --sidebar-bg: #0f1420;
    --sidebar-bg-2: #161c2b;
    --sidebar-text: #9aa3b2;
    --sidebar-active: #f5b301;
    --accent: #e0a80d;
    --accent-dark: #c8940a;
    --accent-soft: #fdf6e3;
    --primary: #d92d20;
    --primary-dark: #b42318;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.10);
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }

.sidebar-toggle-input { display: none; }

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    z-index: 40;
}

.sidebar-brand { padding: 0.5rem 0.75rem 1.5rem; }

.sidebar-eyebrow {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.sidebar-title {
    display: block;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
}
.sidebar-title:hover { text-decoration: none; color: #fff; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.is-active {
    background: linear-gradient(90deg, rgba(245, 179, 1, 0.18), rgba(245, 179, 1, 0.04));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.sidebar-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.sidebar-link.is-active .sidebar-link-icon { color: var(--sidebar-active); }

.sidebar-overlay { display: none; }

/* ---------- Main area ---------- */
.app-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 0.9rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-heading { flex: 1; }

.topbar-eyebrow {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-dark);
    font-weight: 700;
}

.topbar-title { margin: 0; font-size: 1.35rem; font-weight: 700; }

.menu-btn {
    display: none;
    cursor: pointer;
    color: var(--text);
    padding: 0.25rem;
}

.user-menu { display: flex; align-items: center; gap: 1rem; }

.user-meta { text-align: right; line-height: 1.2; }
.user-name { display: block; font-weight: 600; font-size: 0.95rem; }
.user-role { display: block; font-size: 0.78rem; color: var(--muted); }

.content { padding: 1.75rem; flex: 1; }

h2 { margin: 0 0 1rem; font-size: 1.2rem; }
h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(120deg, #fffdf7 0%, #fdf1cf 100%);
    border: 1px solid #f4e4b0;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
}

.hero-eyebrow {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-dark);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.hero-heading { margin: 0 0 0.5rem; font-size: 2rem; font-weight: 800; }
.hero-text { margin: 0; color: #5c5642; max-width: 560px; }

.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1.75rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
    background: var(--accent);
    opacity: 0.8;
}

.card.danger::before { background: var(--danger); }
.card.success::before { background: var(--success); }
.card.warning::before { background: var(--warning); }

.card .label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.card .value { font-size: 1.6rem; font-weight: 800; }

.card.danger .value { color: var(--danger); }
.card.success .value { color: var(--success); }
.card.warning .value { color: var(--warning); }

/* Quick action tiles */
.tiles {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 1.75rem;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s;
}

.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; color: var(--text); }

.tile-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tile-title { font-weight: 700; }
.tile-sub { font-size: 0.82rem; color: var(--muted); }

/* ---------- Panels & tables ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }

th, td { padding: 0.8rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }

th {
    background: #faf9f6;
    font-weight: 700;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tr:hover td { background: #fcfbf8; }

.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 0.88rem; font-weight: 600; }

input, select, textarea {
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(224, 168, 13, 0.15);
}

textarea { min-height: 90px; resize: vertical; }

.search-input { font-size: 1rem; padding: 0.85rem 1rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 0.65rem 1.15rem;
    border-radius: 10px;
    border: none;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-accent { background: var(--accent); color: #1a1d26; }
.btn-accent:hover { background: var(--accent-dark); text-decoration: none; }

.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f3f4f6; text-decoration: none; }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }

/* ---------- Alerts & badges ---------- */
.alert { padding: 0.85rem 1rem; border-radius: 10px; margin-bottom: 1.25rem; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #eef0f3;
    color: #374151;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #0f1420, #232b3d);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 16px;
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
}

.login-card h1 { margin: 0 0 0.25rem; text-align: center; font-size: 1.6rem; }
.login-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }

.footer { padding: 1.5rem 1.75rem; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .app-main { margin-left: 0; }
    .menu-btn { display: inline-flex; }

    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
    .sidebar-toggle-input:checked ~ .sidebar { transform: translateX(0); }
    .sidebar-toggle-input:checked ~ .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 35;
    }

    .hero-heading { font-size: 1.5rem; }
    .content { padding: 1.25rem; }
}
