:root {
    --brand: #0d4038;
    --brand-dark: #092f29;
    --brand-light: #1a6b5e;
    --brand-soft: #e6f0ee;
    --accent: #c9a227;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #e2e8ee;
    --text: #17324d;
    --muted: #66798a;
    --success: #1a7f4b;
    --danger: #b42318;
    --warning: #b45309;
    --shadow-sm: 0 1px 2px rgba(13, 64, 56, 0.05);
    --shadow: 0 4px 14px rgba(13, 64, 56, 0.08);
    --shadow-lg: 0 12px 30px rgba(13, 64, 56, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 250px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-light); text-decoration: underline; }

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--brand);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 22px 22px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #f0c94a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--brand);
    font-size: 11px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.sidebar-brand-text h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
}
.sidebar-brand-text small {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
}

.sidebar-nav-section {
    margin-bottom: 6px;
}

.sidebar-nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: rgba(255, 255, 255, 0.45);
    padding: 14px 12px 6px;
    font-weight: 700;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    margin-bottom: 2px;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-nav a .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.topbar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

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

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 22px;
    color: var(--brand);
    cursor: pointer;
    padding: 4px 8px;
}

.content {
    flex: 1;
    padding: 28px;
    max-width: 1400px;
    width: 100%;
}

/* Page header */
.page-header {
    margin-bottom: 22px;
}
.page-header h1 {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 700;
    color: var(--brand);
}
.page-header p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card h2 {
    margin: 0 0 18px;
    font-size: 16px;
    font-weight: 700;
    color: var(--brand);
    letter-spacing: 0.2px;
}

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 14px;
    flex-wrap: wrap;
}
.card-header-flex h2 {
    margin: 0;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brand);
}

.stat-card.accent::before { background: var(--accent); }
.stat-card.gold::before  { background: #c9a227; }
.stat-card.teal::before  { background: var(--brand-light); }

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--brand);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-hint {
    font-size: 12px;
    color: var(--muted);
}

.stat-icon {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: inherit;
    line-height: 1;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--brand);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--brand-dark);
    color: #ffffff;
    box-shadow: var(--shadow);
}

.btn-accent {
    background: var(--accent);
    color: var(--brand);
}
.btn-accent:hover { background: #d8b23a; color: var(--brand); }

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}
.btn-danger:hover { background: #8f1c13; color: #ffffff; }

.btn-outline {
    background: transparent;
    color: var(--brand);
    border-color: var(--border);
}
.btn-outline:hover {
    background: var(--brand-soft);
    border-color: var(--brand-light);
    color: var(--brand);
}

.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

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

table.data thead th {
    background: #f6f8f9;
    text-align: left;
    padding: 12px 14px;
    font-weight: 700;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }

table.data tbody tr:hover td { background: #fafbfc; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group { display: flex; flex-direction: column; }

.form-group label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #ffffff;
    transition: border 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(26, 107, 94, 0.12);
}

.form-group .errorlist,
.field-error {
    color: var(--danger);
    font-size: 12.5px;
    margin-top: 6px;
    list-style: none;
    padding: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.badge-active   { background: #e6f5ec; color: var(--success); }
.badge-inactive { background: #f1f3f5; color: var(--muted); }
.badge-role     { background: var(--brand-soft); color: var(--brand); }
.badge-gold     { background: #faf1d6; color: #8a6a10; }

/* Messages */
.messages { margin-bottom: 20px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    animation: slideIn 0.2s ease;
}
.alert-success { background: #e6f5ec; color: #0f5a35; border-color: #bfe3ce; }
.alert-error,
.alert-danger  { background: #fdecea; color: #7c1a12; border-color: #f6c6c0; }
.alert-warning { background: #fff5e1; color: #7a4708; border-color: #f2dcae; }
.alert-info    { background: #e6f0ee; color: #0d4038; border-color: #bfded8; }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Empty state */
.empty {
    text-align: center;
    padding: 36px 20px;
    color: var(--muted);
}
.empty-icon {
    font-size: 34px;
    margin-bottom: 8px;
    display: block;
    opacity: 0.5;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { margin: 0 8px; opacity: 0.5; }

/* Detail grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 24px;
}
.detail-item {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.detail-item:last-child { border-bottom: none; }
.detail-label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}
.detail-value { color: var(--text); font-size: 14.5px; }

/* Section list (sidebar on detail pages) */
.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

/* Search bar */
.searchbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.searchbar input[type="text"] {
    flex: 1;
    min-width: 220px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}
.searchbar input[type="text"]:focus {
    outline: none;
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(26, 107, 94, 0.12);
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .form-grid, .split { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .topbar { padding: 0 18px; }
}

/* Backdrop for mobile sidebar */
.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
}
.backdrop.open { display: block; }
