:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --admin: #7c3aed;
    --admin-light: #f5f3ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warn: #d97706;
    --warn-bg: #fffbeb;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --card: #ffffff;
}

* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', -apple-system, Roboto, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ---- Auth pages ---- */
/* ============================================================
   LOGIN PAGES (two-panel, marketing side + form side)
   ============================================================ */
.auth-page-v2 {
    min-height: 100vh; display: flex; background: #f5f6fb;
}
.auth-marketing {
    flex: 1; min-width: 0; position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: center;
    padding: 4rem 4.5rem; background: #fbfbff;
}
.auth-marketing::before, .auth-marketing::after {
    content: ''; position: absolute; border-radius: 50%; z-index: 0;
}
.auth-marketing::before {
    width: 480px; height: 480px; background: radial-gradient(circle, var(--auth-accent-light) 0%, transparent 70%);
    top: -140px; left: -140px;
}
.auth-marketing::after {
    width: 360px; height: 360px; background: radial-gradient(circle, var(--auth-accent-light) 0%, transparent 70%);
    bottom: -120px; left: 30%;
}
.auth-marketing > * { position: relative; z-index: 1; }
.auth-brand-title { display: flex; align-items: center; gap: 0.7rem; font-size: 2.1rem; font-weight: 800; margin: 0 0 1rem; }
.auth-brand-title .accent { color: var(--auth-accent); }
.auth-marketing-tagline { font-size: 1.1rem; color: var(--text-muted); max-width: 460px; margin: 0 0 2.5rem; line-height: 1.5; }
.auth-feature-list { display: flex; flex-direction: column; gap: 1.4rem; max-width: 460px; }
.auth-feature-item { display: flex; align-items: flex-start; gap: 1rem; }
.auth-feature-icon {
    width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center;
    justify-content: center; font-size: 1.3rem; flex-shrink: 0;
}
.auth-feature-item h3 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.auth-feature-item p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }

