/* ===== Design Tokens ===== */
:root {
    --sidebar-width: 255px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255,255,255,0.07);
    --sidebar-active-bg: rgba(99,102,241,0.2);
    --sidebar-active-border: #6366f1;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --topbar-height: 60px;
    --page-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--page-bg);
    color: var(--text-main);
    font-size: 14px;
    margin: 0;
}

/* ===== Sidebar ===== */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: width 0.25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed { width: 68px; }

#sidebar.collapsed .sidebar-brand-text,
#sidebar.collapsed .sidebar-user-info,
#sidebar.collapsed .nav-section-label,
#sidebar.collapsed .nav-link-text,
#sidebar.collapsed .sidebar-logout-text { display: none; }

#sidebar.collapsed .nav-link { justify-content: center; padding: 0.6rem; }
#sidebar.collapsed .nav-link i { margin: 0; }
#sidebar.collapsed .sidebar-brand { justify-content: center; }
#sidebar.collapsed .nav-section-label-icon { display: block !important; }

/* Brand / Logo */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1.1rem 1.1rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem; color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.sidebar-brand-sub {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    font-weight: 400;
    display: block;
    line-height: 1;
}

/* User profile in sidebar */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a5b4fc);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    margin-top: 2px;
    display: inline-block;
}
.role-super { background: rgba(245,158,11,0.2); color: #fbbf24; }
.role-group { background: rgba(99,102,241,0.25); color: #a5b4fc; }
.role-outlet { background: rgba(16,185,129,0.2); color: #34d399; }

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
    color: rgba(255,255,255,0.3);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 1rem 1.1rem 0.35rem;
    list-style: none;
}

.nav-section-label-icon {
    display: none;
    color: rgba(255,255,255,0.25);
    font-size: 0.6rem;
    text-align: center;
    padding: 0.75rem 0 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.6);
    border-radius: 8px;
    padding: 0.52rem 0.9rem;
    margin: 1px 0.6rem;
    white-space: nowrap;
    transition: all 0.15s;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    border-left: 2px solid transparent;
}

.sidebar-nav .nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: #a5b4fc;
    border-left-color: var(--sidebar-active-border);
    font-weight: 600;
}

/* Sidebar footer logout */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 0.75rem 0.6rem;
    flex-shrink: 0;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.15);
    border-radius: 8px;
    color: #f87171;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    justify-content: center;
}

.sidebar-logout-btn:hover {
    background: rgba(239,68,68,0.18);
    color: #fca5a5;
}

.sidebar-logout-btn i { font-size: 1rem; flex-shrink: 0; }

/* ===== Page Content ===== */
#page-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.25s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
}

#page-content.expanded {
    margin-left: 68px;
    width: calc(100% - 68px);
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0; z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    flex-shrink: 0;
}

.topbar-toggle {
    background: none;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.topbar-toggle:hover { background: var(--page-bg); color: var(--text-main); }

.topbar-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
    flex: 1;
}

.topbar-clock {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--page-bg);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Main Content ===== */
.alerts-wrapper {
    padding: 0.75rem 1.5rem 0;
}

.main-content {
    padding: 1.5rem;
    flex: 1;
}

/* ===== Alerts ===== */
.alert {
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    border: none;
}

