:root {
    --brand: #1f4e79;
    --brand-dark: #163a5c;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #1e2530;
    --muted: #6b7684;
    --error: #c0392b;
    --border: #dde3ea;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.auth-card h1 {
    font-size: 20px;
    margin: 0 0 4px;
    color: var(--brand-dark);
}

.auth-card p.subtitle {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 14px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

button, .btn {
    width: 100%;
    padding: 11px 12px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

button:hover, .btn:hover { background: var(--brand-dark); }

.alert-error {
    background: #fdecea;
    color: var(--error);
    border: 1px solid #f5c6cb;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success {
    background: #eafaf1;
    color: #1e7e34;
    border: 1px solid #c3e6cb;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.helper-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
}

.otp-input {
    letter-spacing: 8px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
}

/* App shell: fixed left sidebar (sections) + top bar + sub-tab row */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 210px;
    flex-shrink: 0;
    background: #14161a;
    padding: 16px 0;
}

.app-sidebar .sidebar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    padding: 0 20px 18px;
}

.app-sidebar nav {
    display: flex;
    flex-direction: column;
}

.app-sidebar a.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #b7bcc4;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.app-sidebar a.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.app-sidebar a.sidebar-link.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-left-color: #4f8ef7;
}

.app-sidebar .sidebar-icon {
    width: 18px;
    text-align: center;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: #eef0f2;
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.app-topbar h1 {
    font-size: 18px;
    margin: 0;
    font-weight: 700;
}

.app-topbar h1 .section-name { font-weight: 400; color: var(--muted); }

.app-topbar .user-info {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text);
}

.app-topbar .user-info a { color: var(--muted); text-decoration: none; }
.app-topbar .user-info a:hover { color: var(--brand); }

.role-badge {
    display: inline-block;
    background: rgba(31,78,121,0.1);
    color: var(--brand-dark);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
}

.app-subtabs {
    display: flex;
    gap: 4px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    overflow-x: auto;
}

.app-subtabs a {
    padding: 12px 14px;
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.app-subtabs a.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

.app-subtabs a:hover { color: var(--brand); }

.app-content {
    padding: 32px 24px;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    .app-shell { flex-direction: column; }

    .app-sidebar {
        width: 100%;
        padding: 4px 0;
        overflow-x: auto;
    }

    .app-sidebar .sidebar-brand { display: none; }

    .app-sidebar nav { flex-direction: row; }

    .app-sidebar a.sidebar-link {
        flex-direction: column;
        gap: 2px;
        padding: 8px 14px;
        font-size: 11px;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }

    .app-sidebar a.sidebar-link.active {
        border-left-color: transparent;
        border-bottom-color: #4f8ef7;
    }

    .app-topbar h1 { font-size: 16px; }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

.card a.btn { width: auto; display: inline-block; }

code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.table th,
table.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    font-family: inherit;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

@media (max-width: 560px) {
    .form-row { grid-template-columns: 1fr; }
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ok { background: #eafaf1; color: #1e7e34; }
.badge-warning { background: #fff8e6; color: #92650a; }
.badge-danger { background: #fdecea; color: var(--error); }
.badge-neutral { background: #eef1f4; color: var(--muted); }

.link-btn {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--brand);
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
}

.link-btn:hover { background: var(--brand); color: #fff; }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
}
.back-link:hover { color: var(--brand); }

.muted { color: var(--muted); font-size: 13px; }
