:root {
    --bg: #eef3f6;
    --panel: #ffffff;
    --ink: #13233a;
    --muted: #5b6b7c;
    --line: #d5dee7;
    --navy: #16324f;
    --teal: #0f766e;
    --teal-soft: #d1f0ec;
    --amber: #b45309;
    --amber-soft: #fff4e5;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --ok: #166534;
    --ok-soft: #dcfce7;
    --shadow: 0 10px 30px rgba(19, 35, 58, 0.08);
    --radius: 14px;
    --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 28%),
        linear-gradient(180deg, #f7fafc 0%, var(--bg) 100%);
    min-height: 100vh;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    background: #e8eef3;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #0f2438 0%, var(--navy) 100%);
    color: #e8eef5;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: #9db0c4; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--teal); color: #fff; font-weight: 700;
}
.nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.nav a {
    color: #d7e2ee;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    text-decoration: none;
}
.nav a:hover, .nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}
.sidebar-foot {
    font-size: 0.85rem;
    color: #9db0c4;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 1rem;
}
.main { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 2rem; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.topbar h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.02em; }
.nav-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
}
.content { display: flex; flex-direction: column; gap: 1.25rem; }

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    border: 1px solid transparent;
}
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
}
.card h3 {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}
.card .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.03em; }
.card .hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.2rem;
}
.panel h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}
.chart-wrap { position: relative; height: 280px; }

.toolbar {
    display: flex; flex-wrap: wrap; gap: 0.75rem;
    align-items: center; justify-content: space-between;
}
.search-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
input, select, button, textarea {
    font: inherit;
}
input[type="text"], input[type="number"], input[type="password"], input[type="file"], select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    background: #fff;
}
label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.9rem;
}
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.35rem;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
th, td {
    padding: 0.7rem 0.65rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}
th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #f7fafc;
}
tr:hover td { background: #f8fbfd; }
.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    min-width: 1.6rem;
    justify-content: center;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8rem;
}
.badge-A { background: #dcfce7; color: #166534; }
.badge-B { background: #dbeafe; color: #1d4ed8; }
.badge-C { background: #fef3c7; color: #92400e; }
.badge-S { background: #ffedd5; color: #9a3412; }
.badge-W { background: #fee2e2; color: #991b1b; }

.profile-head {
    display: flex; flex-wrap: wrap; gap: 1rem;
    justify-content: space-between; align-items: flex-start;
}
.profile-head h2 { margin: 0 0 0.25rem; }
.muted { color: var(--muted); }
.stats-inline {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
}
.stat-pill {
    background: var(--teal-soft);
    color: #115e59;
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 20% 20%, rgba(15,118,110,.18), transparent 35%),
        radial-gradient(circle at 80% 0%, rgba(22,50,79,.18), transparent 30%),
        #eef3f6;
}
.login-card {
    width: min(420px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 1.75rem;
}
.login-brand { text-align: center; margin-bottom: 1.25rem; }
.login-brand .brand-mark { margin: 0 auto 0.75rem; }
.login-brand h1 { margin: 0; font-size: 1.5rem; }
.login-brand p { margin: 0.35rem 0 0; color: var(--muted); }
.login-hint { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 1rem 0 0; }

.preview-box {
    background: #f8fafc;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 0.9rem 1rem;
}
.preview-box strong { display: block; margin-bottom: 0.35rem; }

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        display: none;
    }
    .sidebar.open { display: flex; }
    .nav-toggle { display: inline-flex; }
    .grid-2 { grid-template-columns: 1fr; }
}
