:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --ink: #172033;
    --muted: #687385;
    --line: #e7ebf1;
    --primary: #2563eb;
    --success: #0f9f6e;
    --warning: #c27803;
    --danger: #d92d20;
    --shadow: 0 12px 32px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }

.admin-shell { min-height: 100vh; display: flex; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    background: #0d1321;
    color: #dce5f5;
    padding: 18px 14px;
    overflow-y: auto;
    z-index: 1040;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 8px 8px 18px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center; background: #2563eb; color: #fff; font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: #93a4bd; font-size: 12px; }
.nav-section {
    color: #6f819c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin: 18px 10px 7px;
}
.nav-link {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #c5d1e3;
    border-radius: 8px;
    padding: 9px 10px;
    margin: 2px 0;
    font-size: 14px;
}
.nav-link i { width: 18px; text-align: center; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.09); color: #fff; }
.nav-link.active { box-shadow: inset 3px 0 0 #60a5fa; }

.content-wrap { width: 100%; padding-left: 280px; }
.topbar {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(246, 248, 251, .9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar h1, .module-header h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: 0; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn, .light-btn {
    border: 1px solid var(--line);
    background: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    color: var(--ink);
}
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #172033; color: #fff; display: grid; place-items: center; font-weight: 800; }
.main-content { padding: 24px 28px 36px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.metric-card { padding: 18px; min-height: 126px; display: flex; flex-direction: column; gap: 14px; }
.metric-top { display: flex; justify-content: space-between; align-items: flex-start; }
.metric-icon { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: #eef4ff; color: var(--primary); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { font-size: 26px; font-weight: 850; letter-spacing: 0; }
.trend { font-size: 12px; font-weight: 800; color: var(--success); }
.skeleton-card, .table-loader {
    background: linear-gradient(90deg, #eef1f6 25%, #f8fafc 37%, #eef1f6 63%);
    background-size: 400% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.dashboard-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 16px; }
.panel { padding: 18px; }
.panel.wide { grid-column: span 2; }
.panel-head, .module-header, .toolbar, .table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.panel h2 { margin: 0; font-size: 16px; font-weight: 800; }
.panel p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.segmented { display: inline-flex; background: #f1f4f8; padding: 3px; border-radius: 8px; }
.segmented button { border: 0; background: transparent; border-radius: 6px; padding: 6px 10px; font-size: 12px; font-weight: 800; color: var(--muted); }
.segmented .active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(16,24,40,.08); }

.mini-list, .activity-list, .workflow-list { display: grid; gap: 10px; margin-top: 14px; }
.mini-row, .activity-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.activity-item { justify-content: flex-start; }
.activity-item span { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.activity-item strong, .activity-item small { display: block; }
.activity-item small { color: var(--muted); }

.module-header { margin-bottom: 16px; }
.module-header h2 { display: flex; align-items: center; gap: 10px; }
.primary-btn {
    border: 0;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    min-height: 42px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}
.toolbar { margin-bottom: 14px; }
.search-box {
    flex: 1;
    min-width: 220px;
    height: 42px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
}
.search-box input { border: 0; outline: 0; width: 100%; }
.form-select { max-width: 190px; height: 42px; border-color: var(--line); border-radius: 8px; }
.admin-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.admin-table td { white-space: nowrap; font-size: 14px; }
.badge-status { border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; background: #eef4ff; color: var(--primary); }
.badge-status.completed, .badge-status.approved, .badge-status.active, .badge-status.paid, .badge-status.resolved, .badge-status.growth, .badge-status.published { background: #eafaf4; color: var(--success); }
.badge-status.pending, .badge-status.processing, .badge-status.requested, .badge-status.scheduled { background: #fff7e6; color: var(--warning); }
.badge-status.cancelled, .badge-status.rejected, .badge-status.failed, .badge-status.suspended, .badge-status.hidden { background: #fff0ee; color: var(--danger); }
.table-loader { height: 80px; border-radius: 8px; }
.table-footer { border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: 13px; }
.pager { display: flex; gap: 8px; }
.module-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.workflow-list button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-weight: 750;
}
.danger-btn {
    border: 0;
    background: var(--danger);
    color: #fff;
    border-radius: 8px;
    min-height: 42px;
    padding: 0 14px;
    font-weight: 800;
}
.light-text-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px;
    min-height: 42px;
    padding: 0 14px;
    font-weight: 800;
}
.admin-modal { border: 0; border-radius: 8px; overflow: hidden; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: grid; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 800; color: var(--ink); }
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; }
.field-error:empty { display: none; }
.empty-state { min-height: 172px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.empty-state i { font-size: 30px; color: var(--primary); }
.empty-state strong { color: var(--ink); }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 2000; display: grid; gap: 8px; }
.app-toast { background: #172033; color: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; }
.sidebar-backdrop { display: none; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #f6f8fb;
}
.auth-card {
    width: min(100%, 420px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}
.auth-card h1 { margin: 0; font-size: 28px; font-weight: 850; letter-spacing: 0; }
.auth-card p { color: var(--muted); margin: 6px 0 20px; }
.auth-card .brand small { color: var(--muted); }
.auth-form { display: grid; gap: 12px; }
.auth-form label { font-weight: 800; font-size: 13px; color: var(--ink); }

@media (max-width: 1199px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(13,19,33,.45); z-index: 1030; }
    .content-wrap { padding-left: 0; }
}
@media (max-width: 767px) {
    .topbar { height: auto; min-height: 70px; padding: 12px 16px; }
    .topbar h1 { font-size: 20px; }
    .main-content { padding: 18px 14px 28px; }
    .stats-grid, .dashboard-grid, .module-cards { grid-template-columns: 1fr; }
    .panel.wide { grid-column: auto; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .search-box, .form-select { max-width: none; width: 100%; }
    .module-header { align-items: flex-start; }
    .primary-btn span { display: none; }
    .form-grid { grid-template-columns: 1fr; }
}