.auth-form-panel {
    width: 480px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    padding: 2.5rem; background: #fff; box-shadow: -8px 0 30px rgba(15,23,42,0.04);
}
.auth-card-v2 { width: 100%; max-width: 360px; }
.auth-card-v2 .auth-brand-title { justify-content: center; font-size: 1.55rem; margin-bottom: 0.3rem; }
.auth-card-v2 .subtitle-v2 { text-align: center; color: var(--text-muted); font-size: 0.92rem; margin: 0 0 1.8rem; }
.auth-card-v2 label { display: block; margin-bottom: 1.1rem; font-size: 0.85rem; font-weight: 700; color: var(--text); }
.auth-input-wrap { position: relative; margin-top: 0.4rem; }
.auth-input-wrap .field-icon {
    position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 1rem; pointer-events: none;
}
.auth-input-wrap input {
    width: 100%; padding: 0.75rem 0.9rem 0.75rem 2.6rem;
    border: 1.5px solid var(--border); border-radius: 10px; font-size: 0.95rem;
    transition: border-color 0.15s;
}
.auth-input-wrap input:focus { outline: none; border-color: var(--auth-accent); }
.auth-toggle-pw {
    position: absolute; right: 0.8rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem;
}
.auth-remember-row { display: flex; align-items: center; justify-content: space-between; margin: -0.3rem 0 1.3rem; font-size: 0.85rem; }
.auth-remember-row label { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-weight: 600; cursor: pointer; }
.auth-card-v2 button[type=submit] {
    width: 100%; padding: 0.85rem; background: var(--auth-accent); color: #fff;
    border: none; border-radius: 10px; font-size: 1rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: background 0.15s;
}
.auth-card-v2 button[type=submit]:hover { background: var(--auth-accent-dark); }
.auth-divider { display: flex; align-items: center; gap: 0.8rem; margin: 1.4rem 0; color: var(--text-muted); font-size: 0.8rem; font-weight: 700; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-notice-box {
    display: flex; gap: 0.8rem; align-items: flex-start; padding: 1rem 1.1rem;
    background: var(--auth-accent-light); border-radius: 12px;
}
.auth-notice-icon {
    width: 34px; height: 34px; border-radius: 50%; background: #fff; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1rem; color: var(--auth-accent);
}
.auth-notice-box strong { display: block; color: var(--auth-accent-dark); font-size: 0.9rem; margin-bottom: 0.1rem; }
.auth-notice-box span { color: var(--text-muted); font-size: 0.82rem; }
.auth-back-link { text-align: center; margin-top: 1.3rem; font-size: 0.85rem; }
.auth-back-link a { color: var(--text-muted); text-decoration: none; }
.auth-back-link a:hover { color: var(--auth-accent); }

.auth-page-v2.manager-theme { --auth-accent: var(--primary); --auth-accent-dark: var(--primary-dark); --auth-accent-light: var(--primary-light); }
.auth-page-v2.admin-theme { --auth-accent: var(--admin); --auth-accent-dark: #6d28d9; --auth-accent-light: var(--admin-light); }

@media (max-width: 900px) {
    .auth-marketing { display: none; }
    .auth-form-panel { width: 100%; box-shadow: none; }
}

/* ---- App shell ---- */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    background: #1e1b4b; color: #fff; padding: 0.85rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.admin-topbar { background: #2e1065; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.3px; }
.user-info { font-size: 0.88rem; opacity: 0.9; }
.user-info a { color: #c7d2fe; text-decoration: none; margin-left: 0.4rem; font-weight: 600; }
.user-info a:hover { color: #fff; }
.admin-topbar .user-info a { color: #ddd6fe; }

/* ---- Grouped dropdown navigation ---- */
.nav-groups {
    display: flex; flex-wrap: wrap; gap: 0.2rem;
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 0 1rem; position: relative; z-index: 20;
}
.nav-group { position: relative; }
.nav-group-label {
    display: block; padding: 0.9rem 1rem; font-weight: 700; font-size: 0.88rem;
    color: var(--text); cursor: pointer; border-bottom: 3px solid transparent;
    user-select: none;
}
.nav-group.has-active .nav-group-label { color: var(--primary); border-bottom-color: var(--primary); }
.nav-group:hover .nav-group-label { background: var(--primary-light); }
.nav-dropdown {
    display: none; position: absolute; top: 100%; left: 0; min-width: 240px;
    background: #fff; border: 1px solid var(--border); border-radius: 0 0 10px 10px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.12); padding: 0.4rem; z-index: 30;
}
.nav-group:hover .nav-dropdown, .nav-group:focus-within .nav-dropdown { display: block; }
.nav-dropdown a {
    display: block; padding: 0.55rem 0.8rem; border-radius: 6px; text-decoration: none;
    color: var(--text); font-size: 0.87rem;
}
.nav-dropdown a:hover { background: var(--primary-light); color: var(--primary); }
.nav-dropdown a.active { background: var(--primary); color: #fff; font-weight: 600; }
.admin-topbar ~ .nav-groups .nav-group.has-active .nav-group-label { color: var(--admin); border-bottom-color: var(--admin); }
.admin-topbar ~ .nav-groups .nav-dropdown a:hover { background: var(--admin-light); color: var(--admin); }
.admin-topbar ~ .nav-groups .nav-dropdown a.active { background: var(--admin); }

.tab-content { padding: 1.75rem; max-width: 1200px; margin: 0 auto; }

/* ---- Alerts ---- */
.alert { padding: 0.8rem 1.1rem; border-radius: 10px; margin-bottom: 1.2rem; font-size: 0.9rem; font-weight: 500; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

h2 { font-size: 1.4rem; margin: 0 0 0.9rem; letter-spacing: -0.3px; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 0.7rem; color: var(--text); }

/* ---- Forms ---- */
.entry-form {
    background: var(--card); padding: 1.4rem; border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
    margin-bottom: 1.5rem; border: 1px solid var(--border);
}
.form-row { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-bottom: 1.1rem; }
.form-row label { flex: 1; min-width: 170px; font-size: 0.82rem; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.3px; }
.form-row.checkboxes label { flex: none; font-weight: 500; text-transform: none; display: flex; align-items: center; gap: 0.4rem; }
.entry-form input[type=text],
.entry-form input[type=date],
.entry-form input[type=number],
.entry-form input[type=file],
.entry-form input[type=password],
.entry-form select {
    width: 100%; padding: 0.55rem 0.7rem; margin-top: 0.35rem;
    border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.92rem;
    font-weight: 400; text-transform: none; color: var(--text); background: #fff;
    transition: border-color 0.15s;
}
.entry-form input:focus, .entry-form select:focus { outline: none; border-color: var(--primary); }
.entry-form input[readonly] {
    background: #f1f5f9; color: #64748b; cursor: not-allowed;
}
.entry-form button {
    padding: 0.65rem 1.5rem; background: var(--primary); color: #fff; border: none;
    border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 0.92rem;
    transition: background 0.15s;
}
.entry-form button:hover { background: var(--primary-dark); }
.entry-form.is-editing { border: 2px solid var(--warn); background: var(--warn-bg); }
.entry-form.is-editing button { background: var(--warn); }
.entry-form.is-editing button:hover { background: #b45309; }

.btn-danger { background: var(--danger) !important; padding: 0.35rem 0.8rem !important; font-size: 0.8rem; }
.btn-danger:hover { background: #b91c1c !important; }
.btn-edit {
    background: var(--primary-light); color: var(--primary); padding: 0.35rem 0.8rem;
    font-size: 0.8rem; border-radius: 6px; text-decoration: none; font-weight: 700;
    display: inline-block; border: 1px solid #c7d2fe;
}
.btn-edit:hover { background: var(--primary); color: #fff; }
.row-actions { display: flex; gap: 0.4rem; }

/* ---- Stock indicator (Issue tabs) ---- */
.stock-indicator {
    padding: 0.65rem 1rem; border-radius: 10px; font-size: 0.9rem; font-weight: 700;
    margin-bottom: 1.1rem; background: #f1f5f9; color: #475569;
}
.stock-indicator.ok { background: var(--success-bg); color: #166534; }
.stock-indicator.warn { background: var(--warn-bg); color: #92400e; }
.stock-indicator.error { background: var(--danger-bg); color: #991b1b; }

/* ---- Tables ---- */
.data-table {
    width: 100%; border-collapse: collapse; background: var(--card);
    border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
}
.data-table th, .data-table td {
    padding: 0.7rem 1rem; text-align: left; font-size: 0.87rem;
    border-bottom: 1px solid #f1f5f9;
}
.data-table th {
    background: #f8fafc; font-weight: 700; color: #475569; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.4px;
}
.data-table tbody tr:hover { background: #fafbff; }
.data-table tbody tr:last-child td { border-bottom: none; }

.admin-section { margin-bottom: 2.5rem; }
.hint { background: var(--primary-light); color: #3730a3; padding: 0.75rem 1.1rem; border-radius: 10px; font-size: 0.85rem; margin-bottom: 0.9rem; line-height: 1.5; }
.hint code { background: #e0e7ff; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.82rem; }

/* ---- Category Master grid ---- */
.master-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.1rem; }
.master-column { background: var(--card); padding: 1.1rem; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border); }
.master-column h3 { margin-top: 0; font-size: 1rem; }
.inline-form { display: flex; gap: 0.4rem; margin-bottom: 0.9rem; }
.inline-form input[type=text] { flex: 1; padding: 0.45rem 0.6rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: 0.85rem; }
.inline-form button { padding: 0.45rem 0.9rem; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 0.85rem; cursor: pointer; font-weight: 700; }
.master-list { list-style: none; padding: 0; margin: 0; max-height: 280px; overflow-y: auto; }
.master-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid #f1f5f9; font-size: 0.87rem; }
.master-list.view-only li { color: #475569; }
.btn-small { padding: 0.1rem 0.55rem !important; font-size: 0.9rem !important; line-height: 1.2; }
.checkbox-inline { display: flex; align-items: center; gap: 0.4rem; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.badge-ok { background: var(--success-bg); color: #166534; }
.badge-warn { background: var(--warn-bg); color: #92400e; }
.badge-error { background: var(--danger-bg); color: #991b1b; }
.badge-neutral { background: #f1f5f9; color: #64748b; }
.text-warn { color: #b45309; font-weight: 700; }

/* ---- Filter bars ---- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.1rem; align-items: center; }
.filter-link {
    padding: 0.4rem 0.95rem; border-radius: 999px; background: #fff; color: #475569;
    text-decoration: none; font-size: 0.84rem; font-weight: 700; border: 1.5px solid var(--border);
}
.filter-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Scrollable wide tables (calendar-pivot reports) ---- */
.scroll-table-wrap {
    max-height: 70vh; overflow: auto; border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.scroll-table-wrap .data-table { box-shadow: none; border: none; border-radius: 0; }
.scroll-table-wrap .data-table thead th {
    position: sticky; top: 0; z-index: 5; background: #f8fafc;
    box-shadow: 0 1px 0 var(--border);
}
.scroll-table-wrap .data-table th:first-child, .scroll-table-wrap .data-table td:first-child,
.scroll-table-wrap .data-table th:nth-child(2), .scroll-table-wrap .data-table td:nth-child(2) {
    position: sticky; left: 0; background: #fff; z-index: 4;
}
.scroll-table-wrap .data-table th:first-child, .scroll-table-wrap .data-table th:nth-child(2) { z-index: 6; background: #f8fafc; }
.scroll-table-wrap .data-table td:nth-child(2) { left: 44px; box-shadow: 2px 0 3px rgba(0,0,0,0.04); }
.day-col-header { font-size: 0.72rem; line-height: 1.3; white-space: nowrap; }
.month-picker-form { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.1rem; }
.month-picker-form input[type=month] { padding: 0.5rem 0.7rem; border: 1.5px solid var(--border); border-radius: 8px; }

/* ============================================================
   DSR CARD-BASED DESIGN (Daily Sales Report)
   ============================================================ */
.dsr-section-header {
    display: flex; align-items: center; gap: 0.7rem; margin: 1.8rem 0 1rem;
}
.dsr-section-header:first-child { margin-top: 0; }
.dsr-section-icon {
    width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center;
    justify-content: center; font-size: 1.05rem; background: var(--primary-light); color: var(--primary); flex-shrink: 0;
}
.dsr-section-title-wrap { flex: 1; min-width: 0; }
.dsr-section-title { font-weight: 800; font-size: 1.02rem; margin: 0; }
.dsr-section-desc { font-size: 0.8rem; color: var(--text-muted); margin: 0.1rem 0 0; }

.dsr-field-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem; margin-bottom: 1.2rem;
}
.dsr-field-card {
    background: #fff; border: 1px solid var(--border); border-radius: 14px;
    padding: 0.9rem 1.1rem; display: flex; align-items: center; gap: 0.8rem;
}
.dsr-field-icon {
    width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center;
    justify-content: center; font-size: 1.15rem; flex-shrink: 0;
}
.dsr-field-body { flex: 1; min-width: 0; }
.dsr-field-label {
    font-size: 0.72rem; color: var(--text-muted); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 0.25rem;
}
.dsr-field-input-row { display: flex; align-items: baseline; gap: 0.4rem; }
.dsr-field-input-row input {
    border: none; border-bottom: 1.5px solid var(--border); padding: 0.15rem 0;
    font-size: 1rem; font-weight: 700; width: 100%; background: transparent; color: var(--text);
}
.dsr-field-input-row input:focus { outline: none; border-bottom-color: var(--primary); }
.dsr-field-suffix { color: var(--text-muted); font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }

.mini-card-row { display: grid; gap: 1.1rem; margin-bottom: 1.5rem; }
.mini-card-row.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.mini-card-row.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.mini-card {
    background: #fff; border: 1px solid var(--border); border-radius: 16px;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.mini-card-header {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1.1rem;
    border-bottom: 1px solid #f1f5f9;
}
.mini-card-header .icon {
    width: 32px; height: 32px; border-radius: 9px; background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 0.92rem; flex-shrink: 0;
}
.mini-card-header h4 { margin: 0; font-size: 0.9rem; font-weight: 800; flex: 1; }
.mini-card-add-toggle > summary {
    list-style: none; cursor: pointer; padding: 0.35rem 0.85rem; background: var(--primary);
    color: #fff; border-radius: 8px; font-size: 0.78rem; font-weight: 700;
}
.mini-card-add-toggle > summary::-webkit-details-marker { display: none; }
.mini-card-add-toggle .add-form-body { padding: 0.9rem 1.1rem; background: #f8fafc; border-bottom: 1px solid #f1f5f9; }
.mini-card-body { padding: 0.9rem 1.1rem; overflow-x: auto; }
.mini-card-table { width: 100%; font-size: 0.83rem; border-collapse: collapse; }
.mini-card-table th {
    text-align: left; color: var(--text-muted); font-weight: 700; text-transform: uppercase;
    font-size: 0.68rem; letter-spacing: 0.3px; padding-bottom: 0.5rem; border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}
.mini-card-table td { padding: 0.5rem 0.4rem 0.5rem 0; border-bottom: 1px solid #f8fafc; white-space: nowrap; }
.mini-card-empty { color: var(--text-muted); font-size: 0.85rem; padding: 0.3rem 0; }
.mini-card-total-row td { font-weight: 800; border-bottom: none; padding-top: 0.6rem; }

.tally-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.1rem; margin-bottom: 1.5rem; }
.tally-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.tally-card-header { display: flex; align-items: center; gap: 0.6rem; padding: 0.9rem 1.1rem; border-bottom: 1px solid #f1f5f9; }
.tally-card-header .icon { width: 32px; height: 32px; border-radius: 9px; background: var(--success-bg); color: var(--success); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.tally-card-header h4 { margin: 0; font-size: 0.92rem; font-weight: 800; }
.tally-card-body { padding: 0.4rem 1.1rem 0.9rem; }
.tally-line { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid #f8fafc; font-size: 0.86rem; }
.tally-line.total { font-weight: 800; border-bottom: none; padding-top: 0.7rem; }
.tally-line .val { font-weight: 700; }

.eod-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
}
.eod-tile {
    background: #fff; border: 1px solid var(--border); border-radius: 14px;
    padding: 1rem 1.1rem; display: flex; align-items: center; gap: 0.8rem;
}
.eod-tile .icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.eod-tile .label { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.2px; }
.eod-tile .value { font-size: 1.1rem; font-weight: 800; margin-top: 0.15rem; }
.date-filter-form {
    display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: end;
    background: var(--card); padding: 0.9rem 1.1rem; border-radius: 12px;
    margin-bottom: 1.1rem; border: 1px solid var(--border);
}
.date-filter-form label { font-size: 0.78rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.3px; }
.date-filter-form input[type=date] { padding: 0.45rem 0.6rem; border: 1.5px solid var(--border); border-radius: 7px; margin-top: 0.3rem; font-size: 0.88rem; }
.date-filter-form button {
    padding: 0.5rem 1.1rem; background: var(--primary); color: #fff; border: none;
    border-radius: 7px; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.date-filter-form .clear-link { font-size: 0.85rem; color: var(--text-muted); text-decoration: none; padding-bottom: 0.5rem; }
.date-filter-form .clear-link:hover { color: var(--danger); }

/* ---- Home dashboard (Excel-style category grid) ---- */
.dashboard-intro { margin-bottom: 1.5rem; color: var(--text-muted); font-size: 0.95rem; }
.dashboard-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem;
}
.dash-card {
    background: var(--card); border-radius: 14px; overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06); border: 1px solid var(--border);
}
.dash-card-header {
    color: #fff; font-weight: 800; font-size: 0.82rem; padding: 0.6rem 0.85rem;
    letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-card-body { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; }
.dash-item {
    display: block; padding: 0.45rem 0.6rem; border-radius: 8px; text-decoration: none;
    color: var(--text); font-size: 0.8rem; font-weight: 600; transition: background 0.12s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-item:hover { background: var(--primary-light); color: var(--primary); }

/* ---- Top-level module selector ---- */
.module-select-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem; max-width: 800px; margin: 4rem auto;
}
.module-card {
    display: block; background: #fff; border-radius: 20px; padding: 2.2rem 1.8rem;
    text-decoration: none; color: inherit; border-top: 6px solid #4f46e5;
    box-shadow: 0 4px 18px rgba(0,0,0,0.07); transition: transform 0.15s, box-shadow 0.15s;
}
.module-card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,0.12); }
.module-card-icon {
    width: 64px; height: 64px; border-radius: 18px; display: flex; align-items: center;
    justify-content: center; font-size: 2rem; margin-bottom: 1.2rem;
}
.module-card h2 { margin: 0 0 0.5rem; font-size: 1.3rem; letter-spacing: -0.3px; }
.module-card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; line-height: 1.5; }

/* ============================================================
   NEW SIDEBAR SHELL
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px; flex-shrink: 0; background: linear-gradient(180deg, #1e1b4b, #312e81);
    color: #e0e7ff; display: flex; flex-direction: column; padding: 1.1rem 0.9rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-shell .sidebar { background: linear-gradient(180deg, #2e1065, #4c1d95); }
.sidebar-brand {
    display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 1.05rem;
    color: #fff; padding: 0 0.4rem 1.2rem; letter-spacing: -0.2px;
}
.brand-icon { font-size: 1.3rem; }
.sidebar-home-btn {
    display: block; text-align: center; margin: 0 0 1.1rem; padding: 0.6rem 0.8rem;
    background: rgba(255,255,255,0.14); color: #fff; border-radius: 10px;
    text-decoration: none; font-weight: 700; font-size: 0.88rem;
    border: 1.5px solid rgba(255,255,255,0.25);
}
.sidebar-home-btn:hover { background: rgba(255,255,255,0.24); }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.side-link, .side-group summary {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0.7rem;
    border-radius: 9px; text-decoration: none; color: #c7d2fe; font-weight: 600;
    font-size: 0.87rem; cursor: pointer; list-style: none;
}
.side-link::-webkit-details-marker, .side-group summary::-webkit-details-marker { display: none; }
.side-link:hover, .side-group summary:hover { background: rgba(255,255,255,0.08); color: #fff; }
.side-link.active { background: #4f46e5; color: #fff; }
.side-group summary.active-group { color: #fff; }
.side-icon { font-size: 1rem; width: 1.2rem; text-align: center; }
.chev { margin-left: auto; transition: transform 0.15s; font-size: 0.8rem; }
.side-group[open] > summary .chev { transform: rotate(90deg); }
.side-sublist { display: flex; flex-direction: column; padding-left: 1.9rem; margin: 0.1rem 0 0.4rem; }
.side-sublink {
    padding: 0.45rem 0.6rem; border-radius: 7px; text-decoration: none;
    color: #a5b4fc; font-size: 0.83rem; font-weight: 500;
}
.side-sublink:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-sublink.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 700; }
.sidebar-switch {
    display: block; text-align: center; padding: 0.6rem; border-radius: 9px;
    background: rgba(255,255,255,0.08); color: #e0e7ff; text-decoration: none;
    font-size: 0.82rem; font-weight: 700; margin-top: 0.8rem;
}
.sidebar-switch:hover { background: rgba(255,255,255,0.16); }

.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-new {
    display: flex; align-items: center; gap: 1rem; background: #fff;
    border-bottom: 1px solid var(--border); padding: 0.7rem 1.5rem; position: sticky; top: 0; z-index: 15;
}
.hamburger { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; }
.topbar-search {
    flex: 1; max-width: 420px; display: flex; align-items: center; gap: 0.5rem;
    background: #f1f5f9; border-radius: 10px; padding: 0.5rem 0.9rem; color: #94a3b8;
}
.topbar-search input { border: none; background: none; outline: none; flex: 1; font-size: 0.88rem; color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; }
.bell { font-size: 1.15rem; cursor: default; }
.user-chip { display: flex; align-items: center; gap: 0.6rem; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem;
}
.admin-shell .avatar { background: var(--admin); }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 0.85rem; }
.user-meta small { color: var(--text-muted); font-size: 0.72rem; }
.user-chip a { color: var(--text-muted); text-decoration: none; font-size: 1.1rem; margin-left: 0.3rem; }
.user-chip a:hover { color: var(--danger); }

.page-content { padding: 1.6rem 1.8rem 2.5rem; max-width: 1300px; width: 100%; margin: 0 auto; }

/* ---- Page hero header ---- */
.page-hero {
    display: flex; align-items: center; gap: 1.1rem; background: linear-gradient(120deg, var(--primary-light), #fff);
    border: 1px solid #e0e7ff; border-radius: 18px; padding: 1.4rem 1.6rem; margin-bottom: 1.3rem;
}
.admin-shell .page-hero { background: linear-gradient(120deg, var(--admin-light), #fff); border-color: #ede9fe; }
.page-hero-icon {
    font-size: 1.8rem; width: 58px; height: 58px; border-radius: 16px; background: #fff;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); flex-shrink: 0;
}
.page-hero h1 { margin: 0 0 0.2rem; font-size: 1.35rem; letter-spacing: -0.3px; }
.page-hero p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

/* ---- Stat cards ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    padding: 1rem 1.2rem; display: flex; align-items: center; gap: 0.9rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 1.3rem; font-weight: 800; color: var(--text); }

/* ---- Search/filter/sort toolbar ---- */
.list-toolbar {
    display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; margin-bottom: 1.2rem;
}
.search-box {
    flex: 1; min-width: 220px; display: flex; align-items: center; gap: 0.6rem;
    background: #fff; border: 1.5px solid var(--border); border-radius: 12px; padding: 0.6rem 1rem;
}
.search-box input { border: none; outline: none; flex: 1; font-size: 0.92rem; background: transparent; }
.search-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%; background: var(--primary-light);
    font-size: 0.85rem; flex-shrink: 0;
}
.admin-shell .search-icon { background: var(--admin-light); }
.list-toolbar select {
    padding: 0.55rem 0.8rem; border: 1.5px solid var(--border); border-radius: 10px; font-size: 0.85rem; background: #fff;
}

/* ---- Icon action buttons ---- */
.icon-actions { display: flex; gap: 0.35rem; }
.icon-btn {
    width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 0.9rem;
    text-decoration: none; color: inherit;
}
.icon-btn.view { background: #eef2ff; color: #4f46e5; }
.icon-btn.edit { background: #fef3c7; color: #b45309; }
.icon-btn.delete { background: #fee2e2; color: #dc2626; }
.icon-btn:hover { filter: brightness(0.92); }
.sortable-th a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 0.3rem; }

@media (max-width: 900px) {
    .hamburger { display: block; }
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left 0.2s; box-shadow: 0 0 30px rgba(0,0,0,0.2); }
    .app-shell.sidebar-open .sidebar { left: 0; }
    .topbar-search { display: none; }
}

/* ---- Module home-screen alert banner ---- */
.module-alert-banner {
    display: flex; align-items: center; gap: 0.7rem; background: #fffbeb; border: 1.5px solid #fde68a;
    border-radius: 12px; padding: 0.8rem 1.1rem; margin-bottom: 1.2rem; font-size: 0.88rem; color: #92400e;
}
.module-alert-icon { font-size: 1.1rem; flex-shrink: 0; }
.module-alert-banner span:nth-child(2) { flex: 1; }
.module-alert-banner a {
    background: #f59e0b; color: #fff; padding: 0.4rem 0.9rem; border-radius: 8px; font-weight: 700;
    text-decoration: none; white-space: nowrap; font-size: 0.83rem;
}
.module-alert-banner a:hover { background: #d97706; }

/* ============================================================
   PRINT VIEW — used by Stock Value, Salary, DSR Monthly Data
   ============================================================ */
.print-btn {
    padding: 0.55rem 1rem; border-radius: 10px; font-weight: 700; font-size: 0.85rem;
    cursor: pointer; border: 1.5px solid #93c5fd; background: #eff6ff; color: #1d4ed8;
}
.print-btn:hover { background: #dbeafe; }

@media print {
    .sidebar, .topbar-new, .att-btn, .pagination-bar, .filter-toolbar,
    .print-btn, .icon-btn, .row-actions, .hero-banner-image, .page-hero,
    a[href]:not(.keep-on-print) { display: none !important; }
    .app-shell { display: block !important; }
    .page-content { padding: 0 !important; margin: 0 !important; }
    body { background: #fff !important; }
    .data-table, .att-table { font-size: 10px !important; box-shadow: none !important; }
    .att-table-wrap, .scroll-table-wrap { overflow: visible !important; max-height: none !important; border: none !important; }
    * { color: #000 !important; box-shadow: none !important; }
    .print-title { display: block !important; font-size: 1.3rem; font-weight: 800; margin-bottom: 0.8rem; }
    /* Printing always includes every row, regardless of which pagination
       page is currently showing on screen — no need to switch to "All"
       first just to print the whole table. */
    .page-hidden { display: table-row !important; }
}
.print-title { display: none; }
