:root{
  --blue:#1e63ff; --blue2:#4ca0ff; --red:#e02424; --green:#0e9f6e;
  --navy:#1c2b4a; --sidebg:#0c1f38;
  --ink:#1c2430; --muted:#6b7686; --bg:#eef1f7; --card:#fff; --line:#e3e8f0;
}
*{box-sizing:border-box}
body{margin:0;font-family:-apple-system,'Segoe UI',Roboto,'Khmer OS','Khmer OS System',sans-serif;background:var(--bg);color:var(--ink)}
.hidden{display:none!important}
.muted{color:var(--muted);font-size:13px}
.msg{font-size:13px;margin-top:8px;min-height:16px}

/* ---- standard buttons (v2): solid, rounded, icon + label, colour by action ----
   primary blue = main action · green = positive/confirm · navy = lock ·
   red = delete/destructive · plain .btn = secondary (white) */
.btn{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--line);background:#fff;color:var(--ink);border-radius:12px;padding:9px 16px;cursor:pointer;font-size:14px;font-weight:600;line-height:1.25;white-space:nowrap}
.btn.primary{background:var(--blue);border-color:var(--blue);color:#fff;box-shadow:0 2px 8px rgba(30,99,255,.25)}
.btn.green{background:var(--green);border-color:var(--green);color:#fff;box-shadow:0 2px 8px rgba(14,159,110,.25)}
.btn.dark{background:var(--navy);border-color:var(--navy);color:#fff;box-shadow:0 2px 8px rgba(28,43,74,.25)}
.btn.danger{background:var(--red);border-color:var(--red);color:#fff}
.btn.sm{padding:6px 11px;font-size:13px;border-radius:10px}
.btn.ghost{background:transparent;box-shadow:none}
.btn.big{width:100%;padding:12px;font-size:16px;margin-top:10px;justify-content:center}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn:hover:not(:disabled){filter:brightness(1.06)}
/* v4: every icon is an inline SVG (public/icons.js), stroke = currentColor,
   so it takes the colour of its button / pill / menu item automatically. */
.ic-svg{display:inline-block;vertical-align:-.18em;flex:0 0 auto}
input,select{width:100%;padding:9px 10px;border:1px solid var(--line);border-radius:10px;font-size:14px;background:#fff;margin-top:4px}
label{font-size:13px;color:var(--muted);display:block}
a{color:var(--blue)}

/* ---- language toggle (v2): small ខ្មែរ | ENG pill ---- */
.lang-toggle{display:inline-flex;align-items:center;background:#eef1f7;border:1px solid var(--line);border-radius:999px;padding:2px;font-size:13px;flex:0 0 auto}
.lang-toggle button{border:none;background:transparent;padding:5px 11px;border-radius:999px;cursor:pointer;font-weight:700;color:var(--muted);font-family:inherit;font-size:13px;line-height:1.3}
.lang-toggle button.on{background:#fff;color:var(--blue);box-shadow:0 1px 4px rgba(30,60,120,.18)}
.auth-lang{position:fixed;top:14px;right:14px;z-index:20;background:#fff}

/* ---- file pick row (v2): styled solid button on the LEFT, file name to its right ---- */
.file-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:6px 0 4px}
.file-btn{cursor:pointer;margin:0}
.file-name{font-size:14px;color:var(--ink);word-break:break-all;min-width:0}
.visually-hidden{position:absolute!important;width:1px;height:1px;opacity:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---- login / setup (v4): split screen in the FINOTIC reference mood ----
   Left (~45%): very light blue-grey hero — brand top-left, soft floating
   product cards in the middle, big headline at the bottom-left.
   Right: white panel — KH|ENG toggle top-right (fixed .auth-lang), centred
   ~360px form column, small © footer pinned at the bottom.
   Below 1024px: single column — compact brand band, cards hidden, form below. */
.logo-badge{display:inline-flex;align-items:center;justify-content:center;width:52px;height:52px;border-radius:14px;background:linear-gradient(135deg,var(--blue),var(--blue2));color:#fff;font-weight:800;font-size:20px}
.auth-wrap{min-height:100vh}
.auth-shell{display:flex;min-height:100vh}
.auth-hero{width:45%;background:#f2f6fc;padding:34px 42px;display:flex;flex-direction:column;overflow:hidden}
.auth-brand{display:flex;gap:11px;align-items:center}
.auth-brand-text strong{display:block;color:var(--ink);font-size:16.5px;line-height:1.25}
.auth-brand-text small{display:block;color:var(--muted);font-size:12.5px;margin-top:1px}
.auth-cards{position:relative;flex:1 1 auto;min-height:360px;margin:26px 0 8px}
.float-card{position:absolute;background:#fff;border-radius:16px;box-shadow:0 14px 34px rgba(30,60,120,.10);padding:16px 18px}
.float-card .fc-title{font-weight:700;font-size:13.5px;color:var(--ink)}
.fc-close{top:0;left:0;width:248px;animation:floaty 7s ease-in-out infinite alternate}
.fc-step{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--ink);margin-top:9px}
.fc-check{display:inline-flex;align-items:center;justify-content:center;width:19px;height:19px;border-radius:50%;background:#e2f5ec;color:var(--green);flex:0 0 auto}
.fc-donut{top:118px;right:0;width:172px;text-align:center;animation:floaty 8s ease-in-out infinite alternate-reverse}
.fc-donut-svg{display:block;margin:0 auto 8px}
.fc-upload{bottom:6px;left:26px;width:238px;display:flex;gap:12px;align-items:center;border:1.5px dashed #c4d3ea;background:rgba(255,255,255,.75);box-shadow:0 10px 26px rgba(30,60,120,.07);animation:floaty 9s ease-in-out infinite alternate}
.fc-up-ic{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:50%;background:var(--blue);color:#fff;flex:0 0 auto;box-shadow:0 4px 12px rgba(30,99,255,.35)}
.fc-upload .fc-sub{color:var(--muted);font-size:12px;margin-top:1px}
@keyframes floaty{from{transform:translateY(0)}to{transform:translateY(-7px)}}
@media (prefers-reduced-motion:reduce){.float-card{animation:none}}
.auth-hero-text h2{font-size:31px;margin:0 0 8px;color:var(--ink)}
.auth-hero-text p{color:var(--muted);font-size:14.5px;line-height:1.55;margin:0;max-width:360px}
.auth-form-side{flex:1 1 auto;background:#fff;display:flex;flex-direction:column;min-width:0}
.auth-form-col{flex:1 1 auto;display:flex;flex-direction:column;justify-content:center;width:100%;max-width:392px;margin:0 auto;padding:28px 16px}
.auth-form-col h2{font-size:24px;margin:0 0 6px}
.auth-form-col .muted{margin:0 0 18px}
.auth-form-col label{margin-bottom:12px;color:var(--ink);font-size:13.5px;font-weight:600}
.auth-foot{text-align:center;padding:16px;font-size:12px;color:var(--muted)}
/* form inputs with an SVG icon inside (+ eye toggle on password fields) */
.in-wrap{position:relative;display:block}
.in-wrap input{padding-left:38px;background:#f6f8fc;border-color:#e7edf6}
.in-wrap input:focus{outline:2px solid rgba(30,99,255,.35);background:#fff}
.in-wrap input.has-eye{padding-right:42px}
.in-ic{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:#8fa3c4;display:inline-flex;pointer-events:none}
.pw-eye{position:absolute;right:8px;top:50%;transform:translateY(-50%);border:none;background:transparent;cursor:pointer;color:#8fa3c4;display:inline-flex;padding:5px;border-radius:8px}
.pw-eye:hover{color:var(--blue)}
@media (max-width:1023px){
  .auth-shell{flex-direction:column}
  .auth-hero{width:100%;padding:16px 18px}
  .auth-cards,.auth-hero-text{display:none}
  .auth-form-col{justify-content:flex-start;padding-top:26px}
}

/* app shell (v3): fixed LEFT SIDEBAR navigation + slim content header.
   Desktop >=1024px: dark navy sidebar, brand at top, vertical icon menu,
   user chip + Log out pinned at the bottom. Content keeps a slim header row
   (month / branch / currency + language toggle at the top-right).
   Below 1024px the sidebar collapses to a top bar (see media query). */
#appView{display:flex;align-items:stretch}
.sidebar{position:fixed;top:0;left:0;bottom:0;width:230px;background:var(--sidebg);color:#d7e1f2;display:flex;flex-direction:column;padding:18px 14px;z-index:10}
.side-brand{display:flex;gap:11px;align-items:center;padding:2px 6px 16px;border-bottom:1px solid rgba(255,255,255,.13);margin-bottom:14px;min-width:0}
.logo-badge.side-mark{background:var(--red);width:42px;height:42px;font-size:16px;border-radius:11px;flex:0 0 auto;box-shadow:0 4px 12px rgba(224,36,36,.35)}
.side-brand-text{min-width:0}
.side-brand-text strong{display:block;color:#fff;font-size:15px;line-height:1.25}
.side-brand-text small{display:block;color:#8fa3c4;font-size:12px;margin-top:1px}
.side-nav{display:flex;flex-direction:column;gap:4px;flex:1 1 auto;overflow-y:auto;min-height:0}
.tab{display:flex;align-items:center;gap:11px;width:100%;border:none;background:transparent;color:#b7c6de;padding:11px 12px;border-radius:11px;cursor:pointer;font-size:14.5px;font-family:inherit;text-align:left;line-height:1.3}
.tab:hover{background:rgba(255,255,255,.08);color:#fff}
.tab.active{background:var(--red);color:#fff;font-weight:700;box-shadow:0 4px 14px rgba(224,36,36,.35)}
.tab-ic{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex:0 0 auto}
.side-user{border-top:1px solid rgba(255,255,255,.13);padding-top:12px;margin-top:12px}
.side-user-name{font-size:13px;color:#d7e1f2;margin:0 2px 9px;word-break:break-word;line-height:1.35}
.btn.side-logout{background:rgba(255,255,255,.09);border-color:rgba(255,255,255,.2);color:#fff;width:100%;justify-content:center;box-shadow:none}
.btn.side-logout:hover{filter:brightness(1.15)}
.content{flex:1 1 auto;min-width:0;margin-left:230px;display:flex;flex-direction:column;min-height:100vh}
.topbar{display:flex;flex-wrap:wrap;gap:12px;align-items:center;justify-content:space-between;background:#fff;padding:10px 16px;border-bottom:1px solid var(--line);position:sticky;top:0;z-index:5}
.top-filters{display:flex;gap:10px;align-items:end;flex-wrap:wrap}
.top-filters label{min-width:150px}
.top-filters input,.top-filters select{margin-top:2px}
main{padding:14px 16px 40px;max-width:1180px;margin:0 auto;width:100%}

/* sidebar collapses to a top bar below desktop width */
@media (max-width:1023px){
  #appView{flex-direction:column}
  .sidebar{position:static;width:100%;height:auto;padding:12px 12px 10px}
  .side-brand{padding:0 2px 10px;margin-bottom:10px}
  .side-nav{flex-direction:row;overflow-x:auto;overflow-y:hidden;flex:none;padding-bottom:2px;-webkit-overflow-scrolling:touch}
  .tab{width:auto;flex:0 0 auto;white-space:nowrap;padding:9px 12px}
  .side-user{display:flex;align-items:center;gap:10px;margin-top:10px;padding-top:10px}
  .side-user-name{margin:0;flex:1 1 auto}
  .btn.side-logout{width:auto;flex:0 0 auto}
  .content{margin-left:0;min-height:0}
}
.card{background:var(--card);border-radius:16px;padding:18px;margin-bottom:14px;box-shadow:0 2px 10px rgba(30,60,120,.05)}
.card h3{margin:0 0 10px}
.form-row{display:flex;gap:10px;flex-wrap:wrap;align-items:end}
.form-row label{min-width:160px;flex:0 1 auto}
.form-row .btn{margin-bottom:1px}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:10px;margin-bottom:10px}

/* KPI + close strip */
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px;margin-bottom:14px}
.kpi{border-radius:16px;padding:16px;color:#fff;background:linear-gradient(135deg,var(--blue),var(--blue2))}
.kpi:nth-child(2){background:linear-gradient(135deg,#7b5cff,#b18cff)}
.kpi:nth-child(3){background:linear-gradient(135deg,#0e9f6e,#3ec98f)}
.kpi:nth-child(4){background:linear-gradient(135deg,#d61f69,#ff7aa8)}
.kpi .k-label{font-size:12px;letter-spacing:.08em;text-transform:uppercase;opacity:.9}
.kpi .k-value{font-size:26px;font-weight:800;margin:4px 0}
.kpi .k-sub{font-size:12px;opacity:.92}
.close-strip{display:flex;gap:6px;flex-wrap:wrap;align-items:center;background:#fff;border-radius:14px;padding:12px 14px;margin-bottom:14px;font-size:13px}
.close-actions{display:inline-flex;gap:6px;flex-wrap:wrap;align-items:center;margin-left:10px}
.step{padding:6px 10px;border-radius:999px;background:#eef1f7;color:var(--muted)}
.step.done{background:#e2f5ec;color:var(--green);font-weight:700}
.step.locked{background:#fde8e8;color:var(--red);font-weight:700}
.arrow{color:var(--muted)}

/* tables */
table{width:100%;border-collapse:collapse;font-size:14px}
/* Wide tables (P&L history, entries…) scroll sideways INSIDE their card on
   narrow screens instead of pushing the whole page out (v3 mobile fix). */
#historyList,#plTable,#uploadHistory,#upPreview,#entriesList,#fixedList,#staffList{overflow-x:auto;-webkit-overflow-scrolling:touch}
th,td{padding:8px 10px;border-bottom:1px solid var(--line);text-align:right}
th:first-child,td:first-child{text-align:left}
th{color:var(--muted);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.04em}
tr.total td{font-weight:800;border-top:2px solid var(--ink)}
tr.section td{background:#f4f6fb;font-weight:700;text-align:left}
.neg{color:var(--red)}
.pos{color:var(--green)}
.pill{display:inline-block;padding:2px 8px;border-radius:999px;background:#eef1f7;font-size:12px}
.pill.warn{background:#fff3d6;color:#8a6d00}
.pill.bad{background:#fde8e8;color:var(--red)}
.clickable{cursor:pointer}
.clickable:hover td{background:#f7faff}

/* one-pager */
.onepager{background:#fff;border-radius:8px;padding:28px;max-width:1000px;margin:0 auto;box-shadow:0 2px 14px rgba(0,0,0,.08)}
.onepager h1{font-size:22px;margin:0}
.onepager .op-head{display:flex;justify-content:space-between;align-items:flex-start;border-bottom:3px solid var(--red);padding-bottom:10px}
.onepager .op-strip{display:flex;gap:4px;flex-wrap:wrap;margin:12px 0;font-size:12px}
.onepager .op-strip .step.done{background:#e2f5ec}
.onepager .op-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin:12px 0}
.onepager .op-kpi{border:1px solid var(--line);border-top:4px solid var(--blue);border-radius:10px;padding:12px}
.onepager .op-kpi.hl{border-top-color:var(--red);background:#fff7f7}
.onepager .op-kpi .v{font-size:20px;font-weight:800}
.onepager .op-cols{display:grid;grid-template-columns:1.2fr .8fr;gap:18px}
.onepager .op-foot{margin-top:14px;border-top:1px solid var(--line);padding-top:8px;font-size:12px;color:var(--muted);text-align:center}

/* ---- Telegram QR login (v7) ---- */
.or-divider{display:flex;align-items:center;gap:12px;margin:16px 0 2px;color:var(--muted);font-size:12.5px}
.or-divider::before,.or-divider::after{content:'';flex:1 1 auto;border-top:1px solid var(--line)}
.qr-box{display:flex;justify-content:center;padding:12px 0 2px}
.qr-box svg{width:216px;height:216px;max-width:72vw;border:1px solid var(--line);border-radius:12px;background:#fff}
.tg-status{text-align:center;font-size:13.5px;min-height:18px;margin:8px 0 10px}
#tgQrPanel{text-align:center}
#tgQrPanel .muted{margin-bottom:2px}
.tg-h-ic{display:inline-flex;vertical-align:-.22em;color:var(--blue)}
#tgCardBody .qr-box{justify-content:flex-start}
#tgCardBody .tg-status{text-align:left}

@media (max-width:640px){
  .onepager .op-kpis{grid-template-columns:repeat(2,1fr)}
  .onepager .op-cols{grid-template-columns:1fr}
  .onepager{padding:16px;overflow-x:auto}
  .topbar{gap:8px;padding:8px 10px}
  .top-filters label{min-width:132px}
  .side-user-name{font-size:12.5px}
}

/* ---- print: the Boss One-Pager FILLS exactly one A4 landscape page (v3) ----
   The report is sized UP to read like a full board report: the printed sheet
   is a fixed-height flex column (printable height at 9mm margins = 192mm;
   the sheet is 190mm, leaving 2mm of slack) and its sections are spaced
   down the page with the footer pinned at the bottom. Font sizes and row
   padding are set generously but measured so the tallest month (full
   August: by-shop table + both bottom columns + Top 5) still fits the one
   page — verified by headless-Chrome print-to-PDF, with and without the
   browser's own header/footer. */
@media print{
  @page{size:A4 landscape;margin:9mm}
  html,body{background:#fff}
  .sidebar,.topbar,.no-print,.auth-lang,#authView{display:none!important}
  #appView{display:block!important}
  .content{margin:0!important;min-height:0!important}
  #appView main{padding:0;max-width:none;margin:0;width:100%}
  #appView main>section:not(#tab-onepager){display:none!important}
  #tab-onepager{padding:0;margin:0}
  .onepager{box-shadow:none;max-width:none;width:100%;margin:0;border-radius:0;
    height:190mm;padding:5mm 6mm;
    display:flex;flex-direction:column;justify-content:space-between;
    break-inside:avoid;page-break-inside:avoid;
    -webkit-print-color-adjust:exact;print-color-adjust:exact}
  .onepager h1{font-size:24px}
  .onepager h4{font-size:15.5px;margin:0 0 7px}
  .onepager .op-head{padding-bottom:9px;font-size:14.5px}
  .onepager .op-head .muted{font-size:12.5px}
  .onepager .op-strip{margin:0;font-size:12.5px}
  .onepager .op-strip .step{padding:5px 10px}
  .onepager .op-kpis{gap:11px;margin:0}
  .onepager .op-kpi{padding:13px 15px;border-radius:10px}
  .onepager .op-kpi .v{font-size:29px;margin:3px 0}
  .onepager .op-kpi .k-label{font-size:11.5px}
  .onepager .op-kpi .muted{font-size:12px}
  .onepager .op-cols{gap:20px;margin-top:0!important}
  .onepager table th,.onepager table td{padding:7px 9px;font-size:13.5px}
  .onepager p.muted{font-size:11.5px;line-height:1.5;margin:7px 0 0}
  .onepager .op-foot{margin-top:0;padding-top:7px;font-size:11.5px}
  .onepager *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}
