/* =========================================================
   Your Khatabook — design system
   One stylesheet for the user app, auth screens and shared admin pieces.
   Light tokens on :root, dark tokens on [data-theme="dark"] (set by theme.js).
   ========================================================= */

:root{
 --font:'Plus Jakarta Sans',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
 --bg:#f3f5f7;
 --surface:#ffffff;
 --surface-2:#f7f9fa;
 --surface-3:#eef2f4;
 --line:#e4e8ec;
 --line-strong:#d3dae1;
 --ink:#0e1a23;
 --ink-2:#3a4754;
 --muted:#66727f;
 --faint:#97a1ac;
 --brand:#0a7d5a;
 --brand-strong:#066247;
 --brand-soft:#e6f4ee;
 --brand-ink:#ffffff;
 --pos:#06865a;
 --pos-soft:#e5f5ee;
 --neg:#d42e4c;
 --neg-soft:#fdebee;
 --info:#3d5bd9;
 --info-soft:#edf0fe;
 --warn:#b54708;
 --warn-soft:#fef4e6;
 --hero:linear-gradient(140deg,#064b36 0%,#0a7d5a 58%,#17a57b 100%);
 --hero-ink:#ffffff;
 --shadow-xs:0 1px 2px rgba(16,24,40,.05);
 --shadow-sm:0 1px 2px rgba(16,24,40,.04),0 2px 8px -2px rgba(16,24,40,.06);
 --shadow:0 1px 3px rgba(16,24,40,.05),0 12px 32px -12px rgba(16,24,40,.14);
 --shadow-lg:0 24px 64px -20px rgba(16,24,40,.32);
 --focus:0 0 0 4px rgba(10,125,90,.18);
 --r-xs:8px;--r-sm:12px;--r:16px;--r-lg:22px;--r-xl:28px;
 --sidebar:264px;
 --topbar:68px;
 --bottom-nav:68px;
 --safe-b:env(safe-area-inset-bottom,0px);
 --ease:cubic-bezier(.2,.75,.25,1);
 color-scheme:light;
}
[data-theme="dark"]{
 --bg:#090d12;
 --surface:#10161d;
 --surface-2:#141b23;
 --surface-3:#1a232d;
 --line:#1e2832;
 --line-strong:#2a3642;
 --ink:#e8eef3;
 --ink-2:#c2ccd5;
 --muted:#8b97a4;
 --faint:#5d6976;
 --brand:#34c48f;
 --brand-strong:#4fd8a4;
 --brand-soft:rgba(52,196,143,.13);
 --brand-ink:#03140d;
 --pos:#41d39b;
 --pos-soft:rgba(65,211,155,.12);
 --neg:#ff6f86;
 --neg-soft:rgba(255,111,134,.12);
 --info:#93a8ff;
 --info-soft:rgba(147,168,255,.12);
 --warn:#f5b056;
 --warn-soft:rgba(245,176,86,.12);
 --hero:linear-gradient(140deg,#072a1f 0%,#0b4f3a 55%,#11795a 100%);
 --shadow-xs:0 1px 2px rgba(0,0,0,.4);
 --shadow-sm:0 1px 2px rgba(0,0,0,.35),0 4px 12px -4px rgba(0,0,0,.4);
 --shadow:0 1px 3px rgba(0,0,0,.4),0 16px 40px -16px rgba(0,0,0,.6);
 --shadow-lg:0 30px 80px -20px rgba(0,0,0,.75);
 --focus:0 0 0 4px rgba(52,196,143,.22);
 color-scheme:dark;
}

/* ---------- Base ---------- */
*,*::before,*::after{box-sizing:border-box}
[hidden]{display:none!important}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{margin:0;min-height:100vh;min-height:100dvh;background:var(--bg);color:var(--ink);font-family:var(--font);font-size:14.5px;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:'cv11','ss01'}
a{color:inherit;text-decoration:none}
button,input,textarea,select{font:inherit;color:inherit}
button{cursor:pointer;background:none;border:0;padding:0}
button:disabled{opacity:.6;cursor:progress}
button,a,input,textarea,select,summary{-webkit-tap-highlight-color:transparent}
:focus-visible{outline:none;box-shadow:var(--focus);border-radius:var(--r-xs)}
h1,h2,h3,p,dl,dd{margin:0}
h1{font-size:clamp(24px,3.2vw,32px);line-height:1.15;letter-spacing:-.035em;font-weight:800}
h2{font-size:18px;line-height:1.3;letter-spacing:-.02em;font-weight:700}
h3{font-size:15px;line-height:1.35;letter-spacing:-.01em;font-weight:700}
small{font-size:12.5px}
img{max-width:100%}
svg{flex:none}
::selection{background:var(--brand-soft);color:var(--ink)}
.muted{color:var(--muted)}
.eyebrow{font-size:11px;font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);margin-bottom:8px}
.dot{color:var(--brand)}
.green-text{color:var(--pos)!important}
.red-text{color:var(--neg)!important}
.num,.balance b,.entryamount b,.stats h2,.netbalance strong,.detail-amount,.table-money{font-variant-numeric:tabular-nums;font-feature-settings:'tnum'}
.icon{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- Buttons ---------- */
.primary,.outline,.gavebutton,.gotbutton,.detail-delete{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:0 18px;border-radius:var(--r-sm);font-weight:700;font-size:14px;letter-spacing:-.005em;white-space:nowrap;transition:transform .15s var(--ease),background-color .2s,border-color .2s,box-shadow .2s,color .2s;user-select:none}
.primary{background:var(--brand);color:var(--brand-ink);box-shadow:0 1px 0 rgba(255,255,255,.18) inset,0 6px 16px -6px color-mix(in srgb,var(--brand) 60%,transparent)}
.primary:hover{background:var(--brand-strong)}
.primary:active,.outline:active,.gavebutton:active,.gotbutton:active,.detail-delete:active{transform:scale(.98)}
.outline{background:var(--surface);border:1px solid var(--line-strong);color:var(--ink)}
.outline:hover{background:var(--surface-2);border-color:var(--faint)}
.outline[disabled]{opacity:.5}
.textbutton{display:inline-flex;align-items:center;gap:6px;min-height:36px;padding:0 10px;border-radius:var(--r-xs);color:var(--muted);font-weight:600}
.textbutton:hover{color:var(--ink);background:var(--surface-3)}
.full{width:100%}
.detail-delete{background:var(--neg-soft);color:var(--neg);border:1px solid transparent}
.detail-delete:hover{border-color:color-mix(in srgb,var(--neg) 40%,transparent)}
.gavebutton{background:var(--neg);color:#fff;box-shadow:0 8px 20px -8px color-mix(in srgb,var(--neg) 70%,transparent)}
.gotbutton{background:var(--pos);color:#fff;box-shadow:0 8px 20px -8px color-mix(in srgb,var(--pos) 70%,transparent)}
[data-theme="dark"] .gavebutton,[data-theme="dark"] .gotbutton{color:#08110d}
.gavebutton:hover{filter:brightness(1.05)}.gotbutton:hover{filter:brightness(1.05)}

/* ---------- Form controls ---------- */
label{display:block;font-size:13px;font-weight:600;color:var(--ink-2);margin-bottom:16px}
label small{font-weight:500;color:var(--faint)}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),textarea,select{display:block;width:100%;margin-top:7px;min-height:48px;padding:12px 14px;border:1px solid var(--line-strong);border-radius:var(--r-sm);background:var(--surface);color:var(--ink);font-size:15px;font-weight:500;transition:border-color .2s,box-shadow .2s,background-color .2s}
textarea{resize:vertical;min-height:88px;line-height:1.5}
input::placeholder,textarea::placeholder{color:var(--faint);font-weight:400}
input:hover,textarea:hover,select:hover{border-color:var(--faint)}
input:focus,textarea:focus,select:focus{outline:none;border-color:var(--brand);box-shadow:var(--focus)}
input[type="checkbox"]{width:18px;height:18px;margin:0;accent-color:var(--brand)}
select{appearance:none;-webkit-appearance:none;padding-right:38px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366727f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;background-size:16px}
.passwordfield{position:relative;display:block}
.passwordfield input{padding-right:52px!important}
.password-toggle{position:absolute;right:6px;bottom:6px;width:38px;height:36px;display:grid;place-items:center;border-radius:var(--r-xs);color:var(--muted);font-size:0}
.password-toggle:hover{color:var(--ink);background:var(--surface-3)}
.password-toggle svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* Language + theme controls */
.language-control{display:inline-flex;align-items:center;gap:8px;margin:0;font-size:12.5px;font-weight:600;color:var(--muted)}
.language-control span{white-space:nowrap}
.language-control select{margin:0;min-height:38px;width:auto;padding:6px 32px 6px 12px;font-size:13px;font-weight:600;border-radius:10px;background-color:var(--surface);background-position:right 9px center}
.theme-switch{display:inline-flex;padding:3px;gap:2px;border-radius:12px;background:var(--surface-3);border:1px solid var(--line)}
.theme-switch button{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:0 11px;border-radius:9px;font-size:12.5px;font-weight:600;color:var(--muted);transition:background-color .2s,color .2s,box-shadow .2s}
.theme-switch button svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.theme-switch button[aria-pressed="true"]{background:var(--surface);color:var(--ink);box-shadow:var(--shadow-xs)}

/* Alerts */
.error,.success,.customer-status{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;margin:0 0 18px;border-radius:var(--r-sm);font-size:13.5px;font-weight:600;line-height:1.45}
.error{background:var(--neg-soft);color:var(--neg);border:1px solid color-mix(in srgb,var(--neg) 22%,transparent)}
.success{background:var(--pos-soft);color:var(--pos);border:1px solid color-mix(in srgb,var(--pos) 22%,transparent)}
.customer-status{background:var(--info-soft);color:var(--info)}
.customer-status:empty{display:none}
.error a,.success a{text-decoration:underline;text-underline-offset:3px}

/* Brand mark */
.brandmark{display:grid;place-items:center;width:56px;height:56px;border-radius:18px;background:var(--hero);color:#fff;font-weight:800;font-size:24px;box-shadow:0 12px 28px -10px rgba(6,98,71,.55),inset 0 1px 0 rgba(255,255,255,.2)}
.brandmark svg{width:30px;height:30px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
.brandmark .brandmark-check{stroke:#9ff0cc}
.brandmark.small{width:40px;height:40px;border-radius:12px;font-size:18px}

/* Avatars */
.avatar{display:grid;place-items:center;flex:none;width:42px;height:42px;border-radius:13px;font-weight:700;font-size:16px;text-transform:uppercase;background:var(--brand-soft);color:var(--brand)}
.hue-1{background:#e8f0fe;color:#3456c8}.hue-2{background:#fdeee6;color:#c2541d}.hue-3{background:#f2ebfd;color:#7044c4}.hue-4{background:#fdf6dd;color:#a26b00}.hue-5{background:#e3f6f8;color:#11798a}
[data-theme="dark"] .hue-1{background:rgba(120,150,255,.14);color:#9fb3ff}[data-theme="dark"] .hue-2{background:rgba(255,150,100,.13);color:#ffab80}[data-theme="dark"] .hue-3{background:rgba(170,130,255,.14);color:#c4a6ff}[data-theme="dark"] .hue-4{background:rgba(255,200,80,.12);color:#f2c35a}[data-theme="dark"] .hue-5{background:rgba(80,210,230,.12);color:#6fd6e6}

/* =========================================================
   Auth screens (login / register / recovery / admin login)
   ========================================================= */
.login{position:relative;min-height:100vh;min-height:100dvh;display:flex;flex-direction:column;align-items:center;padding:88px 20px 40px;text-align:center;isolation:isolate;overflow:hidden}
.login::before{content:"";position:absolute;inset:-20% -10% auto;height:520px;z-index:-1;background:radial-gradient(60% 60% at 30% 30%,color-mix(in srgb,var(--brand) 22%,transparent),transparent 70%),radial-gradient(50% 55% at 75% 20%,color-mix(in srgb,var(--info) 14%,transparent),transparent 70%);filter:blur(10px)}
.login::after{content:"";position:absolute;inset:0;z-index:-1;background-image:linear-gradient(var(--line) 1px,transparent 1px),linear-gradient(90deg,var(--line) 1px,transparent 1px);background-size:44px 44px;mask-image:radial-gradient(70% 50% at 50% 0%,#000 20%,transparent 75%);-webkit-mask-image:radial-gradient(70% 50% at 50% 0%,#000 20%,transparent 75%);opacity:.6}
.login-theme{position:absolute;top:16px;left:16px;right:16px;display:flex;justify-content:flex-end;align-items:center;gap:10px;flex-wrap:wrap}
.login>.brandmark{width:64px;height:64px;border-radius:20px;margin-bottom:22px}
.login>.brandmark svg{width:34px;height:34px}
.login>.eyebrow{color:var(--brand);margin-bottom:10px}
.login>h1{font-size:clamp(30px,6vw,40px)}
.login>h1 span{background:var(--hero);-webkit-background-clip:text;background-clip:text;color:transparent}
[data-theme="dark"] .login>h1 span{background:linear-gradient(120deg,#5fe0ad,#34c48f);-webkit-background-clip:text;background-clip:text}
.login>p.muted{margin-top:8px;font-size:15px}
.loginbox{width:100%;max-width:440px;margin:32px auto 22px;padding:28px;text-align:left;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-xl);box-shadow:var(--shadow)}
.loginbox h2{font-size:21px;margin-bottom:4px}
.loginbox>p.muted{margin-bottom:22px}
.loginbox .primary.full{min-height:50px;font-size:15px;margin-top:6px}
.auth-tabs{display:grid;grid-template-columns:1fr 1fr;padding:4px;gap:4px;margin-bottom:24px;border-radius:14px;background:var(--surface-3)}
.auth-tabs a{display:grid;place-items:center;min-height:40px;border-radius:10px;font-weight:700;font-size:13.5px;color:var(--muted);transition:background-color .2s,color .2s}
.auth-tabs a[aria-current="page"]{background:var(--surface);color:var(--ink);box-shadow:var(--shadow-xs)}
.forgot-link{text-align:right;margin:-6px 0 16px;font-size:13px;font-weight:600}
.forgot-link a,.auth-note a,.recovery-admin-link a{color:var(--brand)}
.forgot-link a:hover,.auth-note a:hover{text-decoration:underline;text-underline-offset:3px}
.auth-note{margin-top:18px;text-align:center;font-size:12.5px}
.admin-login-link{margin-top:10px;font-size:12.5px;font-weight:600;color:var(--muted)}
.admin-login-link:hover{color:var(--brand)}
.legacy-claim{margin:0 0 18px;padding:14px 16px;border:1px dashed var(--line-strong);border-radius:var(--r-sm);background:var(--surface-2)}
.legacy-claim summary{cursor:pointer;font-weight:700;font-size:13.5px;color:var(--ink-2)}
.legacy-claim p{margin:10px 0 12px;font-size:13px}
.removebill{display:flex;align-items:center;gap:10px}
.recovery-admin-link{margin:-8px 0 16px;font-size:13px}

/* =========================================================
   Workspace shell
   ========================================================= */
.sidebar{position:fixed;inset:0 auto 0 0;z-index:30;width:var(--sidebar);display:flex;flex-direction:column;padding:22px 16px 18px;background:var(--surface);border-right:1px solid var(--line)}
.brand{display:flex;align-items:center;gap:12px;padding:6px 8px 22px}
.brand-text{display:flex;flex-direction:column;min-width:0;line-height:1.2}
.brand-text b{font-size:15px;font-weight:800;letter-spacing:-.02em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-text small{font-size:11.5px;font-weight:700;color:var(--brand);letter-spacing:.02em}
.navlabel{padding:14px 12px 8px;font-size:10.5px;font-weight:700;letter-spacing:.14em;color:var(--faint);text-transform:uppercase}
.side-nav{display:flex;flex-direction:column;gap:2px}
.nav{display:flex;align-items:center;gap:12px;width:100%;min-height:42px;padding:0 12px;border-radius:11px;font-weight:600;font-size:14px;color:var(--ink-2);text-align:left;transition:background-color .2s,color .2s}
.nav .icon{width:19px;height:19px;color:var(--muted)}
.nav:hover{background:var(--surface-3);color:var(--ink)}
.nav.active{background:var(--brand-soft);color:var(--brand)}
.nav.active .icon{color:var(--brand)}
.sidebar-card{margin-top:auto;padding:16px;border-radius:var(--r);background:var(--hero);color:#fff;position:relative;overflow:hidden}
.sidebar-card::after{content:"₹";position:absolute;right:-6px;bottom:-26px;font-size:96px;font-weight:800;opacity:.12;line-height:1}
.sidebar-card small{opacity:.8;font-weight:600}
.sidebar-card strong{display:block;margin-top:4px;font-size:20px;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.sidebarfoot{display:flex;align-items:center;gap:11px;margin-top:14px;padding:12px 10px 0;border-top:1px solid var(--line)}
.sidebarfoot>div{min-width:0;line-height:1.3}
.sidebarfoot b{display:block;font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sidebarfoot small{color:var(--muted)}
.sidebarfoot .avatar{width:36px;height:36px;border-radius:11px;font-size:14px}

.workspace{margin-left:var(--sidebar);min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:16px;height:var(--topbar);padding:0 28px;background:color-mix(in srgb,var(--bg) 82%,transparent);backdrop-filter:saturate(1.6) blur(14px);-webkit-backdrop-filter:saturate(1.6) blur(14px);border-bottom:1px solid var(--line)}
.topbar-title{display:flex;align-items:center;gap:8px;font-weight:700;font-size:14px}
.topbar-title .muted{font-weight:500}
.mobilebrand{display:none}
.headeractions{display:flex;align-items:center;gap:10px}
.headeractions form{margin:0}
.headeractions .outline{min-height:38px;padding:0 14px;font-size:13px}
.icon-button{display:inline-grid;place-items:center;width:40px;height:40px;border-radius:12px;color:var(--ink-2);border:1px solid var(--line);background:var(--surface)}
.icon-button:hover{background:var(--surface-3);color:var(--ink)}
.mobile-only{display:none!important}
.content{flex:1;width:100%;max-width:1480px;margin:0 auto;padding:28px 28px 40px}
.heading{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:24px}
.heading h1{margin-top:2px}
.heading p.muted{margin-top:6px}
.heading .primary{min-height:46px;padding:0 20px}

/* Stats */
.stats{display:grid;grid-template-columns:1.25fr 1fr 1fr;gap:16px;margin-bottom:24px}
.stats article{position:relative;display:flex;flex-direction:column;gap:6px;padding:20px 22px;min-width:0;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);box-shadow:var(--shadow-sm);overflow:hidden}
.stat-head{display:flex;align-items:center;gap:10px;font-size:13px;font-weight:600;color:var(--muted)}
.stat-icon{display:grid;place-items:center;width:34px;height:34px;border-radius:11px;flex:none}
.stat-icon svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.stat-icon.green{background:var(--pos-soft);color:var(--pos)}
.stat-icon.red{background:var(--neg-soft);color:var(--neg)}
.stat-icon.blue{background:var(--info-soft);color:var(--info)}
.stats h2{font-size:clamp(22px,2.4vw,30px);font-weight:800;letter-spacing:-.035em;line-height:1.15;margin-top:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stat-description{color:var(--faint);font-weight:500}
.stat-total{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:auto;padding-top:12px;border-top:1px dashed var(--line);font-size:12.5px;color:var(--muted);font-weight:600}
.stat-total strong{color:var(--ink);font-variant-numeric:tabular-nums}
.stats article.stat-hero{background:var(--hero);border-color:transparent;color:var(--hero-ink);box-shadow:0 18px 40px -18px rgba(6,98,71,.6)}
.stats article.stat-hero::after{content:"";position:absolute;right:-60px;top:-60px;width:220px;height:220px;border-radius:50%;background:radial-gradient(circle,rgba(255,255,255,.18),transparent 65%);pointer-events:none}
.stat-hero .stat-head,.stat-hero .stat-description,.stat-hero .stat-total{color:rgba(255,255,255,.78)}
.stat-hero .stat-icon{background:rgba(255,255,255,.16);color:#fff}
.stat-hero h2{color:#fff!important}
.stat-hero .stat-total{border-top-color:rgba(255,255,255,.22)}
.stat-hero .stat-total strong{color:#fff}

/* Ledger: customer list + detail */
.ledger{display:grid;grid-template-columns:minmax(300px,380px) minmax(0,1fr);gap:16px;align-items:start}
.customerpanel,.detailpanel{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);box-shadow:var(--shadow-sm);min-width:0}
.customerpanel{position:sticky;top:calc(var(--topbar) + 16px);display:flex;flex-direction:column;max-height:calc(100dvh - var(--topbar) - 32px);overflow:hidden}
.paneltitle{display:flex;align-items:center;justify-content:space-between;padding:18px 18px 12px}
.paneltitle h2{display:flex;align-items:center;gap:8px;font-size:16px}
.badge{display:inline-grid;place-items:center;min-width:24px;height:22px;padding:0 7px;border-radius:999px;background:var(--surface-3);color:var(--muted);font-size:11.5px;font-weight:700}
.searchwrap{position:relative;padding:0 14px 12px;border-bottom:1px solid var(--line)}
.searchwrap svg{position:absolute;left:28px;top:50%;transform:translateY(calc(-50% - 6px));width:17px;height:17px;color:var(--faint);pointer-events:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
.searchwrap input{margin:0!important;min-height:44px!important;padding-left:40px!important;background:var(--surface-2)!important;border-color:var(--line)!important;font-size:14px!important}
.customerlist{flex:1;overflow-y:auto;padding:8px;overscroll-behavior:contain;scrollbar-width:thin}
.customer{display:flex;align-items:center;gap:12px;padding:11px 10px;border-radius:14px;transition:background-color .15s}
.customer+.customer{margin-top:2px}
.customer:hover{background:var(--surface-2)}
.customer.selected{background:var(--brand-soft)}
.customer.selected .customername b{color:var(--brand)}
.customername{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.3}
.customername b{font-size:14.5px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.customername small{color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.balance{display:flex;flex-direction:column;align-items:flex-end;line-height:1.3;flex:none}
.balance b{font-size:14.5px;font-weight:800;letter-spacing:-.01em}
.balance small{font-size:11.5px;font-weight:600;color:var(--faint)}
#noResults{padding:24px;text-align:center}

.detailpanel{display:flex;flex-direction:column;min-height:560px;outline:none}
.detailhead{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:18px 20px;border-bottom:1px solid var(--line)}
.person{display:flex;align-items:center;gap:12px;min-width:0}
.person>div{min-width:0}
.person h2{font-size:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.person .avatar{width:46px;height:46px;border-radius:14px;font-size:18px}
.customer-back{display:none;place-items:center;width:40px;height:40px;border-radius:12px;font-size:20px;color:var(--ink);background:var(--surface-3);flex:none}
.detailhead .outline{min-height:40px;font-size:13px;padding:0 14px}
.netbalance{position:relative;display:flex;align-items:center;justify-content:space-between;gap:16px;margin:18px 20px 6px;padding:20px 22px;border-radius:var(--r);background:var(--surface-2);border:1px solid var(--line);overflow:hidden}
.netbalance::before{content:"";position:absolute;inset:0 auto 0 0;width:4px;background:var(--pos)}
.netbalance:has(.red-text)::before{background:var(--neg)}
.netbalance span{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}
.netbalance strong{font-size:clamp(24px,3vw,32px);font-weight:800;letter-spacing:-.035em;line-height:1}
.historytitle{display:flex;align-items:baseline;justify-content:space-between;padding:18px 20px 8px}
.historytitle h3{font-size:14px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-weight:700}
.entries{flex:1;padding:0 12px 12px}
.entry{display:flex;align-items:center;gap:13px;padding:13px 10px;border-radius:14px;cursor:pointer;transition:background-color .15s}
.entry+.entry{border-top:1px solid var(--line)}
.entry:hover{background:var(--surface-2)}
.entry:hover+.entry{border-top-color:transparent}
.entryicon{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;font-size:17px;font-weight:800;flex:none}
.entryicon.red{background:var(--neg-soft);color:var(--neg)}
.entryicon.green{background:var(--pos-soft);color:var(--pos)}
.entryicon svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.entrybody{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
.entry-label-row{display:flex;align-items:center;gap:6px}
.entry-label-row b{font-size:14px;font-weight:700}
.entrybody>small{color:var(--muted);font-weight:500}
.entrybody p{margin-top:3px;font-size:13px;color:var(--ink-2);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}
.view-entry{display:inline-grid;place-items:center;width:26px;height:26px;border-radius:8px;color:var(--faint)}
.view-entry:hover{background:var(--surface-3);color:var(--brand)}
.view-entry svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.entryamount{text-align:right;flex:none}
.entryamount b{font-size:15.5px;font-weight:800;letter-spacing:-.015em}
.entryactions{position:sticky;bottom:0;display:grid;grid-template-columns:1fr 1fr;gap:12px;padding:14px 20px 18px;background:linear-gradient(to top,var(--surface) 70%,transparent);border-radius:0 0 var(--r-lg) var(--r-lg)}
.entryactions button{min-height:50px;font-size:15px;border-radius:14px}

/* Empty states */
.empty{display:flex;flex-direction:column;align-items:center;text-align:center;padding:48px 24px;color:var(--muted)}
.empty h2,.empty h3{color:var(--ink);margin:16px 0 6px}
.empty p{max-width:320px;font-size:13.5px;line-height:1.6}
.empty>span{display:grid;place-items:center;width:56px;height:56px;border-radius:18px;background:var(--surface-3);color:var(--faint);font-size:24px}
.empty .outline,.empty .primary{margin-top:20px}
.small-empty{padding:40px 16px}
.welcome{flex:1;justify-content:center;min-height:540px}
.bookillustration{position:relative;display:grid;place-items:center;width:96px;height:96px;border-radius:30px;background:var(--hero);color:#fff;font-size:40px;font-weight:800;box-shadow:0 22px 50px -20px rgba(6,98,71,.7);transform:rotate(-6deg)}
.bookillustration span{position:absolute;right:-10px;bottom:-10px;display:grid;place-items:center;width:36px;height:36px;border-radius:12px;background:var(--surface);color:var(--pos);font-size:18px;box-shadow:var(--shadow);transform:rotate(6deg)}
.welcome .eyebrow{margin-top:26px;color:var(--brand)}
.welcome h2{margin-top:0;font-size:22px;letter-spacing:-.03em}

footer{display:flex;justify-content:center;gap:8px;padding:32px 0 8px;font-size:12px;color:var(--faint);font-weight:500}

/* Bottom nav (mobile/tablet only) */
.bottom-nav{display:none}

/* =========================================================
   Dialogs
   ========================================================= */
dialog{width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:24px;border:1px solid var(--line);border-radius:var(--r-xl);background:var(--surface);color:var(--ink);box-shadow:var(--shadow-lg);overflow-y:auto;overscroll-behavior:contain}
dialog::backdrop{background:rgba(6,12,18,.5);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}
.modaltitle{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:4px}
.modaltitle h2{font-size:20px;letter-spacing:-.025em}
.modaltitle .textbutton{width:36px;height:36px;justify-content:center;padding:0;font-size:15px;border-radius:11px;background:var(--surface-3)}
dialog form>p.muted,dialog>p.muted{margin-bottom:20px;font-size:13.5px}
#entryDialog .amountinput{min-height:68px!important;font-size:30px!important;font-weight:800!important;letter-spacing:-.03em;text-align:left;padding-left:16px!important}
#entryDialog[data-kind="gave"] .amountinput{color:var(--neg)}
#entryDialog[data-kind="got"] .amountinput{color:var(--pos)}
#entryDialog[data-kind="gave"] #saveEntry{background:var(--neg);box-shadow:0 8px 20px -8px color-mix(in srgb,var(--neg) 70%,transparent)}
#entryDialog[data-kind="got"] #saveEntry{background:var(--pos);box-shadow:0 8px 20px -8px color-mix(in srgb,var(--pos) 70%,transparent)}
[data-theme="dark"] #entryDialog[data-kind] #saveEntry{color:#08110d}
#entryDialog form>label+p.muted{margin:-8px 0 16px;font-size:12.5px}
.upload{position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;padding:20px 16px;border:1.5px dashed var(--line-strong);border-radius:var(--r);background:var(--surface-2);text-align:center;cursor:pointer;transition:border-color .2s,background-color .2s}
.upload:hover{border-color:var(--brand);background:var(--brand-soft)}
.upload input[type="file"]{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%}
.upload small{display:block}
.bill-thumbnail{position:relative;margin:-4px 0 16px;border-radius:var(--r);overflow:hidden;border:1px solid var(--line);background:var(--surface-2)}
.bill-thumbnail img{display:block;width:100%;max-height:220px;object-fit:contain}
.remove-bill-button{position:absolute;top:10px;right:10px;padding:7px 12px;border-radius:10px;background:rgba(10,14,18,.72);color:#fff;font-size:12.5px;font-weight:700;backdrop-filter:blur(6px)}
#billRemoveNotice{margin:-6px 0 14px;font-size:12.5px}
#saveEntry{min-height:52px;font-size:15px}

/* Entry details */
#entryDetails #detailDate{margin-top:2px;font-size:13px}
.detail-amount{display:block;margin:16px 0 18px;padding:18px;border-radius:var(--r);background:var(--surface-2);font-size:34px;font-weight:800;letter-spacing:-.04em;text-align:center}
#entryDetails section{margin-bottom:16px}
#entryDetails section h3{font-size:12px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);margin-bottom:6px}
#detailNote{white-space:pre-wrap;word-break:break-word;font-size:14.5px;color:var(--ink-2)}
#detailBillLink{display:block;border-radius:var(--r);overflow:hidden;border:1px solid var(--line);background:var(--surface-2)}
#detailBillLink img{display:block;width:100%;max-height:320px;object-fit:contain}
#detailBillLink span{display:block;padding:10px;text-align:center;font-size:12.5px;font-weight:700;color:var(--brand)}
.detail-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:20px}
.detail-actions form{margin:0}
.detail-actions button{width:100%;min-height:48px}

/* Account dialog */
.account-person{display:flex;align-items:center;gap:14px;margin:12px 0 18px;padding:16px;border-radius:var(--r);background:var(--hero);color:#fff}
.account-person .avatar{width:52px;height:52px;border-radius:16px;font-size:20px;background:rgba(255,255,255,.18);color:#fff}
.account-person h3{font-size:17px}
.account-person .muted{color:rgba(255,255,255,.78)}
.profile-details{display:grid;grid-template-columns:auto 1fr;gap:10px 16px;margin-bottom:18px;padding:16px;border-radius:var(--r);border:1px solid var(--line);font-size:13.5px}
.profile-details dt{color:var(--muted);font-weight:600}
.profile-details dd{text-align:right;font-weight:600;word-break:break-word}
.profile-options{display:grid;gap:8px;margin-bottom:18px}
.profile-options .outline{justify-content:space-between;min-height:50px}
.profile-options .outline span{color:var(--faint)}
#accountDialog .language-control{display:flex;justify-content:space-between;margin-bottom:16px}
#accountDialog .language-control select{min-width:150px}
#accountDialog .eyebrow{margin:6px 0 8px}
#accountDialog .theme-switch{display:flex;margin-bottom:18px}
#accountDialog .theme-switch button{flex:1;justify-content:center;min-height:38px}
.account-logout{margin:0}
[data-account-panel] .textbutton{margin:10px 0 14px;padding-left:0}
[data-account-panel] .textbutton:hover{background:none;color:var(--brand)}

/* =========================================================
   Tablet + mobile (≤1024px) — app-like single column
   ========================================================= */
@media (max-width:1024px){
 :root{--topbar:60px}
 body{font-size:15px;padding-bottom:calc(var(--bottom-nav) + var(--safe-b))}
 .sidebar{display:none}
 .workspace{margin-left:0}
 .topbar{padding:0 16px;padding-top:env(safe-area-inset-top,0px);height:calc(var(--topbar) + env(safe-area-inset-top,0px))}
 .topbar-title,.topbar .headeractions>.language-control,.topbar .headeractions>.theme-switch,.topbar .headeractions>.desktop-account,.topbar .headeractions>form{display:none}
 .mobile-only{display:inline-grid!important}
 .mobilebrand{display:flex;align-items:center;gap:10px;min-width:0;font-weight:800;font-size:16px;letter-spacing:-.02em}
 .mobilebrand>span:last-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 .mobile-logo{display:grid;place-items:center;width:36px;height:36px;border-radius:11px;background:var(--hero);color:#fff;font-size:16px;font-weight:800;flex:none}
 .content{padding:18px 16px 24px}
 .heading{margin-bottom:18px}
 .heading .primary{display:none}
 .heading .eyebrow{margin-bottom:4px}
 h1{font-size:26px}
 .stats{grid-template-columns:1fr 1fr;gap:10px;margin-bottom:18px}
 .stats article{padding:16px;border-radius:var(--r)}
 .stats article.stat-hero{grid-column:1/-1}
 .stat-customers h2{font-size:26px}
 .stat-head{font-size:12.5px;gap:8px}
 .stat-icon{width:30px;height:30px;border-radius:10px}
 .stats h2{font-size:22px}
 .stat-hero h2{font-size:30px}
 .stat-description{display:none}
 .stat-customers .stat-description{display:block}
 .stat-hero .stat-description{display:block}
 .stats article:not(.stat-hero) .stat-total{flex-direction:column;align-items:flex-start;gap:2px}
 .ledger{display:block}
 .customerpanel{position:static;max-height:none;overflow:visible}
 .customerlist{overflow:visible;padding:6px}
 .customer{padding:12px 10px}
 .detailpanel{display:none}
 body.customer-open .heading,body.customer-open .stats,body.customer-open .customerpanel,body.customer-open footer,body.customer-open .topbar,body.customer-open #customerStatus{display:none}
 body.customer-open{padding-bottom:0}
 body.customer-open .content{padding:0;max-width:none}
 body.customer-open .detailpanel{display:flex;min-height:100dvh;border:0;border-radius:0;box-shadow:none;background:var(--bg)}
 body.customer-open .bottom-nav{display:none}
 .detailhead{position:sticky;top:0;z-index:10;padding:10px 12px;padding-top:calc(10px + env(safe-area-inset-top,0px));background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
 .customer-back{display:grid}
 .person{flex:1}
 .person .avatar{width:40px;height:40px;font-size:16px}
 .person h2{font-size:16.5px}
 .detailhead .outline{padding:0 12px;min-height:38px}
 .netbalance{margin:12px 16px 4px;background:var(--hero);border:0;color:#fff;padding:22px 20px;flex-direction:column;align-items:flex-start;gap:6px}
 .netbalance::before{display:none}
 .netbalance span{color:rgba(255,255,255,.8)}
 .netbalance strong{color:#fff!important;font-size:34px}
 .historytitle{padding:18px 18px 6px}
 .entries{padding:0 8px;padding-bottom:calc(96px + var(--safe-b))}
 .entries .entry{background:var(--surface);border:1px solid var(--line);border-radius:14px;margin-bottom:8px;padding:12px}
 .entry+.entry{border-top:1px solid var(--line)}
 .entryactions{position:fixed;left:0;right:0;bottom:0;z-index:25;padding:12px 16px calc(12px + var(--safe-b));background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border-top:1px solid var(--line);border-radius:0}
 .welcome{display:none}
 footer{padding:24px 0 8px}

 .bottom-nav{position:fixed;left:0;right:0;bottom:0;z-index:25;display:grid;grid-template-columns:repeat(4,1fr);height:calc(var(--bottom-nav) + var(--safe-b));padding:6px 8px var(--safe-b);background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border-top:1px solid var(--line)}
 .bottom-nav a,.bottom-nav button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border-radius:14px;color:var(--muted);font-size:11px;font-weight:700}
 .bottom-nav svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
 .bottom-nav .bottom-home,.bottom-nav .active{color:var(--brand)}
 .bottom-nav form{display:contents}
 .bottom-nav .bottom-add{color:var(--brand-ink)}
 .bottom-nav .bottom-add svg{width:46px;height:46px;padding:12px;border-radius:16px;background:var(--brand);color:var(--brand-ink);box-shadow:0 8px 18px -6px color-mix(in srgb,var(--brand) 70%,transparent);stroke-width:2.2;margin-top:-18px}
 .bottom-nav .bottom-add span{color:var(--muted)}

 /* Dialogs become bottom sheets */
 dialog{width:100%;max-width:100%;margin:auto 0 0;max-height:92dvh;border-radius:26px 26px 0 0;border-bottom:0;padding:12px 20px calc(20px + var(--safe-b))}
 dialog::before{content:"";display:block;width:40px;height:5px;margin:0 auto 14px;border-radius:999px;background:var(--line-strong)}
 dialog[open]{animation:sheet-in .32s var(--ease)}
 .detail-amount{font-size:32px}
}
@keyframes sheet-in{from{transform:translateY(40px);opacity:.4}to{transform:none;opacity:1}}

@media (max-width:420px){
 .stats h2{font-size:19px}
 .stat-hero h2{font-size:28px}
 .stats article{padding:14px}
 .loginbox{padding:22px 18px;border-radius:var(--r-lg)}
 .login{padding-top:84px}
 .login-theme .language-control span{display:none}
 .detailhead .outline span.label{display:none}
}
@media (min-width:1025px) and (max-width:1240px){
 :root{--sidebar:232px}
 .stats{grid-template-columns:1fr 1fr}
 .stats article.stat-hero{grid-column:1/-1}
 .ledger{grid-template-columns:320px minmax(0,1fr)}
}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
@media print{.sidebar,.topbar,.bottom-nav,.entryactions,.customerpanel{display:none!important}.workspace{margin:0}}

/* ---------- Customer delete ---------- */
.detail-tools{display:flex;align-items:center;gap:8px;flex:none}
.danger-icon{color:var(--neg);border-color:var(--line)}
.danger-icon:hover{background:var(--neg-soft);color:var(--neg);border-color:color-mix(in srgb,var(--neg) 35%,transparent)}
.danger-icon .icon{width:19px;height:19px}
.danger-summary{display:flex;align-items:center;gap:12px;margin:14px 0 14px;padding:14px;border-radius:var(--r);background:var(--surface-2);border:1px solid var(--line)}
.danger-summary>div{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.35}
.danger-summary b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.danger-summary small{color:var(--muted)}
.danger-summary strong{font-size:16px;font-weight:800;font-variant-numeric:tabular-nums;flex:none}
.danger-note{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;margin-bottom:10px;border-radius:var(--r-sm);background:var(--neg-soft);color:var(--neg);font-size:13.5px;font-weight:600;line-height:1.5}
.danger-note .icon{width:18px;height:18px;margin-top:1px}
.danger-tip{font-size:13px;margin-bottom:16px}
.danger-tip a{color:var(--brand);font-weight:700}
.confirm-check{display:flex;align-items:center;gap:10px;margin:0 0 4px;padding:12px 14px;border:1px solid var(--line-strong);border-radius:var(--r-sm);cursor:pointer;font-size:13.5px;color:var(--ink)}
.confirm-check:has(input:checked){border-color:var(--neg);background:var(--neg-soft)}
.confirm-check input{accent-color:var(--neg)}
.danger-button{white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:0 16px;border-radius:var(--r-sm);background:var(--neg);color:#fff;font-weight:700;font-size:14px;box-shadow:0 8px 20px -8px color-mix(in srgb,var(--neg) 70%,transparent);transition:filter .2s,transform .15s var(--ease),opacity .2s}
.danger-button:hover{filter:brightness(1.06)}
.danger-button:active{transform:scale(.98)}
[data-theme="dark"] .danger-button{color:#170408}
.danger-dialog form:has(input[name="confirm_delete"]:not(:checked)) .danger-button{opacity:.55}
@media (max-width:1024px){
 .detail-tools .icon-button{width:38px;height:38px}
}
@media (max-width:420px){
 .detail-tools{gap:6px}
 .detail-tools .outline{width:38px;padding:0}
 .danger-button .icon{display:none}
}
