/* ==========================================================================
   FACTORY MANAGER — "Ledger" premium theme
   A premium, professional Cash Book / accounting look: soft 3D elevation,
   subtle gradients, smooth micro-interactions. Same class names as before —
   this file only changes how things look, not what the app does.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    /* ---- accent (deep indigo, premium finance feel) ---- */
    --primary:#4f46e5;
    --primary-2:#6366f1;
    --primary-dark:#3730a3;
    --primary-light:#eef0ff;
    --primary-rgb:79,70,229;

    /* ---- neutrals ---- */
    --bg:#eef1f7;
    --paper:#ffffff;
    --border:#e4e8f1;
    --border-soft:#eef1f7;

    /* ---- sidebar (deep navy glass) ---- */
    --side-bg-1:#131a33;
    --side-bg-2:#1c2748;
    --side-active-bg:rgba(99,102,241,0.22);
    --side-text:#aab2cf;
    --side-text-active:#ffffff;

    /* ---- status ---- */
    --success-700:#0f7a3d;
    --success-600:#12a350;
    --success-bg:#e6f8ee;
    --danger-700:#c0221f;
    --danger-600:#e0342f;
    --danger-bg:#fdecec;
    --warn-700:#b25f06;
    --warn-bg:#fef3e0;
    --info-700:#1d4ed8;
    --info-bg:#eaf1ff;

    /* ---- ink ---- */
    --ink-900:#111629;
    --ink-700:#3a4159;
    --ink-600:#5a6280;
    --ink-400:#9aa1bb;

    /* ---- elevation: layered "physical" shadows ---- */
    --e1: 0 1px 2px rgba(17,22,41,0.05), 0 1px 1px rgba(17,22,41,0.04);
    --e2: 0 2px 4px rgba(17,22,41,0.05), 0 8px 20px -6px rgba(17,22,41,0.10);
    --e3: 0 4px 10px rgba(17,22,41,0.06), 0 16px 34px -10px rgba(17,22,41,0.16);
    --e4: 0 8px 18px rgba(17,22,41,0.08), 0 26px 54px -16px rgba(17,22,41,0.22);
    --e-inset: inset 0 1px 2px rgba(17,22,41,0.05);
    --e-press: inset 0 2px 4px rgba(17,22,41,0.12);

    --r-sm:8px; --r-md:12px; --r-lg:16px; --r-xl:20px;
    --ease: cubic-bezier(.22,1,.36,1);
    --ease-out: cubic-bezier(.16,1,.3,1);
    --dur-1: 160ms; --dur-2: 260ms; --dur-3: 380ms;
}

* { margin:0; padding:0; box-sizing:border-box; }

html { scroll-behavior:smooth; }

body {
    font-family:'Inter','Segoe UI',Arial,sans-serif;
    background:var(--bg);
    background-image:
        radial-gradient(900px 500px at 100% -10%, rgba(99,102,241,0.07), transparent 60%),
        radial-gradient(700px 400px at -10% 110%, rgba(79,70,229,0.05), transparent 55%);
    background-attachment:fixed;
    color:var(--ink-900);
    -webkit-font-smoothing:antialiased;
    font-size:14px;
    opacity:0;
    animation: bodyIn var(--dur-3) var(--ease-out) forwards;
}

@keyframes bodyIn { from{ opacity:0; transform:translateY(6px);} to{ opacity:1; transform:none; } }

/* perceived page-exit transition, toggled by ui.js before internal navigation */
body.page-exit { animation: bodyOut 150ms var(--ease) forwards; }
@keyframes bodyOut { to{ opacity:0; transform:translateY(-4px); } }

