:root {
    --primary: #7c3aed;
    --primary-dark: #5b21b6;
    --primary-light: #8b5cf6;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0ea5e9;
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-sidebar: #13151f;
    --bg-hover: #252836;
    --border: #2a2d3e;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: #a78bfa; }

/* ── LAYOUT ─────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo .logo-icon {
    font-size: 1.5rem;
}

.sidebar-logo .logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

.sidebar-logo .logo-version {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0.4rem 1rem 0.2rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    border-radius: 0;
    transition: all 0.15s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    background: rgba(124, 58, 237, 0.15);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

.nav-item .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info .user-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
}

.user-info .user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── MAIN CONTENT ────────────────────────────────────── */
.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ── CARDS ───────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── STAT CARDS ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--primary); }

.stat-icon { font-size: 1.5rem; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── MODULE CARDS ────────────────────────────────────── */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
}

.module-card:hover {
    border-color: var(--primary);
    background: rgba(124, 58, 237, 0.08);
    transform: translateY(-2px);
    text-decoration: none;
}

.module-card.wip {
    opacity: 0.5;
    cursor: default;
}

.module-card.wip:hover {
    transform: none;
    border-color: var(--border);
    background: var(--bg-card);
}

.module-icon { font-size: 2rem; }

.module-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.module-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.module-badge {
    font-size: 0.65rem;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 600;
    background: rgba(124, 58, 237, 0.2);
    color: var(--primary-light);
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.module-badge.wip {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
    border-color: var(--border);
}

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ── BADGES ──────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-success { background: rgba(22,163,74,0.2); color: #4ade80; }
.badge-danger  { background: rgba(220,38,38,0.2); color: #f87171; }
.badge-warning { background: rgba(217,119,6,0.2); color: #fbbf24; }
.badge-info    { background: rgba(14,165,233,0.2); color: #38bdf8; }
.badge-gray    { background: rgba(100,116,139,0.2); color: var(--text-muted); }

/* ── FORMS ───────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

select.form-control option { background: var(--bg-card); }

/* ── TABLES ──────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid rgba(42, 45, 62, 0.6);
    color: var(--text-dim);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); color: var(--text); }

/* ── ALERTS ──────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-success { background: rgba(22,163,74,0.15); border: 1px solid rgba(22,163,74,0.3); color: #4ade80; }
.alert-danger  { background: rgba(220,38,38,0.15); border: 1px solid rgba(220,38,38,0.3); color: #f87171; }
.alert-warning { background: rgba(217,119,6,0.15); border: 1px solid rgba(217,119,6,0.3); color: #fbbf24; }
.alert-info    { background: rgba(14,165,233,0.15); border: 1px solid rgba(14,165,233,0.3); color: #38bdf8; }

/* ── LOGIN PAGE ──────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 60% 40%, rgba(124,58,237,0.15) 0%, transparent 60%), var(--bg);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* ── FILTER BAR ─────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.filter-form .form-control {
    width: auto;
    min-width: 160px;
    flex: 1;
}

.filter-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── DATA TABLE ──────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 0.6rem 1rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600; text-align: left; }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid rgba(42,45,62,0.6); color: var(--text-dim); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); color: var(--text); }

.item-name { font-weight: 500; color: var(--text); }
.item-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.table-actions { text-align: right; white-space: nowrap; }

/* ── FORM LAYOUT ─────────────────────────────────────── */
.form-card { display: flex; flex-direction: column; gap: 1.25rem; }
.form-card .card { margin-bottom: 0; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid .form-group.full { grid-column: 1 / -1; }
.form-group { margin-bottom: 0; }

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.form-actions .btn-danger { margin-right: auto; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dim);
    padding-top: 0.4rem;
}

/* ── DETAIL VIEW ─────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.25rem;
    align-items: start;
}

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th { width: 35%; padding: 0.5rem 0.75rem; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; vertical-align: top; border-bottom: 1px solid var(--border); }
.detail-table td { padding: 0.5rem 0.75rem; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.detail-table tr:last-child th, .detail-table tr:last-child td { border-bottom: none; }

.detail-main { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-side { display: flex; flex-direction: column; gap: 1.25rem; }

.echeck-item, .list-item {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.echeck-item:last-child, .list-item:last-child { border-bottom: none; }
.echeck-date { font-weight: 500; color: var(--text); }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

/* ── UTILITY ─────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; font-size: 0.82rem; }
.text-success { color: #4ade80; }
.text-danger { color: #f87171; }
.badge-secondary { background: rgba(100,116,139,0.2); color: var(--text-muted); }
.badge-primary { background: rgba(124,58,237,0.2); color: var(--primary-light); }
code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 0.82rem; color: #a78bfa; }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modules-grid { grid-template-columns: repeat(2, 1fr); }
}
