/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ── App Shell ─────────────────────────────────────────────────────────────── */
#app-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
    width: 240px;
    min-height: 100vh;
    background: #1e293b;
    color: #cbd5e1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}

#sidebar .sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
    border-bottom: 1px solid #334155;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#sidebar .sidebar-brand svg { flex-shrink: 0; }

#sidebar .sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}
#sidebar .sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.25rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
#sidebar .sidebar-nav li a:hover {
    background: #273449;
    color: #e2e8f0;
}
#sidebar .sidebar-nav li a.active {
    background: #334155;
    color: #f8fafc;
    border-left-color: #3b82f6;
}
#sidebar .sidebar-section-label {
    padding: 1rem 1.25rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    font-weight: 600;
}
#sidebar .sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #334155;
    font-size: 0.8rem;
    color: #64748b;
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f1f5f9;
    min-width: 0;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
#topbar {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    position: sticky;
    top: 0;
    z-index: 100;
}
#topbar .topbar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#topbar .topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: #475569;
    white-space: nowrap;
}
#topbar .topbar-user a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}
#topbar .topbar-user a:hover { text-decoration: underline; }
#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 0.35rem;
    display: none;
    line-height: 1;
}
#sidebar-toggle:hover { color: #1e293b; }

/* ── Page Content ──────────────────────────────────────────────────────────── */
.page-content { padding: 2rem 1.75rem; flex: 1; }
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 0; }
.page-header p  { margin: 0.25rem 0 0; color: #64748b; font-size: 0.9rem; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.stat-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: #0f172a; line-height: 1; }
.stat-card .stat-label { font-size: 0.8rem; color: #64748b; margin-top: 0.2rem; }
.stat-icon-blue   { background: #dbeafe; color: #2563eb; }
.stat-icon-green  { background: #dcfce7; color: #16a34a; }
.stat-icon-purple { background: #ede9fe; color: #7c3aed; }
.stat-icon-amber  { background: #fef3c7; color: #d97706; }

.content-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.content-card .card-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.content-card .card-body { padding: 1.25rem; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .actions { display: flex; gap: 0.4rem; align-items: center; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.65em;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-amber  { background: #fef3c7; color: #92400e; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary-app {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary-app:hover { background: #2563eb; color: #fff; }

.btn-secondary-app {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: #f1f5f9;
    color: #374151;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-secondary-app:hover { background: #e2e8f0; color: #374151; }

.btn-danger-app {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-danger-app:hover { background: #fecaca; color: #991b1b; }

.btn-sm-app {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert-app {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}
.alert-app-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-app-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-app-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-app-warn    { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-section { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.25rem; }
.form-section-title { font-size: 0.9rem; font-weight: 600; color: #0f172a; margin: 0 0 1rem; }
.form-grid { display: grid; gap: 1rem; }
.form-grid-2 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-field label { display: block; font-size: 0.8rem; font-weight: 500; color: #374151; margin-bottom: 0.35rem; }
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 0.875rem;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: auto;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-field .field-hint { font-size: 0.75rem; color: #6b7280; margin-top: 0.3rem; }
.form-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 1.25rem; }

/* ── Login Page ────────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.login-box {
    width: 100%;
    max-width: 420px;
}
.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-brand h1 {
    color: #f8fafc;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}
.login-brand p {
    color: #94a3b8;
    font-size: 0.875rem;
    margin: 0.4rem 0 0;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 1.25rem;
}
.login-card .btn-login {
    width: 100%;
    padding: 0.65rem;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 0.25rem;
}
.login-card .btn-login:hover { background: #2563eb; }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination-bar { display: flex; gap: 0.4rem; align-items: center; margin-top: 1rem; }
.pagination-bar a, .pagination-bar span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.6rem;
    border-radius: 7px;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid #e2e8f0;
    color: #374151;
    background: #fff;
}
.pagination-bar a:hover { background: #f1f5f9; }
.pagination-bar .pg-active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.pagination-bar .pg-disabled { color: #cbd5e1; pointer-events: none; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
    }
    #sidebar.open { transform: translateX(0); }
    #sidebar-toggle { display: flex; }
    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 199;
    }
    #sidebar-overlay.open { display: block; }
    .page-content { padding: 1.25rem 1rem; }
    .form-grid-2 { grid-template-columns: 1fr; }
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.text-muted-sm { font-size: 0.8rem; color: #64748b; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #94a3b8; }
.empty-state svg { margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state p { margin: 0; font-size: 0.9rem; }