/* Hide empty validation summaries (no errors yet) */
[data-valmsg-summary="true"]:not(.validation-summary-errors) {
    display: none;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid #22c55e;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card-blue::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.stat-card-green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card-amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card-rose::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.stat-card-cyan::before { background: linear-gradient(90deg, #06b6d4, #22d3ee); }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.10);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-icon-blue  { background: #eef2ff; color: #6366f1; }
.stat-icon-green { background: #ecfdf5; color: #10b981; }
.stat-icon-amber { background: #fffbeb; color: #f59e0b; }
.stat-icon-rose  { background: #fff1f2; color: #f43f5e; }
.stat-icon-cyan  { background: #ecfeff; color: #06b6d4; }

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

.stat-link {
    font-size: 0.78rem;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 0.5rem;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.stat-link:hover { opacity: 1; text-decoration: none; }

/* ===== Welcome Banner ===== */
.welcome-banner {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 24px rgba(99,102,241,0.25);
}

.welcome-banner::after {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(99,102,241,0.15);
    pointer-events: none;
}

.welcome-banner::before {
    content: '';
    position: absolute;
    bottom: -50px; right: 100px;
    width: 150px; height: 150px;
    border-radius: 50%;
    background: rgba(99,102,241,0.08);
    pointer-events: none;
}

.welcome-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
}

.welcome-sub {
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    margin: 0;
}

.welcome-badge {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-header-icon {
    width: 28px; height: 28px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ===== Quick Action Tiles ===== */
.quick-tile {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 1.1rem 0.75rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.quick-tile:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(99,102,241,0.3);
    text-decoration: none;
}

.quick-tile-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: #eef2ff;
    color: #6366f1;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.quick-tile:hover .quick-tile-icon {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.quick-tile-label {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}

/* ===== Activity Feed ===== */
.activity-timeline { padding: 0.25rem 0; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 0.7rem 0;
    border-bottom: 1px solid #f1f5f9;
    align-items: flex-start;
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.act-created { background: #ecfdf5; color: #10b981; }
.act-updated { background: #eff6ff; color: #3b82f6; }
.act-deleted { background: #fef2f2; color: #ef4444; }
.act-default { background: #f5f3ff; color: #8b5cf6; }

.activity-body { min-width: 0; flex: 1; }

.activity-desc {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.4;
    margin: 0 0 2px;
}

.activity-meta {
    font-size: 0.72rem;
    color: var(--text-light);
}

/* ===== Overview mini stats ===== */
.overview-stat {
    text-align: center;
    padding: 0.75rem 0.5rem;
}

.overview-stat-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    letter-spacing: -0.02em;
}

.overview-stat-label {
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 3px;
}

/* ===== Forms ===== */
.form-label {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--card-border);
    font-size: 0.875rem;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
    outline: none;
}

.form-control::placeholder { color: var(--text-light); }

/* ===== Tables ===== */
.table {
    font-size: 0.875rem;
    color: var(--text-main);
}

.table thead th {
    background: #f8fafc;
    border-top: none;
    border-bottom: 2px solid var(--card-border);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.07em;
    padding: 0.75rem 1rem;
}

.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: #f8fafc; }
.table td { padding: 0.7rem 1rem; vertical-align: middle; border-color: #f1f5f9; }

/* Items grid */
.items-grid th {
    background: var(--sidebar-bg);
    color: rgba(255,255,255,0.8);
    font-size: 0.72rem;
}

/* ===== Buttons ===== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-sm { font-size: 0.78rem; padding: 0.3rem 0.7rem; }

/* ===== Auth pages ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #312e81 100%);
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}

/* ===== Password toggle ===== */
.password-field { position: relative; }

.password-toggle {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    border: none; background: none;
    color: var(--text-light);
    cursor: pointer; padding: 0;
    z-index: 10;
    transition: color 0.15s;
}

.password-toggle:hover { color: var(--text-muted); }

/* ===== Badges ===== */
.badge-bottle {
    background: #eef2ff;
    color: #6366f1;
    font-weight: 600;
    font-size: 0.78rem;
    padding: 0.3em 0.65em;
    border-radius: 5px;
}

/* ===== Page header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.01em;
}

.page-header-sub {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 2px 0 0;
}

/* ===== Search input ===== */
.search-input-wrap {
    position: relative;
}

.search-input-wrap .bi-search {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.85rem;
}

.search-input-wrap input {
    padding-left: 2rem;
}

/* ===== Divider utility ===== */
.sidebar-divider {
    border-color: rgba(255,255,255,0.06);
    margin: 0;
}
