/* ============================================================
   SMARTY SYSTEM - MODERN UI REDESIGN
   Desktop: fixed sidebar + topbar. Tablet/Mobile: drawer, bottom nav.
   Themes: .theme-green (light, navy sidebar) and .theme-dark.
   Structure / IDs / JS hooks are unchanged.
   ============================================================ */

:root {
    --smarty-green: #0cc44e;
    --smarty-green-dark: #09a841;
    --c-green: #0cc44e;
    --c-blue: #3b82f6;
    --c-orange: #f59e0b;
    --c-purple: #8b5cf6;
    --c-red: #ef4444;
    --radius: 20px;
    --radius-sm: 14px;
    --sidebar-w: 272px;
    --transition-fast: all 0.15s ease;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --btn-grad: linear-gradient(180deg, #17d35e 0%, #09a841 100%);
}

/* Light theme */
.theme-green {
    --bg-main: #f1f6fa;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --text-main: #26394d;
    --text-dark: #0e2236;
    --text-muted: #6a7d90;
    --accent: #0cc44e;
    --accent-hover: #09a841;
    --accent-text: #08a244;
    --accent-soft: #e5f9ec;
    --accent-border: #a4ebbf;
    --sidebar: linear-gradient(180deg, #06182b 0%, #082640 100%);
    --sidebar-text: #ffffff;
    --border: #e1e9f0;
    --border-light: #edf3f8;
    --shadow-sm: 0 1px 2px rgba(7, 27, 47, 0.05);
    --shadow: 0 1px 2px rgba(7, 27, 47, 0.04), 0 8px 26px rgba(7, 27, 47, 0.06);
    --shadow-lg: 0 18px 44px rgba(7, 27, 47, 0.14);
    --input-bg: #ffffff;
    --table-th-bg: #f1f6fa;
    --table-row-hover: #f7fafc;
    --overlay-bg: rgba(5, 18, 32, 0.55);
    --topbar-bg: rgba(241, 246, 250, 0.85);
    --nav-bg: #ffffff;
}

/* Dark theme */
.theme-dark {
    --bg-main: #040f1b;
    --bg-card: #0a1c2f;
    --bg-elevated: #0d2540;
    --text-main: #d4e3f0;
    --text-dark: #f4f9ff;
    --text-muted: #8aa3b8;
    --accent: #0cc44e;
    --accent-hover: #12d95a;
    --accent-text: #2fe27a;
    --accent-soft: #0b2f20;
    --accent-border: #14703d;
    --sidebar: linear-gradient(180deg, #03111f 0%, #051a2d 100%);
    --sidebar-text: #ffffff;
    --border: #133450;
    --border-light: #0f2a42;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.5);
    --input-bg: #071a2a;
    --table-th-bg: #0b2236;
    --table-row-hover: #0e2a45;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --topbar-bg: rgba(4, 15, 27, 0.85);
    --nav-bg: #081a2c;
}

/* ============================================================
   GLOBAL
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.35s ease, color 0.35s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

i[class^="ph"], i[class*=" ph-"] { line-height: 1; }

.sm-logo { width: 44px; height: 44px; display: block; flex-shrink: 0; object-fit: contain; border-radius: 24%; }

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font-weight: 800; letter-spacing: 1px; font-size: 1.45rem; color: #fff; }
.brand-text small { font-size: 0.82rem; letter-spacing: 6px; font-weight: 600; color: #19e068; margin-top: 4px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 35%, transparent); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(120% 90% at 50% 0%, rgba(10, 60, 50, 0.94), rgba(4, 15, 27, 0.96) 70%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading-overlay.hidden { display: flex !important; opacity: 0; visibility: hidden; pointer-events: none; }

.ld-bg { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .35; pointer-events: none; }
.ld-bg-1 { width: 320px; height: 320px; left: -110px; top: -90px; background: #19e068; animation: ldFloat 7s ease-in-out infinite; }
.ld-bg-2 { width: 360px; height: 360px; right: -140px; bottom: -120px; background: #12b8a6; animation: ldFloat 9s ease-in-out infinite reverse; }

.ld-card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 34px 38px 28px;
    min-width: 270px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    animation: ldCardIn .45s cubic-bezier(.16, 1, .3, 1);
}

.ld-stage { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 6px; }

.ld-glow {
    position: absolute;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(25, 224, 104, .55), transparent 70%);
    animation: ldGlow 2.2s ease-in-out infinite;
}

.ld-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ld-ring circle { fill: none; stroke-width: 3.5; }
.ld-ring-bg { stroke: rgba(255, 255, 255, 0.1); }
.ld-ring-arc {
    stroke: #19e068;
    stroke-linecap: round;
    stroke-dasharray: 90 250;
    transform-origin: 60px 60px;
    animation: spinOrbit 1.5s linear infinite;
    filter: drop-shadow(0 0 6px rgba(25, 224, 104, .7));
}

.ld-orbit { position: absolute; inset: 0; animation: spinOrbit 9s linear infinite; }

.ld-ico {
    position: absolute;
    left: 50%; top: 50%;
    width: 32px; height: 32px;
    margin: -16px 0 0 -16px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: linear-gradient(145deg, #0e3f33, #0a2b3a);
    border: 1px solid rgba(25, 224, 104, .55);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .35), 0 0 12px rgba(25, 224, 104, .25);
    transform: rotate(var(--a)) translateY(-67px) rotate(calc(var(--a) * -1));
}

.ld-ico i { color: #19e068; font-size: 1.05rem; line-height: 1; animation: spinOrbit 9s linear infinite reverse; }

.loading-logo {
    position: relative;
    width: 72px; height: 72px;
    display: grid; place-items: center;
    animation: pulseLogo 1.8s ease-in-out infinite;
}

.loading-logo .sm-logo { width: 72px; height: 72px; border-radius: 22%; box-shadow: 0 12px 28px rgba(0, 0, 0, .4); }

.ld-brand { color: #fff; font-size: 1.45rem; font-weight: 800; letter-spacing: -.5px; line-height: 1; }
.ld-brand b { color: #19e068; }

.loading-text { color: rgba(255, 255, 255, .85); font-weight: 600; letter-spacing: 1px; font-size: 0.9rem; text-align: center; animation: pulseText 1.8s ease-in-out infinite; }

.loading-progress { width: 190px; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; }

.loading-progress::after {
    content: '';
    display: block;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #19e068, #12b8a6, transparent);
    animation: progressSlide 1.3s ease-in-out infinite;
}

.ld-dots { display: flex; gap: 7px; }
.ld-dots i { width: 7px; height: 7px; border-radius: 50%; background: #19e068; opacity: .3; animation: ldDot 1.2s ease-in-out infinite; }
.ld-dots i:nth-child(2) { animation-delay: .2s; }
.ld-dots i:nth-child(3) { animation-delay: .4s; }

@keyframes spinOrbit { to { transform: rotate(360deg); } }
@keyframes pulseLogo { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes pulseText { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes progressSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes ldGlow { 0%, 100% { transform: scale(.9); opacity: .7; } 50% { transform: scale(1.2); opacity: 1; } }
@keyframes ldFloat { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(30px, 24px); } }
@keyframes ldDot { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
@keyframes ldCardIn { from { transform: translateY(16px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOASTS
   ============================================================ */
#toast-host {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 260px;
    max-width: min(380px, calc(100vw - 32px));
    padding: 14px 16px;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-left: 4px solid var(--c-blue);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast > i { font-size: 1.4rem; margin-top: 1px; color: var(--c-blue); flex-shrink: 0; }
.toast-success { border-left-color: var(--c-green); }
.toast-success > i { color: var(--c-green); }
.toast-error { border-left-color: var(--c-red); }
.toast-error > i { color: var(--c-red); }
.toast-warning { border-left-color: var(--c-orange); }
.toast-warning > i { color: var(--c-orange); }
.toast-title { font-weight: 800; font-size: 0.85rem; color: var(--text-dark); }
.toast-message { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }

/* ============================================================
   AUTH (login screen) + modals + staff management
   ============================================================ */
.auth-container {
    --text-main: #16324f; --text-dark: #0a2540; --text-muted: #6b7f95; --border: #dbe7e1;
    --input-bg: #ffffff; --bg-card: #ffffff; --accent-text: #08a244; --accent-soft: #e5f9ec;
    position: fixed; inset: 0; z-index: 500; overflow-y: auto; padding: 22px 16px 28px;
    background: linear-gradient(180deg, #f8fcfa 0%, #eef8f2 100%);
}
.auth-blob { position: fixed; border-radius: 50%; pointer-events: none; z-index: 0; }
.auth-blob-tl { width: 360px; height: 360px; left: -190px; top: -210px; background: linear-gradient(145deg, #12b85a, #7be5a8); }
.auth-blob-br { width: 420px; height: 420px; right: -230px; bottom: -250px; background: linear-gradient(145deg, #7be5a8, #12b85a); opacity: .85; }
.auth-wrap { position: relative; z-index: 1; max-width: 500px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; justify-content: center; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 22px; }
.auth-brand .sm-logo { width: 64px; height: 64px; }
.auth-brand h1 { margin: 0; font-size: 2.1rem; font-weight: 800; letter-spacing: -1px; color: #0a2540; line-height: 1.05; }
.auth-brand h1 b { color: #0aa84a; }
.auth-brand small { display: block; margin-top: 6px; font-size: .64rem; font-weight: 700; letter-spacing: 3.2px; color: #6b7f95; }
.auth-card { background: #fff; border: 1px solid #e3efe8; border-radius: 28px; padding: 30px 28px; box-shadow: 0 24px 60px rgba(10, 60, 40, .1); animation: slideUp .6s cubic-bezier(.16, 1, .3, 1); }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.auth-card h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 2rem; font-weight: 800; letter-spacing: -1px; color: #0a2540; }
.auth-card h2 i { color: #12b85a; font-size: 1.9rem; }
.auth-sub { margin: 0 0 20px; color: #6b7f95; font-size: .98rem; }
.auth-card .form-group { margin-bottom: 14px; }
.auth-card label { color: #0a2540; font-size: .9rem; font-weight: 700; }
.auth-card label i { color: #0aa84a; font-size: 1.15rem; }
.auth-card .req { color: #0aa84a; }
.field { position: relative; }
.field .field-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #7c93a8; font-size: 1.2rem; pointer-events: none; z-index: 2; }
.field input, .field select { padding-left: 46px; height: 54px; border-radius: 16px; background-color: #fff; border: 1.5px solid #dbe7e1; color: #0a2540; }
.field input:focus, .field select:focus { border-color: #12b85a; box-shadow: 0 0 0 4px rgba(18, 184, 90, .15); }
.select-field select { border-color: #66dba0; background-color: #f1fbf5; font-weight: 700; }
.select-field .field-icon { color: #0aa84a; }
.phone-field .phone-prefix { position: absolute; left: 46px; top: 50%; transform: translateY(-50%); z-index: 2; display: flex; align-items: center; height: 26px; padding-right: 12px; border-right: 1.5px solid #dbe7e1; color: #0a2540; font-weight: 800; font-size: .95rem; letter-spacing: .2px; pointer-events: none; }
.field.phone-field input { padding-left: 112px; }
.password-wrapper input { padding-right: 48px; }
.password-wrapper .toggle-password { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #7c93a8; cursor: pointer; font-size: 1.2rem; z-index: 2; }
.password-wrapper .toggle-password:hover { color: #0aa84a; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 6px; }
.auth-row .remember { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 600; cursor: pointer; }
.auth-row .remember input { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: #12b85a; box-shadow: none; }
.link-btn { border: 0; background: none; color: #0aa84a; font-weight: 700; font-size: .92rem; cursor: pointer; padding: 6px 0; }
.link-btn:hover { text-decoration: underline; }
.login-message { min-height: 20px; margin: 4px 0 8px; color: #d93636; font-size: .85rem; font-weight: 600; line-height: 1.45; }
.login-message.ok { color: #0a8f3f; }
.auth-submit { width: 100%; height: 56px; font-size: 1.05rem; border-radius: 16px; margin-top: 2px; }
.secure-line { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 12px; color: #5b708a; font-size: .85rem; }
.secure-line i { color: #0aa84a; font-size: 1.2rem; }
.auth-note { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; border-left: 4px solid #12b85a; background: #f2f6f9; color: #4a6078; font-size: .86rem; line-height: 1.45; }
.auth-note i { font-size: 1.6rem; color: #5b708a; }
.auth-foot { text-align: center; margin-top: 20px; color: #6b7f95; font-size: .7rem; letter-spacing: 2px; }
.auth-foot b { display: block; color: #0aa84a; font-size: .95rem; letter-spacing: 0; margin-bottom: 4px; }
@media (max-width: 430px) {
    .auth-card { padding: 24px 18px; border-radius: 24px; }
    .auth-brand h1 { font-size: 1.7rem; }
    .auth-brand .sm-logo { width: 52px; height: 52px; }
    .auth-card h2 { font-size: 1.7rem; }
}

@media (min-width: 900px) {
    .auth-container { padding: 40px 32px; }
    .auth-wrap { max-width: 820px; }
    .auth-brand { margin-bottom: 28px; }
    .auth-brand .sm-logo { width: 76px; height: 76px; }
    .auth-brand h1 { font-size: 2.5rem; }
    .auth-card { padding: 44px 52px; border-radius: 34px; }
    .auth-card h2 { font-size: 2.3rem; }
    .auth-sub { font-size: 1.05rem; margin-bottom: 28px; }
    #login-form { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; row-gap: 4px; }
    #login-form .form-group { margin-bottom: 14px; }
    #login-form .auth-row, #login-form .login-message, #login-form .auth-submit { grid-column: 1 / -1; }
    .auth-card .field input, .auth-card .field .cs-btn { height: 58px; }
    .auth-submit { height: 60px; }
}
@media (min-width: 1400px) {
    .auth-wrap { max-width: 900px; }
}

/* ---------- modals ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: rgba(4, 15, 27, .62); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal-card { width: min(660px, 100%); max-height: 92vh; overflow-y: auto; background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border); border-radius: 24px; padding: 24px; box-shadow: var(--shadow-lg); }
.small-modal { width: min(420px, 100%); }
.modal-card h3 { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-size: 1.15rem; font-weight: 800; color: var(--text-dark); }
.modal-card h3 i { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--btn-grad); color: #fff; font-size: 1.3rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-actions .btn { width: auto; }
.btn-ghost { background: var(--bg-card) !important; color: var(--text-main) !important; border: 1px solid var(--border); box-shadow: none !important; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-text) !important; }

/* ---------- staff & roles ---------- */
.staff-table { min-width: 700px; }
.staff-table td { white-space: normal; }
.staff-actions { white-space: normal; }
.staff-actions .btn { width: auto; margin: 2px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 6px; }
.perm-group { border: 1px solid var(--border); border-radius: 16px; padding: 12px; background: var(--table-th-bg); }
.perm-group > strong { display: block; margin-bottom: 4px; font-size: .85rem; color: var(--text-dark); }
.perm-item { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: 500; font-size: .84rem; cursor: pointer; }
.perm-item input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.perm-item.disabled { opacity: .45; cursor: not-allowed; }

/* hide actions the signed-in role can never use (the database blocks them anyway) */
body.np-del-sale button[onclick*="deleteSale("],
body.np-del-loan button[onclick*="deleteLoan("],
body.np-refund button[onclick*="refundLoan("] { display: none !important; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    background: var(--bg-main);
}

/* ---------- Topbar ---------- */
.global-topbar {
    position: sticky;
    top: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    background: var(--topbar-bg);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
}

.global-topbar .menu-toggle-btn { order: 1; }
.topbar-logo { order: 2; display: none; align-items: center; gap: 10px; }
.topbar-logo .sm-logo { width: 38px; height: 38px; }
.topbar-logo .brand-text b { font-size: 1.15rem; color: var(--text-dark); }
.topbar-logo .brand-text small { font-size: 0.66rem; letter-spacing: 5px; margin-top: 3px; }
.topbar-search { order: 3; flex: 1; position: relative; min-width: 0; }
.topbar-clock { order: 4; }
#notif-btn { order: 5; }
#theme-toggle-btn { order: 6; }
.topbar-profile { order: 7; }

.topbar-search input {
    width: 100%;
    height: 50px;
    padding: 0 16px 0 48px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dark);
    font-size: 0.92rem;
    box-shadow: var(--shadow-sm);
}

.topbar-search > i {
    position: absolute;
    left: 17px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
    pointer-events: none;
    transition: var(--transition);
}

.topbar-search input:focus + i { color: var(--accent); }

.topbar-clock {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 50px;
    padding: 0 18px;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.topbar-clock i { font-size: 1.15rem; color: var(--text-muted); }

.topbar-icon-btn,
.global-topbar .menu-toggle-btn {
    position: relative;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-dark);
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.topbar-icon-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.topbar-icon-btn:active, .global-topbar .menu-toggle-btn:active { transform: scale(0.94); }

#theme-toggle-btn { background: #08203a; border-color: #08203a; color: #fff; }
.theme-dark #theme-toggle-btn { background: var(--bg-card); border-color: var(--border); color: #ffd466; }

.global-topbar .menu-toggle-btn { background: var(--btn-grad); border-color: transparent; color: #fff; box-shadow: 0 8px 18px rgba(12, 196, 78, 0.3); }

.notif-dot {
    position: absolute;
    top: 11px;
    right: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid var(--bg-card);
}

.topbar-profile { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-profile-copy { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-profile-copy strong { font-size: 0.88rem; color: var(--text-dark); font-weight: 700; }
.topbar-profile-copy span { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.topbar-avatar { width: 46px; height: 46px; }

/* ---------- Avatar ---------- */
.avatar-container { position: relative; cursor: pointer; flex-shrink: 0; }

.avatar-box {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #0e3b5e, #0a2a44);
    border: 2px solid #19e068;
    color: #d4e3f0;
    flex-shrink: 0;
    transition: var(--transition);
}

.avatar-box img { width: 100%; height: 100%; object-fit: cover; }
.avatar-box i { font-size: 1.4rem; }

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(4, 15, 27, 0.65);
    color: #fff;
    display: grid;
    place-items: center;
    opacity: 0;
    transition: var(--transition);
    font-size: 1.1rem;
}

.avatar-container:hover .avatar-upload-overlay { opacity: 1; }

/* ---------- Sidebar ---------- */
aside {
    background: var(--sidebar);
    color: var(--sidebar-text);
    width: 288px;
    max-width: 86vw;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-102%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 300;
    box-shadow: none;
    overflow: hidden;
}

aside.active { transform: translateX(0); box-shadow: 18px 0 50px rgba(0, 0, 0, 0.35); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 290;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 26px 24px 20px; }
.sidebar-brand .sm-logo { width: 46px; height: 46px; }

.sidebar-profile {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "av name" "av role";
    align-items: center;
    column-gap: 12px;
    margin: 0 16px 18px;
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(25, 224, 104, 0.35);
    background: linear-gradient(135deg, rgba(12, 196, 78, 0.12), rgba(12, 196, 78, 0.03));
}

.sidebar-profile .avatar-container { grid-area: av; }
.sidebar-profile h2 { grid-area: name; font-size: 0.95rem; font-weight: 700; color: #fff; align-self: end; }

.sidebar-profile .role-badge {
    grid-area: role;
    align-self: start;
    font-size: 0.74rem;
    font-weight: 600;
    color: #9fb6ca;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sidebar-profile .role-badge i { display: none; }
.sidebar-profile .sub-title { display: none; }

.sidebar-scrollable-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 14px 18px;
}

.nav-links { display: flex; flex-direction: column; gap: 5px; flex: 1; }

.nav-links button {
    border: 1px solid transparent;
    background: transparent;
    color: #c7d7e6;
    text-align: left;
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
    width: 100%;
}

.nav-links button i { font-size: 1.4rem; color: #8fa9bf; flex-shrink: 0; transition: var(--transition); }

.nav-links button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-links button:hover i { color: #fff; }

.nav-links button.active {
    background: linear-gradient(135deg, rgba(12, 196, 78, 0.34), rgba(12, 196, 78, 0.12));
    border-color: rgba(25, 224, 104, 0.45);
    color: #fff;
}

.nav-links button.active i { color: #19e068; }

.btn-logout {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #ff6b6b !important;
}

.nav-links .btn-logout { margin-top: 18px; }
.btn-logout i { color: #ff5252 !important; }
.btn-logout:hover { background: rgba(239, 68, 68, 0.14) !important; }

.sidebar-footer {
    margin-top: 22px;
    padding-top: 14px;
    font-size: 0.72rem;
    color: #6f8aa1;
    line-height: 1.7;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer span { display: block; }

/* ---------- Main ---------- */
main { flex: 1; padding: 6px 32px 48px; width: 100%; }

main > header,
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 12px 0 22px;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.6px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 i {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    background: var(--accent-soft);
    color: var(--accent-text);
}

.clock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 99px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.clock i { font-size: 1.05rem; }

/* Dashboard shows the hero instead of the page header */
#app-screen[data-tab="dashboard"] main > header { display: none; }

.welcome-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0a8f3f, #0cc44e);
    color: #fff;
    box-shadow: 0 14px 30px rgba(12, 196, 78, 0.28);
    animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.welcome-banner i { font-size: 2rem; }
.welcome-banner h3 { font-size: 1rem; font-weight: 800; }
.welcome-banner p { font-size: 0.82rem; opacity: 0.9; margin-top: 2px; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.tab-content { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.dash-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 26px 30px;
    margin-bottom: 20px;
    border-radius: 24px;
    background:
        radial-gradient(500px 220px at 85% 50%, rgba(12, 196, 78, 0.22), transparent 65%),
        linear-gradient(135deg, #062a2a 0%, #07263d 100%);
    border: 1px solid rgba(25, 224, 104, 0.28);
    color: #fff;
    box-shadow: var(--shadow);
}

.hero-copy { position: relative; z-index: 1; }
.hero-copy h2 { font-size: 2rem; font-weight: 800; letter-spacing: -0.8px; line-height: 1.15; }
.hero-copy h2 em { font-style: normal; color: #19e068; display: block; }
.hero-copy p { margin-top: 10px; font-size: 0.95rem; color: #b8cde0; max-width: 300px; line-height: 1.5; }
.hero-art { width: 210px; height: auto; flex-shrink: 0; filter: drop-shadow(0 14px 24px rgba(12, 196, 78, 0.25)); }

/* search wrapper in the dashboard is replaced by the topbar search (kept in DOM) */
.search-wrapper { display: none; }

.search-counter {
    display: inline-block;
    margin-bottom: 14px;
    padding: 8px 16px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 0.84rem;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

.search-counter strong { font-weight: 800; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card-title { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.card-title i { font-size: 1.15rem; color: var(--accent-text); }
.card-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.8px; color: var(--text-dark); overflow-wrap: anywhere; }

/* Stat cards (dashboard) */
.grid-dash-totals {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.grid-dash-totals .card {
    --c: var(--c-green);
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
    min-height: 112px;
    padding: 20px 20px 20px 94px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 4px solid var(--c);
}

.grid-dash-totals .card:nth-child(2) { --c: var(--c-blue); }
.grid-dash-totals .card:nth-child(3) { --c: var(--c-orange); }
.grid-dash-totals .card:nth-child(4) { --c: var(--c-purple); }

.grid-dash-totals .card-title { color: var(--c); font-size: 0.92rem; margin-bottom: 6px; }

.grid-dash-totals .card-title i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 17px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c));
    color: #fff;
    font-size: 1.65rem;
    box-shadow: 0 10px 20px color-mix(in srgb, var(--c) 32%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.grid-dash-totals .card-value { font-size: 1.7rem; }

/* decorative wave */
.grid-dash-totals .card::after {
    content: '';
    position: absolute;
    right: 10px;
    bottom: 12px;
    width: 96px;
    height: 34px;
    background: var(--c);
    opacity: 0.55;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 34' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 28c8-2 10-8 18-8s8 6 16 4 10-12 18-12 8 8 16 4 12-14 22-14'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 34' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 28c8-2 10-8 18-8s8 6 16 4 10-12 18-12 8 8 16 4 12-14 22-14'/%3E%3C/svg%3E") center / contain no-repeat;
    pointer-events: none;
}

.theme-dark .grid-dash-totals .card {
    background: linear-gradient(145deg, color-mix(in srgb, var(--c) 16%, var(--bg-card)), var(--bg-card) 70%);
    border-color: color-mix(in srgb, var(--c) 42%, var(--border));
}

/* ---------- Charts ---------- */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-card { margin-bottom: 0; display: flex; flex-direction: column; }

.chart-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.chart-head > div { flex: 1; min-width: 0; }
.chart-icon { order: -1; }
.chart-kicker { display: none; }
.chart-head h3 { font-size: 1.1rem; font-weight: 800; color: var(--text-dark); letter-spacing: -0.3px; }

.chart-icon,
.dashboard-group-title i {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--btn-grad);
    color: #fff;
    font-size: 1.35rem;
    flex-shrink: 0;
    box-shadow: 0 8px 16px rgba(12, 196, 78, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.bar-chart {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
    height: 250px;
    min-height: 250px;
    padding: 6px 4px 0;
    flex: 1 1 auto;
}

.bar-item { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }

.bar-track {
    flex: 1;
    width: 100%;
    max-width: 86px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: 14px;
    background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--border-light) calc(25% - 1px), var(--border-light) 25%);
}

.bar-fill {
    --c: var(--c-green);
    position: relative;
    width: 62%;
    border-radius: 12px 12px 5px 5px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c));
    box-shadow: 0 8px 18px color-mix(in srgb, var(--c) 28%, transparent);
    transition: height 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.bar-item:nth-child(2) .bar-fill { --c: var(--c-blue); }
.bar-item:nth-child(3) .bar-fill { --c: var(--c-orange); }
.bar-item:nth-child(4) .bar-fill { --c: var(--c-purple); }

.bar-fill span {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--text-dark);
}

.bar-item small { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }

.donut-chart {
    --poultry: 0%;
    --livestock: 0%;
    --crypto: 0%;
    width: 190px;
    height: 190px;
    margin: 6px auto 20px;
    border-radius: 50%;
    position: relative;
    background: conic-gradient(
        var(--c-green) 0 var(--poultry),
        var(--c-blue) var(--poultry) var(--livestock),
        var(--c-orange) var(--livestock) var(--crypto),
        var(--c-purple) var(--crypto) 100%
    );
}

.donut-chart.empty { background: var(--border); }

.donut-chart::before {
    content: '';
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: var(--bg-card);
}

.donut-center { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-size: 2rem; font-weight: 800; letter-spacing: -1px; color: var(--text-dark); }
.donut-center span { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }

.chart-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.chart-legend span { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.chart-legend strong { margin-left: auto; color: var(--text-dark); font-weight: 800; }

.legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-green); flex-shrink: 0; }
.dot-1 { background: var(--c-blue); }
.dot-2 { background: var(--c-orange); }
.dot-3 { background: var(--c-purple); }

/* ---------- Quick links (mobile + tablet) ---------- */
.quick-links { display: none; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }

.quick-card {
    --c: var(--c-green);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 18px;
    border: 1px solid color-mix(in srgb, var(--c) 38%, var(--border));
    background: linear-gradient(135deg, color-mix(in srgb, var(--c) 12%, var(--bg-card)), var(--bg-card));
    color: var(--text-dark);
    transition: var(--transition);
    min-width: 0;
}

.quick-card:active { transform: scale(0.97); }
.ql-blue { --c: var(--c-blue); }
.ql-orange { --c: var(--c-orange); }
.ql-purple { --c: var(--c-purple); }

.ql-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c));
    color: #fff;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.ql-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ql-copy strong { font-size: 0.86rem; font-weight: 700; line-height: 1.25; }
.ql-copy small { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.ql-arrow { color: var(--c); font-size: 1rem; flex-shrink: 0; }

/* ---------- Data groups ---------- */
#all-data-container { display: grid; grid-template-columns: 1fr; gap: 20px; }
#all-data-container .card { margin-bottom: 0; min-width: 0; }

.dashboard-group-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: var(--text-dark);
}

/* ============================================================
   FORMS & BUTTONS
   ============================================================ */
.form-group { margin-bottom: 15px; }

label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
}

label i { color: var(--accent-text); font-size: 1.05rem; }

input, select {
    width: 100%;
    height: 50px;
    padding: 11px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-dark);
    font-size: 0.92rem;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(12, 196, 78, 0.16);
}

input::placeholder { color: var(--text-muted); opacity: 0.7; }

input[type="radio"], input[type="checkbox"] {
    width: 20px;
    height: 20px;
    padding: 0;
    flex-shrink: 0;
    accent-color: var(--accent);
    box-shadow: none;
}

input[type="file"] {
    height: auto;
    padding: 10px 12px;
    font-size: 0.85rem;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: 0;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 700;
    cursor: pointer;
}

select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236a7d90' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.btn {
    border: 0;
    border-radius: 15px;
    padding: 14px 22px;
    min-height: 50px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--btn-grad);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 10px 22px rgba(9, 168, 65, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn i { font-size: 1.15rem; }
.btn:hover { filter: brightness(1.05); box-shadow: 0 14px 28px rgba(9, 168, 65, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.24); }
.btn:active { transform: scale(0.98); }

.btn-sm {
    width: auto;
    min-height: 34px;
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 0.78rem;
    box-shadow: none;
}

.btn-sm i { font-size: 0.95rem; }

button, .btn, .nav-links button, .menu-toggle-btn { font-family: inherit; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 20px; }
.grid-3 .card { margin-bottom: 0; }

@media (min-width: 550px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.max-w-md { max-width: 620px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-card);
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 520px; }

th, td { text-align: left; padding: 13px 16px; font-size: 0.85rem; white-space: nowrap; border-bottom: 1px solid var(--border-light); }

th {
    background: var(--table-th-bg);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--table-row-hover); }
td strong { font-weight: 700; color: var(--text-dark); }
td small { font-size: 0.82rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
td small i { color: var(--text-muted); }
th:last-child, td:last-child { text-align: right; }

td button { border-radius: 10px !important; transition: var(--transition); }
td button:hover { background: rgba(239, 68, 68, 0.12) !important; }
td .btn-sm:hover { background: var(--btn-grad) !important; }

.text-green-premium { color: var(--accent-text); font-weight: 700; }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.74rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--c-blue) 14%, transparent);
    color: var(--c-blue);
}

.theme-dark .status-badge { background: color-mix(in srgb, var(--c-blue) 22%, transparent); color: #7db4ff; }
.status-pending { background: color-mix(in srgb, var(--c-orange) 18%, transparent) !important; color: #b77700 !important; }
.theme-dark .status-pending { color: #ffc65c !important; }
.status-refunded { background: color-mix(in srgb, var(--c-green) 16%, transparent) !important; color: var(--accent-text) !important; }

.no-results-msg { text-align: center; padding: 44px 20px; color: var(--text-muted); }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-row {
    padding: 18px;
    margin-bottom: 14px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--accent-soft) 35%, var(--bg-card));
}

.settings-row:last-child { margin-bottom: 0; }

.settings-row h3 { display: flex; align-items: center; gap: 12px; font-size: 0.98rem; font-weight: 800; color: var(--text-dark); margin-bottom: 4px; }

.settings-row h3 i {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--btn-grad);
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 8px 16px rgba(12, 196, 78, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.settings-hint { font-size: 0.82rem; color: var(--text-muted); margin: 8px 0 12px; line-height: 1.5; }

.report-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.report-controls select { flex: 1 1 170px; width: auto; }
.report-controls .btn { flex: 1 1 190px; width: auto; }

.theme-selector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
}

.theme-btn i { font-size: 1.15rem; }
.theme-btn:hover { border-color: var(--accent); }

.theme-btn.active {
    background: var(--btn-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 10px 20px rgba(9, 168, 65, 0.26);
}

#exchange-result { margin-top: 18px; }

#exchange-output {
    padding: 18px;
    border-radius: 16px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--text-dark);
    line-height: 1.9;
    font-size: 0.95rem;
}

/* ============================================================
   RECEIPT PRINT
   ============================================================ */
#receipt-print-area {
    background: white;
    padding: 28px;
    border-radius: 16px;
    margin-top: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    color: #000;
}

#receipt-print-area * { color: #000; }

@media print {
    body * { visibility: hidden; }
    #receipt-print-area, #receipt-print-area * { visibility: visible; }
    #receipt-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 30px;
        background: white;
        color: black;
        border: none;
        box-shadow: none;
    }
}

/* ============================================================
   BOTTOM NAV (mobile only)
   ============================================================ */
.bottom-nav { display: none; }

/* ============================================================
   DESKTOP: permanent sidebar (>= 1100px)
   ============================================================ */
@media (min-width: 1100px) {
    .app-container { padding-left: var(--sidebar-w); }

    aside {
        width: var(--sidebar-w);
        transform: none;
        box-shadow: none;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }

    .sidebar-overlay { display: none; }
    .global-topbar .menu-toggle-btn { display: none; }
    .topbar-profile { display: none; }
    .topbar-clock { display: flex; }
    .dash-hero { display: none; }
    .quick-links { display: none; }
    #app-screen:not([data-tab="dashboard"]) .clock { display: none; }
}

@media (max-width: 1099px) {
    .topbar-clock { display: none; }
    .topbar-logo { display: flex; }
    .global-topbar { padding: 12px 22px; }
    main { padding: 6px 22px 48px; }
    .dash-hero { display: flex; }
    .quick-links { display: grid; }
    .grid-dash-totals { grid-template-columns: repeat(2, 1fr); }
    .dashboard-charts-grid { grid-template-columns: 1fr; }
}

/* Two-column data tables on wide desktops */
@media (min-width: 1500px) {
    #all-data-container { grid-template-columns: 1fr 1fr; }
    #all-data-container .data-group-card[data-group="savings"] { grid-column: 1 / -1; }
}

@media (min-width: 1100px) and (max-width: 1499px) {
    .grid-dash-totals .card::after { display: none; }
}

@media (min-width: 1100px) and (max-width: 1399px) {
    .grid-dash-totals .card { padding-left: 86px; }
    .grid-dash-totals .card-title i { width: 50px; height: 50px; left: 18px; }
    .grid-dash-totals .card-value { font-size: 1.45rem; }
}

/* ============================================================
   TABLET (760 - 1099)
   ============================================================ */
@media (min-width: 761px) and (max-width: 1099px) {
    .dashboard-charts-grid { grid-template-columns: 1.4fr 1fr; }
    .grid-dash-totals { grid-template-columns: repeat(4, 1fr); gap: 12px; }
    .grid-dash-totals .card { padding: 16px; min-height: 0; border-left-width: 1px; border: 1px solid color-mix(in srgb, var(--c) 40%, var(--border)); }
    .grid-dash-totals .card-title { flex-direction: column; align-items: flex-start; gap: 10px; }
    .grid-dash-totals .card-title i { position: static; transform: none; width: 46px; height: 46px; font-size: 1.4rem; }
    .grid-dash-totals .card-value { font-size: 1.35rem; }
    .quick-links { grid-template-columns: repeat(4, 1fr); }
    .quick-card { flex-wrap: wrap; }
    .ql-arrow { display: none; }
}

@media (min-width: 761px) and (max-width: 899px) {
    .dashboard-charts-grid { grid-template-columns: 1fr; }
    .grid-dash-totals { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   MOBILE (<= 760)
   ============================================================ */
@media (max-width: 760px) {
    .global-topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; gap: 8px; }
    .global-topbar .menu-toggle-btn { width: 46px; height: 46px; border-radius: 14px; background: var(--bg-card); color: var(--text-dark); border-color: var(--border); box-shadow: var(--shadow-sm); }
    .topbar-search input { height: 46px; border-radius: 14px; font-size: 0.85rem; padding-left: 42px; }
    .topbar-search > i { left: 14px; font-size: 1.1rem; }
    .topbar-icon-btn { width: 44px; height: 44px; border-radius: 14px; background: transparent; box-shadow: none; border-color: transparent; }
    #theme-toggle-btn { display: none; }
    .topbar-profile { display: flex; }
    .topbar-profile-copy { display: none; }
    .topbar-avatar { width: 42px; height: 42px; }
    .topbar-logo .sm-logo { width: 34px; height: 34px; }
    .topbar-logo .brand-text b { font-size: 1.05rem; }
    .topbar-logo .brand-text small { font-size: 0.6rem; letter-spacing: 4px; }

    main { padding: 4px 14px 120px; }

    .dash-hero { padding: 22px 20px; border-radius: 22px; margin-bottom: 16px; }
    .hero-copy h2 { font-size: 1.7rem; }
    .hero-copy p { font-size: 0.88rem; }
    .hero-art { position: absolute; right: -8px; bottom: 4px; width: 170px; opacity: 0.55; }
    .hero-copy p { max-width: 62%; }

    .grid-dash-totals { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

    .grid-dash-totals .card {
        padding: 14px 14px 16px;
        min-height: 150px;
        justify-content: flex-start;
        border-left-width: 1px;
        border: 1px solid color-mix(in srgb, var(--c) 40%, var(--border));
        background: linear-gradient(160deg, var(--bg-card) 40%, color-mix(in srgb, var(--c) 10%, var(--bg-card)));
    }

    .grid-dash-totals .card-title { flex-direction: column; align-items: flex-start; gap: 10px; font-size: 0.82rem; }
    .grid-dash-totals .card-title i { position: static; transform: none; width: 44px; height: 44px; border-radius: 14px; font-size: 1.35rem; }
    .grid-dash-totals .card-value { font-size: 1.35rem; }
    .grid-dash-totals .card::after { right: 6px; bottom: 6px; width: 70px; height: 26px; opacity: 0.6; }

    .dashboard-charts-grid { gap: 14px; margin-bottom: 16px; }
    .card { padding: 16px; border-radius: 22px; margin-bottom: 14px; }
    .chart-head { gap: 12px; }
    .chart-icon, .dashboard-group-title i { width: 40px; height: 40px; font-size: 1.2rem; border-radius: 13px; }
    .bar-chart { height: 210px; min-height: 210px; gap: 12px; }
    .donut-chart { width: 168px; height: 168px; }

    .quick-links { grid-template-columns: 1fr 1fr; gap: 10px; }
    .quick-card { padding: 12px; }
    .ql-icon { width: 42px; height: 42px; }

    #all-data-container { gap: 14px; }
    .dashboard-group-title { font-size: 0.98rem; gap: 12px; }

    header { margin: 10px 0 16px; }
    header h1 { font-size: 1.25rem; gap: 10px; }
    header h1 i { width: 40px; height: 40px; font-size: 1.25rem; }
    .clock { padding: 7px 12px; font-size: 0.72rem; }

    .settings-row { padding: 14px; }
    .theme-selector-grid { grid-template-columns: 1fr; }
    .report-controls { flex-direction: column; align-items: stretch; }
    .report-controls select, .report-controls .cs, .report-controls .btn { flex: 1 1 auto; width: 100%; }

    #toast-host { top: 12px; left: 12px; right: 12px; align-items: stretch; }
    .toast { min-width: 0; max-width: none; }

    .welcome-banner { padding: 14px 16px; }

    /* Bottom navigation */
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
        display: grid;
        grid-template-columns: 1fr 1fr 78px 1fr 1fr;
        align-items: center;
        height: calc(74px + env(safe-area-inset-bottom, 0px));
        padding: 6px 8px env(safe-area-inset-bottom, 0px);
        background: var(--nav-bg);
        border-top: 1px solid var(--border);
        border-radius: 26px 26px 0 0;
        box-shadow: 0 -12px 34px rgba(5, 20, 35, 0.14);
    }

    .bottom-nav button {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        height: 100%;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.7rem;
        font-weight: 600;
        cursor: pointer;
        transition: var(--transition);
    }

    .bottom-nav button i { font-size: 1.6rem; }
    .bottom-nav button.active { color: var(--accent-text); }

    .bottom-nav button.active::after {
        content: '';
        position: absolute;
        bottom: 2px;
        width: 40px;
        height: 3px;
        border-radius: 3px;
        background: var(--accent);
    }

    .bottom-nav .bn-fab {
        width: 62px;
        height: 62px;
        margin: -30px auto 0;
        border-radius: 50%;
        background: var(--btn-grad);
        color: #fff;
        border: 5px solid var(--bg-main);
        box-shadow: 0 12px 26px rgba(9, 168, 65, 0.45);
        height: 62px;
    }

    .bottom-nav .bn-fab i { font-size: 1.9rem; }
    .bottom-nav .bn-fab:active { transform: scale(0.92); }
}

@media (max-width: 400px) {
    .topbar-logo .brand-text { display: none; }
    .hero-copy h2 { font-size: 1.5rem; }
    .grid-dash-totals .card-value { font-size: 1.2rem; }
    .quick-card .ql-copy small { display: none; }
}

@media (max-width: 340px) {
    .grid-dash-totals, .quick-links { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* wider settings card so the staff and activity tables fit */
#tab-settings .max-w-md { max-width: 980px; }


/* ============================================================
   MODERN DROPDOWN (option inputs) - built by select-ui.js
   ============================================================ */
.cs { position: relative; width: 100%; min-width: 0; }
.cs > select.cs-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; padding: 0; border: 0; }

.cs-btn {
    width: 100%; height: 50px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 0 14px 0 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-dark);
    font-family: inherit; font-size: 0.92rem; font-weight: 600; text-align: left;
    cursor: pointer;
    transition: var(--transition);
}
.cs-btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.cs-btn:focus-visible, .cs.open .cs-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(12, 196, 78, 0.16); }
.cs-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-label.cs-placeholder { color: var(--text-muted); font-weight: 500; }
.cs-caret {
    flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center;
    border-radius: 50%; font-size: .8rem; color: var(--accent-text);
    background: var(--accent-soft);
    transition: transform .25s cubic-bezier(.16, 1, .3, 1);
}
.cs.open .cs-caret { transform: rotate(180deg); }
.cs-disabled .cs-btn { opacity: .55; cursor: not-allowed; }

/* inside the login card (icon on the left) */
.field .cs-btn { padding-left: 46px; height: 54px; border-radius: 16px; border: 1.5px solid #dbe7e1; background: #fff; color: #0a2540; }
.field .cs-btn:focus-visible, .field .cs.open .cs-btn { border-color: #12b85a; box-shadow: 0 0 0 4px rgba(18, 184, 90, .15); }
.select-field .cs-btn { border-color: #66dba0; background: #f1fbf5; font-weight: 700; }
.field .cs-caret { background: #e5f9ec; color: #0aa84a; }

.report-controls .cs { flex: 1 1 170px; width: auto; }

.cs-menu {
    position: fixed; z-index: 9500;
    overflow-y: auto; overscroll-behavior: contain;
    padding: 6px;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 22px 50px rgba(4, 20, 35, .22), 0 4px 12px rgba(4, 20, 35, .08);
    opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top center;
    transition: opacity .16s ease, transform .2s cubic-bezier(.16, 1, .3, 1);
}
.cs-menu.show { opacity: 1; transform: none; }
.cs-menu.cs-light { --bg-card: #fff; --border: #dbe7e1; --text-main: #16324f; --text-dark: #0a2540; --accent-soft: #e5f9ec; --accent-text: #08a244; }
.cs-opt {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 12px; border-radius: 11px;
    font-size: .9rem; font-weight: 600; color: var(--text-main);
    cursor: pointer; transition: background .12s, color .12s;
}
.cs-opt i { opacity: 0; font-size: .95rem; color: var(--accent-text); }
.cs-opt:hover, .cs-opt.focus { background: var(--accent-soft); color: var(--accent-text); }
.cs-opt.selected { background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.cs-opt.selected i { opacity: 1; }
.cs-opt.disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   FIXED TABLES - the table keeps its size and scrolls inside
   (header stays pinned) however long the data gets
   ============================================================ */
.table-responsive {
    max-height: clamp(260px, 58vh, 540px);
    overflow: auto;
    overscroll-behavior: contain;
}
.table-responsive thead th { position: sticky; top: 0; z-index: 2; background: var(--table-th-bg); box-shadow: 0 1px 0 var(--border); }
.table-responsive::-webkit-scrollbar { width: 7px; height: 7px; }
.table-fixed.audit-fixed { max-height: 420px; }
.audit-fixed td:first-child { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
    .ld-orbit, .ld-ico i, .ld-ring-arc, .ld-glow, .ld-bg, .ld-dots i { animation: none !important; }
}
