:root {
    --green-deep: #0D3B2E;
    --green-mid: #145C42;
    --green-fresh: #1DB974;
    --green-light: #D4F5E6;
    --amber: #F5A623;
    --amber-light: #FEF3DC;
    --red: #E53E3E;
    --red-light: #FFF5F5;
    --off-white: #F7F9F5;
    --slate: #4A5568;
    --slate-light: #EDF2F7;
    --white: #FFFFFF;
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 16px rgba(13,59,46,.10);
    --font: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--off-white); color: var(--green-deep); }

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

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--green-deep);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width .25s ease;
    overflow: hidden;
}

/* Suppress transition on page load to prevent flash */
.sidebar.no-transition,
.sidebar.no-transition * { transition: none !important; }

/* ── Collapsed: 64px, everything centred via fixed-width container ── */
.sidebar.collapsed { width: 64px; }

/* Brand: switch to column layout, kill gap, let icon centre itself */
.sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    gap: 0;
    padding: 18px 0;
    align-items: center;
    justify-content: center;
}
.sidebar.collapsed .brand-text { display: none; }

/* User strip: same approach */
.sidebar.collapsed .sidebar-user {
    flex-direction: column;
    gap: 0;
    padding: 14px 0;
    align-items: center;
    justify-content: center;
}
.sidebar.collapsed .user-info { display: none; }

/* Section labels hidden */
.sidebar.collapsed .nav-section { display: none; }

/* Nav items: no side padding, link becomes a centred square */
.sidebar.collapsed .sidebar-nav li { padding: 1px 6px; }
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
    width: 100%;
}
.sidebar.collapsed .nav-link .nav-label { display: none; }

/* Footer logout button */
.sidebar.collapsed .sidebar-footer { padding: 12px 6px; }
.sidebar.collapsed .btn-logout {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
    width: 100%;
}
.sidebar.collapsed .btn-logout .nav-label { display: none; }

/* ── Brand ── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 13px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--green-fresh);
    border-radius: 10px;
    display: grid; place-items: center;
    color: var(--green-deep);
    font-size: 18px;
    flex-shrink: 0;
    /* always stays as a perfect square — never stretches */
    min-width: 36px;
}
.brand-text {
    font-weight: 700; font-size: 15px; color: #fff;
    white-space: nowrap; overflow: hidden;
}

/* ── User strip ── */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 13px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--amber);
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700; font-size: 15px;
    color: var(--green-deep);
    flex-shrink: 0;
    /* same: never stretch */
    min-width: 36px;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }
.user-role span {
    font-size: 10px; font-weight: 600;
    background: rgba(29,185,116,.2);
    color: var(--green-fresh);
    padding: 2px 8px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: .5px;
}

/* ── Nav list ── */
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav li { padding: 1px 10px; }
.nav-section {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,.3);
    padding: 12px 10px 4px;
    white-space: nowrap;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    color: rgba(255,255,255,.7) !important;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
}
/* Fixed-width icon so it never shifts during collapse animation */
.nav-link i {
    font-size: 18px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    line-height: 1;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff !important; }
.nav-link.active { background: var(--green-fresh); color: var(--green-deep) !important; font-weight: 700; }

/* ── Footer / logout ── */
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); }
.btn-logout {
    display: flex; align-items: center; gap: 10px;
    background: none; border: none;
    color: rgba(255,255,255,.5);
    font-size: 14px; font-family: var(--font);
    padding: 10px 12px; width: 100%;
    cursor: pointer; border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
}
.btn-logout i { font-size: 18px; flex-shrink: 0; width: 20px; text-align: center; line-height: 1; }
.btn-logout:hover { background: rgba(229,62,62,.15); color: #fc8181; }

/* ── Main Area ──────────────────────────────────────────────────────── */
.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex; flex-direction: column;
    transition: margin-left .25s ease;
    min-width: 0;
}
.sidebar.collapsed ~ .main-area { margin-left: 64px; }

/* Suppress transition on page load — same no-transition class used by sidebar */
.sidebar.no-transition ~ .main-area { transition: none !important; }

