:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #677489;
    --border: #dce4ef;
    --primary: #1d4ed8;
    --primary-dark: #163ea8;
    --danger: #c62828;
    --success: #0f9d58;
    --sidebar-a: #0f172a;
    --sidebar-b: #172554;
    --shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
    --radius: 20px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #eef3f9, #f8fbff);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
textarea, input, select, button { font: inherit; }

.mobile-topbar {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand-mobile { font-weight: 700; }
.mobile-logout { color: var(--primary); font-weight: 600; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}
.sidebar {
    background: linear-gradient(180deg, var(--sidebar-a), var(--sidebar-b));
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
}
.brand { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.brand-subtitle { color: #c7d2fe; font-size: 14px; line-height: 1.4; }
.nav-menu { display: grid; gap: 10px; }
.nav-link {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    transition: .2s ease;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,0.18); }
.user-box {
    background: rgba(255,255,255,0.10);
    padding: 14px;
    border-radius: 16px;
    display: grid;
    gap: 4px;
}
.user-box span { color: #dbeafe; font-size: 14px; }

.content { padding: 28px; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.page-title { margin: 0; font-size: 30px; }
.page-subtitle { color: var(--muted); margin-top: 6px; }

.grid-cards, .two-column-grid {
    display: grid;
    gap: 18px;
}
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.two-column-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card, .table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card { padding: 20px; }
.stat-number { font-size: 34px; font-weight: 800; margin-top: 8px; }
.muted { color: var(--muted); }
.soft-info { display: grid; align-content: start; }
.space-top { margin-top: 20px; }

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 0;
}
.section-title-row h2 { margin: 0; }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    padding: 11px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
button:hover, .btn:hover { background: var(--primary-dark); }
.btn-light { background: #e8eef8; color: #14213d; }
.btn-light:hover { background: #dbe7f8; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #aa1f1f; }
.btn-sm { padding: 8px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }

.form-group { display: grid; gap: 8px; margin-bottom: 16px; }
label { font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
}
textarea { resize: vertical; min-height: 100px; }
.inline-filters, .search-row {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.search-row { grid-template-columns: minmax(0, 1fr) auto; }

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
}
.alert-success { background: #e3f8eb; color: #166534; }
.alert-error { background: #fde8e8; color: #991b1b; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
th { background: #f8fbff; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.actions-cell { white-space: nowrap; }
.stack-list { display: grid; gap: 10px; }
.mini-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f8fbff;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.login-wrapper {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at top right, #dbeafe, #eff6ff 40%, #f8fafc 70%);
}
.login-card {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 24px;
    padding: 34px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.login-card h1 { margin-top: 0; }
.help-box {
    background: #eef4ff;
    border: 1px solid #c8d8ff;
    color: #183b8c;
    border-radius: 16px;
    padding: 14px;
    margin-top: 20px;
    line-height: 1.5;
}

@media (max-width: 980px) {
    .mobile-topbar { display: flex; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        padding: 16px;
        border-radius: 0 0 22px 22px;
        position: static;
    }
    .content { padding: 18px; }
    .page-title { font-size: 24px; }
}

@media (max-width: 640px) {
    .search-row { grid-template-columns: 1fr; }
    .mini-item, .page-header, .section-title-row { flex-direction: column; align-items: stretch; }
    th, td { padding: 12px; }
}