::-webkit-scrollbar { width:10px; height:10px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:#c7cce0; border-radius:20px; border:2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background:#aab0cf; }

h1, h2, h3, .display {
    font-family:'Inter',sans-serif;
    font-weight:700;
    letter-spacing:-0.2px;
    color:var(--ink-900);
}

.mono, table td.num, .value {
    font-variant-numeric: tabular-nums;
    font-feature-settings:"tnum";
}

a { color:inherit; }
:focus-visible { outline:2px solid var(--primary); outline-offset:2px; border-radius:4px; }

/* ---------- Auth pages (login / register / super-admin) ---------- */
.auth-wrap {
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    position:relative;
    overflow:hidden;
    background:
        radial-gradient(1100px 600px at 12% -5%, #dfe4ff 0%, transparent 50%),
        radial-gradient(900px 600px at 90% 105%, #e3e8ff 0%, transparent 50%),
        linear-gradient(180deg, #f3f5fb, var(--bg));
}

.auth-wrap::before, .auth-wrap::after {
    content:'';
    position:absolute;
    width:420px; height:420px;
    border-radius:50%;
    filter:blur(10px);
    opacity:0.35;
    background:conic-gradient(from 180deg, #6366f1, #a5b4fc, #4f46e5, #6366f1);
    animation: floatBlob 14s ease-in-out infinite;
    z-index:0;
}
.auth-wrap::before { top:-160px; left:-140px; }
.auth-wrap::after { bottom:-180px; right:-150px; animation-delay:-6s; }
@keyframes floatBlob {
    0%,100% { transform:translate(0,0) scale(1); }
    50% { transform:translate(20px,-24px) scale(1.06); }
}

.auth-box, .box {
    background:var(--paper);
    padding:38px 40px;
    border-radius:var(--r-xl);
    width:100%;
    max-width:420px;
    box-shadow: var(--e4), 0 0 0 1px rgba(17,22,41,0.03);
    border:1px solid rgba(255,255,255,0.6);
    position:relative;
    margin:0 auto;
    z-index:1;
    animation: cardRise var(--dur-3) var(--ease-out) both;
}

@keyframes cardRise {
    from { opacity:0; transform:translateY(18px) scale(.98); }
    to { opacity:1; transform:none; }
}

.logo-mark {
    width:46px; height:46px;
    border-radius:var(--r-md);
    background:linear-gradient(150deg, var(--primary-2), var(--primary) 60%, var(--primary-dark));
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    font-size:19px;
    margin-bottom:18px;
    box-shadow: 0 6px 14px -4px rgba(var(--primary-rgb),0.55), inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -6px 10px rgba(0,0,0,0.12);
}

.eyebrow {
    font-size:11.5px;
    letter-spacing:0.6px;
    text-transform:uppercase;
    color:var(--primary);
    margin-bottom:8px;
    display:block;
    font-weight:700;
}

.auth-box h2, .box h2 {
    margin-bottom:6px;
    color:var(--ink-900);
    font-size:24px;
    font-weight:800;
    letter-spacing:-0.3px;
}

.auth-box p.sub, .box .sub, .sub {
    color:var(--ink-600);
    margin-bottom:22px;
    font-size:14px;
}

.auth-box label, .box label, label {
    display:block;
    margin:16px 0 6px;
    font-size:12.5px;
    font-weight:600;
    color:var(--ink-700);
}

.auth-box input,
.auth-box select,
.box input,
.box select,
input[type=text], input[type=email], input[type=password] {
    width:100%;
    padding:11px 13px;
    border:1px solid var(--border);
    border-radius:var(--r-sm);
    font-size:14px;
    font-family:'Inter',sans-serif;
    background:#f8f9fd;
    color:var(--ink-900);
    outline:none;
    box-shadow: var(--e-inset);
    transition: border var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1);
}

.auth-box input:focus,
.auth-box select:focus,
.box input:focus,
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus {
    border-color: var(--primary);
    background:#fff;
    box-shadow: 0 0 0 4px var(--primary-light), var(--e-inset);
}

.auth-box input::placeholder, .box input::placeholder { color:#a3aab7; }

.auth-box button, .box .btn, .box button {
    width:100%;
    margin-top:22px;
    padding:12px;
    background: linear-gradient(155deg, var(--primary-2), var(--primary) 65%, var(--primary-dark));
    color:#fff;
    border:none;
    border-radius:var(--r-sm);
    font-size:14.5px;
    font-weight:700;
    cursor:pointer;
    text-align:center;
    text-decoration:none;
    display:block;
    position:relative;
    overflow:hidden;
    box-shadow: 0 8px 18px -6px rgba(var(--primary-rgb),0.55), inset 0 1px 0 rgba(255,255,255,0.25);
    transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), filter var(--dur-1);
}

.auth-box button:hover, .box .btn:hover { filter:brightness(1.06); transform:translateY(-1px); box-shadow: 0 12px 24px -8px rgba(var(--primary-rgb),0.6), inset 0 1px 0 rgba(255,255,255,0.25); }
.auth-box button:active, .box .btn:active { transform: translateY(1px) scale(.99); box-shadow: var(--e-press); }

.auth-box .switch, .box .switch, .switch {
    text-align:center;
    margin-top:18px;
    font-size:13.5px;
    color: var(--ink-600);
}

.auth-box .switch a, .box .switch a, .switch a { color: var(--primary); text-decoration:none; font-weight:600; transition:color var(--dur-1); }
.auth-box .switch a:hover, .switch a:hover { text-decoration: underline; color:var(--primary-dark); }

.error-msg, .box .error, .error {
    background: var(--danger-bg);
    color: var(--danger-700);
    padding:10px 12px;
    border-radius:var(--r-sm);
    font-size:13px;
    margin-bottom:12px;
    border: 1px solid #f6d3d0;
    animation: shake .4s var(--ease);
}
@keyframes shake { 15%,45%,75%{transform:translateX(-4px);} 30%,60%,90%{transform:translateX(4px);} 100%{transform:none;} }

.success-msg, .box .success, .success {
    background: var(--success-bg);
    color: var(--success-700);
    padding:10px 12px;
    border-radius:var(--r-sm);
    font-size:13px;
    margin-bottom:12px;
    border: 1px solid #cdeddb;
    animation: cardRise var(--dur-2) var(--ease-out);
}

/* OTP boxes */
.otp-row{ display:flex; gap:8px; margin-top:6px; }
.otp-row input{
    width:46px; height:52px; text-align:center; font-size:21px; font-weight:700;
    border:1px solid var(--border); border-radius:var(--r-sm); background:#f8f9fd; color:var(--ink-900); outline:none; padding:0;
    box-shadow: var(--e-inset);
}
.otp-row input:focus{ border-color:var(--primary); box-shadow:0 0 0 4px var(--primary-light), var(--e-inset); }
.email-show{ color:var(--primary); font-weight:700; }
.timer{ color:var(--ink-400); font-size:12px; margin-top:10px; text-align:center; }
.back{ background:none; border:none; color:var(--primary); font-size:13.5px; cursor:pointer; margin-top:14px; display:block; text-align:center; width:100%; text-decoration:none; transition:color var(--dur-1); }
.back:hover{ text-decoration:underline; color:var(--primary-dark); }
.trial-badge{
    background: linear-gradient(135deg, var(--primary-light), #e3e7ff); border:1px solid #cfe0fb; color: var(--primary-dark);
    padding:10px 14px; border-radius:var(--r-sm); font-size:13px; margin-bottom:18px; text-align:center; font-weight:600;
    box-shadow: var(--e1);
}
.done-icon{ font-size:38px; text-align:center; margin-bottom:14px; filter:drop-shadow(0 6px 10px rgba(var(--primary-rgb),.3)); }
.badge{ display:inline-block; background:var(--danger-bg); color:var(--danger-700); border:1px solid #f6d3d0; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:700; margin-bottom:20px; }

/* ---------- App layout ---------- */
.topbar {
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(10px) saturate(1.4);
    -webkit-backdrop-filter: blur(10px) saturate(1.4);
    color:var(--ink-900);
    padding:0 20px;
    height:60px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    position:sticky;
    top:0;
    z-index:100;
    border-bottom:1px solid var(--border);
    box-shadow: 0 1px 0 rgba(17,22,41,0.02), 0 8px 24px -18px rgba(17,22,41,0.3);
    transition: box-shadow var(--dur-2);
}

.topbar-left { display:flex; align-items:center; gap:12px; }
.topbar-left .mark {
    width:32px; height:32px;
    background:linear-gradient(150deg, var(--primary-2), var(--primary) 60%, var(--primary-dark));
    border-radius:var(--r-sm);
    display:flex; align-items:center; justify-content:center;
    font-weight:800;
    font-size:14px;
    color:#fff;
    flex-shrink:0;
    box-shadow: 0 4px 10px -2px rgba(var(--primary-rgb),0.55), inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -4px 8px rgba(0,0,0,0.14);
}
.topbar-left strong {
    font-size:15.5px;
    font-weight:700;
    letter-spacing:-0.1px;
    color:var(--ink-900);
}
.topbar-right { display:flex; align-items:center; gap:16px; font-size:13.5px; color:var(--ink-600); }
.btn-logout {
    color:var(--ink-700);
    background: #fff;
    border:1px solid var(--border);
    padding:7px 14px;
    border-radius:var(--r-sm);
    text-decoration:none;
    font-weight: 600;
    font-size:13px;
    box-shadow: var(--e1);
    transition: border-color var(--dur-1), background var(--dur-1), color var(--dur-1), box-shadow var(--dur-1), transform var(--dur-1);
}
.btn-logout:hover { border-color:var(--primary); background: var(--primary-light); color:var(--primary-dark); box-shadow: var(--e2); transform:translateY(-1px); }
.btn-logout:active { transform:translateY(0); box-shadow:var(--e-press); }
.hamburger { display:none; cursor:pointer; font-size:20px; color:var(--ink-700); transition:transform var(--dur-1) var(--ease); border-radius:8px; padding:4px 6px; }
.hamburger:active { transform:scale(0.85); }

.layout { display:flex; min-height:calc(100vh - 60px); }
.sidebar {
    width:236px;
    background:
        radial-gradient(500px 260px at 0% 0%, rgba(99,102,241,0.35), transparent 60%),
        linear-gradient(190deg, var(--side-bg-2), var(--side-bg-1) 70%);
    padding:18px 0;
    flex-shrink:0;
    position:sticky;
    top:60px;
    height:calc(100vh - 60px);
    overflow-y:auto;
    box-shadow: 4px 0 24px -14px rgba(17,22,41,0.35);
    transition: left var(--dur-2) var(--ease);
}

.nav-section {
    font-size:10.5px;
    letter-spacing:1px;
    text-transform:uppercase;
    color:#7a83ab;
    font-weight:700;
    padding:20px 22px 8px;
}
.sidebar a:first-child + .nav-section { padding-top:16px; }

.sidebar a {
    display:flex;
    align-items:center;
    gap:11px;
    padding:10px 20px;
    margin:2px 10px;
    color:var(--side-text);
    text-decoration:none;
    font-size:13.5px;
    font-weight:500;
    border-radius:10px;
    position:relative;
    transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.sidebar a::before {
    font-size:15px;
    line-height:1;
    width:18px;
    text-align:center;
    flex-shrink:0;
    opacity:0.9;
}
.sidebar a[href="dashboard.php"]::before   { content:"\1F4CA"; }
.sidebar a[href="cashbook.php"]::before    { content:"\1F4B0"; }
.sidebar a[href="expenses.php"]::before    { content:"\1F9FE"; }
.sidebar a[href="billing.php"]::before     { content:"\1F4C4"; }
.sidebar a[href="rate_master.php"]::before { content:"\1F4B2"; }
.sidebar a[href="parties.php"]::before     { content:"\1F465"; }
.sidebar a[href="ledger.php"]::before      { content:"\1F4D2"; }
.sidebar a[href="payroll.php"]::before     { content:"\1F465"; }
.sidebar a[href="advances.php"]::before    { content:"\1F4B8"; }
.sidebar a[href="attendance.php"]::before  { content:"\1F5D3"; }
.sidebar a[href="leaves.php"]::before      { content:"\1F3D6"; }
.sidebar a[href="workers.php"]::before     { content:"\1F477"; }
.sidebar a[href="production.php"]::before  { content:"\1F3ED"; }
.sidebar a[href="inventory.php"]::before   { content:"\1F4E6"; }
.sidebar a[href="reports.php"]::before     { content:"\1F4C8"; }
.sidebar a[href="users.php"]::before       { content:"\1F511"; }

.sidebar a:hover { background:rgba(255,255,255,0.06); color:#fff; transform:translateX(2px); }

.sidebar a.active {
    background: linear-gradient(90deg, var(--side-active-bg), rgba(99,102,241,0.08));
    color:var(--side-text-active);
    font-weight:700;
    box-shadow: inset 3px 0 0 var(--primary-2), var(--e2);
}

.content { flex:1; padding:28px; overflow-x:auto; min-width:0; }
.content > * { animation: fadeInUp var(--dur-3) var(--ease-out) both; }

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

.page-title {
    font-size:22px;
    margin-bottom:22px;
    color:var(--ink-900);
    display:flex;
    align-items:baseline;
    gap:10px;
    font-weight:800;
}
.page-title .eyebrow {
    margin-bottom:0;
}

/* ---------- Cards / stats ---------- */
.stats-grid {
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(190px,1fr));
    gap:18px;
    margin-bottom:28px;
}

.stat-card {
    background:linear-gradient(180deg, #ffffff, #fbfbfe);
    padding:19px 21px;
    border-radius:var(--r-lg);
    border:1px solid var(--border);
    position:relative;
    overflow:hidden;
    box-shadow: var(--e2);
    transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
    animation: fadeInUp var(--dur-3) var(--ease-out) both;
}
.stats-grid .stat-card:nth-child(1){animation-delay:.02s}
.stats-grid .stat-card:nth-child(2){animation-delay:.07s}
.stats-grid .stat-card:nth-child(3){animation-delay:.12s}
.stats-grid .stat-card:nth-child(4){animation-delay:.17s}
.stats-grid .stat-card:nth-child(5){animation-delay:.22s}
.stats-grid .stat-card:nth-child(6){animation-delay:.27s}

.stat-card::before {
    content:'';
    position:absolute; inset:0 0 auto 0; height:3px;
    background:linear-gradient(90deg, var(--primary-2), var(--primary));
    opacity:0.85;
}
.stat-card.green::before { background:linear-gradient(90deg, #22c55e, var(--success-600)); }
.stat-card.red::before   { background:linear-gradient(90deg, #f87171, var(--danger-600)); }
.stat-card.blue::before  { background:linear-gradient(90deg, #60a5fa, var(--info-700)); }

.stat-card:hover { transform:translateY(-4px); box-shadow: var(--e4); }

.stat-card .label {
    font-size:12px;
    color:var(--ink-400);
    font-weight:600;
    letter-spacing:0.2px;
}
.stat-card .value {
    font-size:27px;
    font-weight:800;
    margin-top:9px;
    color:var(--ink-900);
    letter-spacing:-0.4px;
}
.stat-card.green .value { color:var(--success-700); }
.stat-card.red .value { color:var(--danger-700); }
.stat-card.blue .value { color:var(--info-700); }

/* ---------- Forms & tables ---------- */
.card {
    background:var(--paper);
    padding:22px;
    border-radius:var(--r-lg);
    border:1px solid var(--border);
    margin-bottom:22px;
    box-shadow: var(--e2);
    transition: box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.card:hover { box-shadow: var(--e3); }

.content > .card:nth-of-type(1){animation-delay:.05s}
.content > .card:nth-of-type(2){animation-delay:.10s}
.content > .card:nth-of-type(3){animation-delay:.15s}
.content > .card:nth-of-type(4){animation-delay:.20s}

.card h3 {
    margin-bottom:16px;
    font-size:15px;
    font-weight: 700;
    color: var(--ink-900);
    padding-bottom:12px;
    border-bottom:1px solid var(--border-soft);
    display:flex;
    align-items:center;
    gap:8px;
}

.form-row { display:flex; gap:14px; flex-wrap:wrap; margin-bottom:15px; }
.form-row .field { flex:1; min-width:150px; }

.field label {
    display:block;
    font-size:12.5px;
    font-weight:600;
    margin-bottom:5px;
    color:var(--ink-700);
}

.field input,
.field select,
.field textarea {
    width:100%;
    padding:10px 12px;
    border:1px solid var(--border);
    border-radius:var(--r-sm);
    font-size:14px;
    font-family:'Inter',sans-serif;
    color: var(--ink-900);
    background:#f8f9fd;
    outline: none;
    box-shadow: var(--e-inset);
    transition: border var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1), transform var(--dur-1);
}

.field input:hover, .field select:hover, .field textarea:hover { border-color:#c7cce0; }

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--primary); background:#fff; box-shadow:0 0 0 4px var(--primary-light), var(--e-inset); }

.btn {
    padding:10.5px 19px;
    background:linear-gradient(155deg, var(--primary-2), var(--primary) 65%, var(--primary-dark));
    color:#fff;
    border:none;
    border-radius:var(--r-sm);
    font-size:13.5px;
    font-weight:600;
    cursor:pointer;
    text-decoration:none;
    display:inline-block;
    position:relative;
    overflow:hidden;
    isolation:isolate;
    box-shadow: 0 6px 14px -5px rgba(var(--primary-rgb),0.55), inset 0 1px 0 rgba(255,255,255,0.22);
    transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), filter var(--dur-1);
}

.btn:hover { filter:brightness(1.06); transform:translateY(-1.5px); box-shadow: 0 10px 20px -6px rgba(var(--primary-rgb),0.6), inset 0 1px 0 rgba(255,255,255,0.22); }
.btn:active { transform:translateY(1px) scale(.98); box-shadow: var(--e-press); filter:none; }

/* ripple element injected by ui.js on click */
.btn .ripple, .btn-outline .ripple, .btn-logout .ripple {
    position:absolute;
    border-radius:50%;
    transform:scale(0);
    background:rgba(255,255,255,0.55);
    pointer-events:none;
    animation: rippleAnim 550ms var(--ease-out);
    z-index:-1;
}
@keyframes rippleAnim { to { transform:scale(2.6); opacity:0; } }

.btn-sm { padding:6.5px 12px; font-size:12px; border-radius:7px; box-shadow: 0 3px 8px -3px rgba(var(--primary-rgb),0.5); }
.btn-red { background:linear-gradient(155deg, var(--danger-600), var(--danger-700)); box-shadow: 0 6px 14px -5px rgba(192,34,31,0.5), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn-red:hover { box-shadow: 0 10px 20px -6px rgba(192,34,31,0.55), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn-green { background:linear-gradient(155deg, var(--success-600), var(--success-700)); box-shadow: 0 6px 14px -5px rgba(15,122,61,0.5), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn-green:hover { box-shadow: 0 10px 20px -6px rgba(15,122,61,0.55), inset 0 1px 0 rgba(255,255,255,0.2); }

table { width:100%; border-collapse:separate; border-spacing:0; font-size:13.5px; }
table th, table td { padding:12px 13px; text-align:left; border-bottom:1px solid var(--border-soft); }
table th {
    background:linear-gradient(180deg, #f8f9fd, #f2f4fa);
    color:var(--ink-600);
    font-weight:700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    position:sticky;
    top:0;
}
table tr:first-child th:first-child { border-top-left-radius:var(--r-md); }
table tr:first-child th:last-child { border-top-right-radius:var(--r-md); }
table tbody tr { transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
table tbody tr:hover { background:#f8f9fe; }
table tbody tr:last-child td { border-bottom:none; }

table td { color: var(--ink-900); }
table td.num, table td.mono { font-variant-numeric:tabular-nums; }

.tag {
    padding:4px 11px;
    border-radius:20px;
    font-size:11px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:0.3px;
    box-shadow: var(--e1);
    display:inline-block;
}

.tag.in, .tag.paid, .tag.present { background:linear-gradient(135deg, var(--success-bg), #d8f5e4); color:var(--success-700); }
.tag.out, .tag.unpaid, .tag.absent { background:linear-gradient(135deg, var(--danger-bg), #fbdcdb); color:var(--danger-700); }
.tag.half { background:linear-gradient(135deg, var(--warn-bg), #fbe7c4); color:var(--warn-700); }

/* light-background banner, for use inside .content (dashboard/module pages) */
.banner {
    padding:13px 17px;
    border-radius:var(--r-sm);
    font-size:13.5px;
    margin-bottom:22px;
    border-left:3px solid;
    box-shadow: var(--e1);
    animation: fadeInUp var(--dur-2) var(--ease-out);
}
.banner.warn { background:var(--warn-bg); color:var(--warn-700); border-color:var(--warn-700); }
.banner.danger { background:var(--danger-bg); color:var(--danger-700); border-color:var(--danger-700); }
.banner.success { background:var(--success-bg); color:var(--success-700); border-color:var(--success-700); }
.banner.info { background:var(--info-bg); color:var(--info-700); border-color:var(--info-700); }

/* ---------- Responsive + Mobile Next-Level ---------- */
@media (max-width: 768px) {
    .hamburger { display:flex; align-items:center; justify-content:center; min-width:44px; min-height:44px; font-size:22px; }
    .sidebar {
        position:fixed;
        left:-280px;
        top:0;
        bottom:0;
        width:280px;
        height:100vh;
        height:100dvh;
        padding-top:70px;
        transition:left var(--dur-2) var(--ease);
        z-index:200;
        box-shadow: 8px 0 40px rgba(17,22,41,0.35);
    }
    .sidebar.open { left:0; }
    .content {
        padding:14px 12px 88px; /* space for bottom nav */
        width:100%;
    }
    .form-row { flex-direction:column; gap:10px; }
    .auth-box, .box { padding: 22px 16px; border-radius: var(--r-lg); }
    .topbar {
        padding: 0 10px;
        height: 56px;
        position: sticky;
        top: 0;
        z-index: 150;
    }
    .topbar-left strong { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-right span { display: none; } /* hide username on small screens */
    .btn-logout { padding: 8px 12px; font-size: 12px; min-height: 40px; }

    /* Stats grid: 2 columns on mobile */
    .stats { grid-template-columns: 1fr 1fr !important; gap: 10px; }
    .stat-card { padding: 14px 12px; }
    .stat-card .value { font-size: 20px; }
    .stat-card .label { font-size: 11px; }

    /* Touch-friendly buttons */
    .btn, button.btn, a.btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 14px;
        touch-action: manipulation;
    }
    .btn-sm { min-height: 36px; padding: 6px 12px; font-size: 12px; }

    /* Forms: larger inputs, no iOS zoom */
    input, select, textarea {
        font-size: 16px !important;
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 10px;
    }
    label { font-size: 13px; margin-bottom: 6px; }

    /* Tables: horizontal scroll + card-ish feel */
    .table-wrap, table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--r-md);
    }
    table { min-width: 520px; }
    table th, table td { padding: 10px 10px; font-size: 13px; white-space: nowrap; }

    /* Page title + actions stack */
    .page-head, .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .page-head .btn, .page-header .btn { width: 100%; justify-content: center; }

    /* Quick actions on dashboard */
    .quick-actions, .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .quick-actions .btn, .actions .btn { width: 100%; text-align: center; justify-content: center; }

    /* Tabs */
    .tabs, .tab-bar {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .tabs .btn, .tab-bar .btn { flex-shrink: 0; }

    /* Bottom navigation bar */
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: 64px;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255,255,255,0.92);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 24px rgba(17,22,41,0.08);
        z-index: 180;
        justify-content: space-around;
        align-items: stretch;
    }
    .bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: var(--ink-600);
        font-size: 10px;
        font-weight: 600;
        padding: 6px 2px;
        min-height: 44px;
        transition: color var(--dur-1) var(--ease);
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav a .bn-icon { font-size: 20px; line-height: 1; }
    .bottom-nav a.active {
        color: var(--primary);
    }
    .bottom-nav a.active .bn-icon {
        transform: scale(1.08);
    }
    .bottom-nav a:active { opacity: 0.7; }

    /* Sidebar overlay full height under topbar */
    .sidebar-overlay {
        inset: 0;
        z-index: 190;
    }
}

/* Desktop: hide bottom nav */
@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
}

/* Extra small phones */
@media (max-width: 380px) {
    .stats { grid-template-columns: 1fr !important; }
    .quick-actions, .actions { grid-template-columns: 1fr; }
    .bottom-nav a { font-size: 9px; }
    .bottom-nav a .bn-icon { font-size: 18px; }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    body { padding-bottom: 0; }
}

/* dim overlay behind an open mobile sidebar, added/removed by ui.js */
.sidebar-overlay {
    display:none;
    position:fixed; inset:0;
    background:rgba(10,13,28,0.45);
    z-index:190;
    animation: fadeInUp var(--dur-1) var(--ease-out);
}
@media (max-width:768px) {
    .sidebar-overlay.show { display:block; }
}

.btn-outline {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--border);
    box-shadow: var(--e1);
}
.btn-outline:hover { background: var(--primary-light); border-color:var(--primary); transform:translateY(-1.5px); box-shadow:var(--e2); }
.btn-outline:active { transform:translateY(1px); box-shadow:var(--e-press); }

/* Mobile-first utility */
.touch-target { min-width: 44px; min-height: 44px; }
.hide-mobile { }
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}
.show-mobile { display: none !important; }
@media (max-width: 768px) {
    .show-mobile { display: block !important; }
    .show-mobile-flex { display: flex !important; }
}

/* Sticky form actions on mobile */
@media (max-width: 768px) {
    .form-actions-sticky {
        position: sticky;
        bottom: 72px;
        background: var(--paper);
        padding: 12px;
        margin: 0 -12px -12px;
        border-top: 1px solid var(--border);
        display: flex;
        gap: 10px;
        z-index: 50;
        box-shadow: 0 -4px 16px rgba(17,22,41,0.06);
    }
    .form-actions-sticky .btn { flex: 1; }
}

/* ==========================================================================
   CASHBOOK-STYLE SIMPLE ENTRY (Play Store feel)
   ========================================================================== */

.cb-hero {
    background: linear-gradient(160deg, #1c2748 0%, #131a33 100%);
    border-radius: var(--r-xl);
    padding: 22px 20px 18px;
    color: #fff;
    text-align: center;
    margin-bottom: 16px;
    box-shadow: var(--e3);
    position: relative;
    overflow: hidden;
}
.cb-hero::before {
    content: "";
    position: absolute;
    width: 180px; height: 180px;
    border-radius: 50%;
    background: rgba(99,102,241,0.25);
    top: -60px; right: -40px;
}
.cb-hero.danger { background: linear-gradient(160deg, #7f1d1d 0%, #450a0a 100%); }
.cb-hero.danger::before { background: rgba(239,68,68,0.2); }
.cb-hero-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    opacity: 0.75;
    margin-bottom: 6px;
    position: relative;
}
.cb-hero-amount {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.15;
    position: relative;
}
.cb-hero-amount.pos { color: #6ee7b7; }
.cb-hero-amount.neg { color: #fca5a5; }
.cb-neg-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    background: rgba(239,68,68,0.25);
    color: #fecaca;
    padding: 2px 8px;
    border-radius: 20px;
    vertical-align: middle;
    margin-left: 6px;
    letter-spacing: 0;
}
.cb-hero-sub {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 18px;
    font-size: 13px;
    font-weight: 600;
    position: relative;
}
.cb-hero-sub .in { color: #6ee7b7; }
.cb-hero-sub .out { color: #fca5a5; }

/* Big type buttons */
.cb-type-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.cb-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    border: none;
    border-radius: var(--r-lg);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    font-family: inherit;
    transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1);
    -webkit-tap-highlight-color: transparent;
}
.cb-btn:active { transform: scale(0.97); }
.cb-btn.in {
    background: linear-gradient(155deg, #12a350, #0f7a3d);
    box-shadow: 0 8px 20px -6px rgba(15,122,61,0.5);
}
.cb-btn.out {
    background: linear-gradient(155deg, #e0342f, #c0221f);
    box-shadow: 0 8px 20px -6px rgba(192,34,31,0.5);
}
.cb-btn.full {
    width: 100%;
    flex-direction: row;
    gap: 10px;
    min-height: 52px;
    margin-bottom: 16px;
}
.cb-btn-icon {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.cb-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.cb-list-head h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0;
    border: none;
    padding: 0;
}
.cb-count {
    font-size: 12px;
    color: var(--ink-400);
    font-weight: 600;
}

/* Transaction list cards */
.tx-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 20px; }
.tx-date {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-400);
    padding: 12px 4px 6px;
}
.tx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: var(--e1);
    transition: box-shadow var(--dur-1);
}
.tx-item:active { box-shadow: var(--e2); }
.tx-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800;
    flex-shrink: 0;
}
.tx-item.in .tx-icon { background: var(--success-bg); color: var(--success-700); }
.tx-item.out .tx-icon { background: var(--danger-bg); color: var(--danger-700); }
.tx-body { flex: 1; min-width: 0; }
.tx-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-meta {
    font-size: 11.5px;
    color: var(--ink-400);
    margin-top: 2px;
}
.tx-right { text-align: right; flex-shrink: 0; }
.tx-amt {
    font-size: 15px;
    font-weight: 700;
}
.tx-item.in .tx-amt { color: var(--success-700); }
.tx-item.out .tx-amt { color: var(--danger-700); }
.tx-del {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-400);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 6px;
}
.tx-del:hover { background: var(--danger-bg); color: var(--danger-700); }

.tx-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--ink-400);
}
.tx-empty-icon { font-size: 40px; margin-bottom: 10px; }
.tx-empty p { margin: 0 0 4px; font-weight: 600; color: var(--ink-600); }
.tx-empty-hint { font-size: 13px !important; font-weight: 400 !important; color: var(--ink-400) !important; }

/* Bottom sheet modal */
.sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,13,28,0.5);
    z-index: 300;
    animation: fadeInUp var(--dur-1) var(--ease-out);
}
.sheet-overlay.show { display: block; }

.sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--paper);
    border-radius: 20px 20px 0 0;
    padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 310;
    transform: translateY(110%);
    transition: transform 280ms var(--ease-out);
    box-shadow: 0 -8px 40px rgba(17,22,41,0.18);
    max-height: 90vh;
    overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet-handle {
    width: 40px; height: 4px;
    background: #d1d5e0;
    border-radius: 4px;
    margin: 0 auto 14px;
}
.sheet-title {
    font-size: 18px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 16px;
    color: var(--ink-900);
}
.sheet-title.in { color: var(--success-700); }
.sheet-title.out { color: var(--danger-700); }

.sheet-amount-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 18px;
    padding: 8px 0;
}
.sheet-rupee {
    font-size: 28px;
    font-weight: 700;
    color: var(--ink-600);
}
.sheet-amount-wrap input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 40px !important;
    font-weight: 800 !important;
    text-align: center;
    width: 100%;
    max-width: 260px;
    min-height: 52px !important;
    padding: 0 !important;
    color: var(--ink-900);
    outline: none;
}
.sheet-amount-wrap input::placeholder { color: #c5cad8; }

.sheet-save {
    width: 100%;
    min-height: 50px !important;
    font-size: 16px !important;
    margin-top: 8px;
    margin-bottom: 8px;
}
.sheet-save.btn-in {
    background: linear-gradient(155deg, #12a350, #0f7a3d) !important;
    box-shadow: 0 8px 18px -5px rgba(15,122,61,0.5) !important;
}
.sheet-save.btn-out {
    background: linear-gradient(155deg, #e0342f, #c0221f) !important;
    box-shadow: 0 8px 18px -5px rgba(192,34,31,0.5) !important;
}
.sheet-cancel {
    width: 100%;
    min-height: 44px;
}

@media (min-width: 769px) {
    .sheet {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 50%;
        width: 400px;
        max-width: 92vw;
        border-radius: var(--r-xl);
        transform: translate(-50%, -40%) scale(0.95);
        opacity: 0;
        pointer-events: none;
        transition: transform 220ms var(--ease-out), opacity 220ms;
    }
    .sheet.show {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        pointer-events: auto;
    }
    .sheet-handle { display: none; }
}

/* Hide page h2 when using cb-hero (cleaner mobile) */
.content > h2 { margin-bottom: 16px; }

.bill-tabs{display:flex;gap:8px;overflow-x:auto;-webkit-overflow-scrolling:touch;margin-bottom:16px;padding-bottom:4px;}
.bill-tabs a{flex-shrink:0;padding:10px 14px;border-radius:20px;background:#fff;border:1px solid var(--border);font-size:12.5px;font-weight:600;color:var(--ink-600);text-decoration:none;}
.bill-tabs a.active{background:var(--primary);color:#fff;border-color:var(--primary);}