.top-bar {
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid #E2E8F0;
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.btn-toggle-sidebar {
    background: none; border: none;
    font-size: 20px; color: var(--slate);
    cursor: pointer; padding: 4px;
}
.page-title { font-size: 15px; font-weight: 600; color: var(--green-deep); }
.main-content { padding: 28px 28px; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid #E2E8F0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    background: none;
    border-bottom: 1px solid #E2E8F0;
    padding: 16px 20px;
    font-weight: 700; font-size: 15px;
}

/* ── Stat cards ─────────────────────────────────────────────────────── */
.stat-card {
    background: var(--white);
    border: 1px solid #E2E8F0;
    border-radius: var(--radius);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.green { background: var(--green-light); color: var(--green-mid); }
.stat-icon.amber { background: var(--amber-light); color: #B7750A; }
.stat-icon.red { background: var(--red-light); color: var(--red); }
.stat-icon.blue { background: #EBF8FF; color: #2B6CB0; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--green-deep); }
.stat-label { font-size: 12px; color: var(--slate); font-weight: 500; }

/* ── Buttons ─────────────────────────────────────────────────────────  */
.btn-primary { background: var(--green-fresh); color: var(--green-deep); border: none; font-weight: 600; }
.btn-primary:hover { background: #18a865; color: var(--green-deep); }
.btn-outline-primary { border-color: var(--green-fresh); color: var(--green-mid); font-weight: 600; }
.btn-outline-primary:hover { background: var(--green-fresh); color: var(--green-deep); border-color: var(--green-fresh); }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert-canteen-success {
    background: var(--green-light); color: var(--green-mid);
    border: 1px solid #9AE6C4; border-radius: var(--radius-sm);
}
.alert-canteen-error {
    background: var(--red-light); color: var(--red);
    border: 1px solid #FEB2B2; border-radius: var(--radius-sm);
}

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge-green { background: var(--green-light); color: var(--green-mid); }
.badge-amber { background: var(--amber-light); color: #B7750A; }
.badge-red { background: var(--red-light); color: var(--red); }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid #CBD5E0;
    font-family: var(--font);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--green-fresh);
    box-shadow: 0 0 0 3px rgba(29,185,116,.15);
}

/* ── Auth layout ─────────────────────────────────────────────────────── */
.auth-layout {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--green-deep) 0%, var(--green-mid) 100%);
    padding: 20px;
}
.auth-card {
    background: var(--white);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%; max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-logo {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 28px;
}
.auth-logo-icon {
    width: 44px; height: 44px;
    background: var(--green-fresh);
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 22px;
    color: var(--green-deep);
}
.auth-title { font-size: 22px; font-weight: 800; color: var(--green-deep); }
.auth-subtitle { font-size: 13px; color: var(--slate); margin-top: 2px; }

/* ── POS Screen ─────────────────────────────────────────────────────── */
.pos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; height: calc(100vh - 130px); }
.pos-left { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.pos-right { display: flex; flex-direction: column; gap: 14px; }

.pos-search-bar { display: flex; gap: 10px; }
.barcode-indicator {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600;
    color: var(--green-mid);
    background: var(--green-light);
    border-radius: 6px; padding: 4px 10px;
}
.barcode-flash { animation: flashGreen .3s ease; }
@keyframes flashGreen { 0%,100% { background: var(--green-light); } 50% { background: var(--green-fresh); } }

.cart-table-wrap { flex: 1; overflow-y: auto; }
.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th { background: var(--slate-light); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 10px 12px; color: var(--slate); position: sticky; top: 0; }
.cart-table td { padding: 10px 12px; border-bottom: 1px solid #EDF2F7; font-size: 14px; vertical-align: middle; }
.cart-table tr:last-child td { border-bottom: none; }
.btn-remove { background: none; border: none; color: #FC8181; cursor: pointer; font-size: 16px; padding: 2px 6px; }
.btn-remove:hover { color: var(--red); }

.cart-total-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px;
    background: var(--green-light);
    border-radius: var(--radius-sm);
    font-weight: 700;
}
.total-amount { font-size: 22px; color: var(--green-mid); font-family: var(--font-mono); }

.student-panel { background: var(--slate-light); border-radius: var(--radius); padding: 16px; }
.student-found { background: var(--green-light); border-radius: var(--radius-sm); padding: 12px 14px; }
.student-balance { font-size: 20px; font-weight: 700; font-family: var(--font-mono); color: var(--green-mid); }

.btn-charge {
    background: var(--green-deep); color: #fff;
    border: none; border-radius: var(--radius-sm);
    padding: 14px; font-size: 16px; font-weight: 700;
    width: 100%; cursor: pointer; transition: background .15s;
    font-family: var(--font);
}
.btn-charge:hover { background: var(--green-mid); }
.btn-charge:disabled { background: #CBD5E0; cursor: not-allowed; }

/* ── Product Grid ────────────────────────────────────────────────────── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.product-card {
    background: var(--white);
    border: 1.5px solid #E2E8F0;
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color .15s, transform .15s, box-shadow .15s;
    user-select: none;
}
.product-card:hover { border-color: var(--green-fresh); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(29,185,116,.12); }
.product-card .price { font-size: 18px; font-weight: 700; color: var(--green-mid); font-family: var(--font-mono); }
.product-card .stock-pill {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 20px;
}

/* ── Wallet balance display ─────────────────────────────────────────── */
.wallet-hero {
    background: linear-gradient(135deg, var(--green-deep), var(--green-mid));
    border-radius: var(--radius);
    padding: 28px;
    color: #fff;
}
.wallet-amount { font-size: 40px; font-weight: 800; font-family: var(--font-mono); letter-spacing: -1px; }
.wallet-label { font-size: 13px; opacity: .7; font-weight: 500; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table { font-size: 14px; }
.table th {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--slate); background: var(--slate-light);
    border-bottom: none;
    padding: 13px 16px;
    white-space: nowrap;
}
.table td {
    vertical-align: middle;
    padding: 13px 16px;
    border-color: #EDF2F7;
}
.table-hover tbody tr:hover { background: #F0FFF4; }
.table > :not(caption) > * > * { border-color: #EDF2F7; }

/* ── DataTables overrides ────────────────────────────────────────────── */
/* Wrapper spacing — room between card edge and table controls */
div.dataTables_wrapper {
    padding: 18px 20px 16px;
    align-items:end;
}
div.dataTables_wrapper div.dataTables_filter,
div.dataTables_wrapper div.dataTables_length {
    margin-bottom: 14px;
}
div.dataTables_wrapper div.dataTables_filter label,
div.dataTables_wrapper div.dataTables_length label {
    font-size: 13px;
    font-weight: 500;
    color: var(--slate);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    border: 1.5px solid #CBD5E0;
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 13px;
    font-family: var(--font);
    color: var(--green-deep);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}

div.dataTables_wrapper div.dataTables_filter input:focus,
div.dataTables_wrapper div.dataTables_length select:focus {
    outline: none;
    border-color: var(--green-fresh);
    box-shadow: 0 0 0 3px rgba(29,185,116,.15);
}
/* Info text */
div.dataTables_wrapper div.dataTables_info {
    font-size: 12px;
    color: var(--slate);
    padding-top: 10px;
}
/* Pagination */
div.dataTables_wrapper div.dataTables_paginate {
    padding-top: 6px;
}

table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
    opacity: .5;
}
table.dataTable thead th.sorting_asc::after  { color: var(--green-fresh); opacity: 1; }
table.dataTable thead th.sorting_desc::after { color: var(--green-fresh); opacity: 1; }

/* ── Nav Pills (role filter tabs) ────────────────────────────────────── */
.nav-pills .nav-link {
    color: var(--slate);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid #E2E8F0;
    background: var(--white);
    transition: background .15s, color .15s, border-color .15s;
}
.nav-pills .nav-link:hover {
    background: var(--green-light);
    color: var(--green-mid);
    border-color: var(--green-fresh);
}
.nav-pills .nav-link.active {
    background: var(--green-fresh) !important;
    color: var(--green-deep) !important;
    border-color: var(--green-fresh) !important;
    font-weight: 700;
}
#userTabs { gap: 6px; }

/* ── Mono data ──────────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }

/* ── Receipt modal ──────────────────────────────────────────────────── */
.receipt {
    background: #fff; border-radius: var(--radius); padding: 24px;
    text-align: center; max-width: 340px; margin: 0 auto;
}
.receipt-ref { font-family: var(--font-mono); font-size: 13px; color: var(--slate); }
.receipt-amount { font-size: 36px; font-weight: 800; color: var(--green-mid); font-family: var(--font-mono); }
.receipt-check { font-size: 56px; color: var(--green-fresh); }
/*FP*/
.fp-step-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #dee2e6;
    display: inline-block;
    margin: 0 3px;
}
.fp-step-dot.done {
    background: #198754;
}

.fp-step-dot.active {
    background: #0d6efd;
}
/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .pos-layout { grid-template-columns: 1fr; height: auto; }
    .main-content { padding: 16px; }
}
@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar .brand-text,
    .sidebar .user-info,
    .sidebar .nav-section,
    .sidebar .nav-label { display: none; }
    .sidebar .sidebar-brand { flex-direction: column; gap: 0; padding: 18px 0; align-items: center; justify-content: center; }
    .sidebar .sidebar-user { flex-direction: column; gap: 0; padding: 14px 0; align-items: center; justify-content: center; }
    .sidebar .sidebar-nav li { padding: 1px 6px; }
    .sidebar .nav-link { justify-content: center; padding: 11px 0; gap: 0; }
    .sidebar .sidebar-footer { padding: 12px 6px; }
    .sidebar .btn-logout { justify-content: center; padding: 11px 0; gap: 0; }
    .main-area { margin-left: 64px; }
}
