/* NOX Invoice — mobile-first UI. Brand colours come from /brand/theme.css (CSS variables). */
:root{--primary:#4cbb17;--primary-rgb:76,187,23;--secondary:#1b3a6b;--secondary-rgb:27,58,107;--accent:#ffc107;--text:#1f2328;
--font:'Inter',system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--bg:#f3f5f8;--card:#fff;--line:#e4e8ee;--muted:#6b7280;
--red:#dc3545;--green:#198754;--amber:#b7791f;--radius:12px;--shadow:0 1px 2px rgba(16,24,40,.06),0 1px 3px rgba(16,24,40,.08);--side:248px}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;font:14px/1.5 var(--font);color:var(--text);background:var(--bg)}
a{color:var(--secondary);text-decoration:none}
a:hover{text-decoration:underline}
img{max-width:100%}
h1,h2,h3,h4{margin:0;line-height:1.25;color:var(--secondary)}
h1{font-size:20px}h2{font-size:17px}h3{font-size:15px}h4{font-size:13px}
[x-cloak]{display:none!important}

/* ---------- shell ---------- */
.shell{display:flex;min-height:100vh}
.side{width:var(--side);background:#fff;border-right:1px solid var(--line);position:fixed;inset:0 auto 0 0;overflow-y:auto;z-index:40;display:flex;flex-direction:column}
.side .brand{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--line);min-height:62px}
.side .brand img{max-height:34px;max-width:150px;object-fit:contain}
.side .brand b{color:var(--secondary);font-size:15px;line-height:1.2}
.nav{padding:8px 10px 24px;flex:1}
.nav .sec{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:14px 10px 4px;font-weight:600}
.nav a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;color:#374151;font-weight:500}
.nav a:hover{background:rgba(var(--primary-rgb),.08);text-decoration:none}
.nav a.on{background:rgba(var(--primary-rgb),.14);color:var(--secondary);font-weight:600}
.nav a svg{width:18px;height:18px;flex:0 0 18px;opacity:.75}
.main{flex:1;margin-left:var(--side);min-width:0;display:flex;flex-direction:column}
.top{position:sticky;top:0;z-index:30;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:10px;padding:10px 20px;min-height:58px}
.top .title{flex:1;font-weight:600;color:var(--secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top .menu-btn{display:none}
.content{padding:20px;max-width:1280px;width:100%;margin:0 auto 90px}
.banner{background:#fff4d6;border-bottom:1px solid #f3dfa2;padding:8px 20px;font-size:13px;color:#7a5a00}
.bottom{display:none}
.fab{display:none}
.overlay{display:none}

@media (max-width:900px){
  .side{transform:translateX(-100%);transition:transform .2s;box-shadow:0 0 30px rgba(0,0,0,.2)}
  .side.open{transform:none}
  .overlay.open{display:block;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:35}
  .main{margin-left:0}
  .top{padding:8px 12px}
  .top .menu-btn{display:inline-flex}
  .content{padding:12px 12px 100px}
  .bottom{display:flex;position:fixed;bottom:0;left:0;right:0;background:#fff;border-top:1px solid var(--line);z-index:30;padding:4px 4px calc(4px + env(safe-area-inset-bottom))}
  .bottom a{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;font-size:11px;color:var(--muted);padding:6px 0;text-decoration:none}
  .bottom a.on{color:var(--secondary);font-weight:600}
  .bottom svg{width:22px;height:22px}
  .bottom .plus{margin-top:-22px}
  .bottom .plus span{width:52px;height:52px;border-radius:50%;background:var(--primary);color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 14px rgba(var(--primary-rgb),.45)}
  .hide-sm{display:none!important}
}
@media (min-width:901px){.show-sm{display:none!important}}

/* ---------- elements ---------- */
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px;margin-bottom:16px}
.card.flush{padding:0;overflow:hidden}
.card-h{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px;flex-wrap:wrap}
.bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.bar h1{flex:1;min-width:160px}
.grid{display:grid;gap:16px}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))}.g3{grid-template-columns:repeat(3,minmax(0,1fr))}.g4{grid-template-columns:repeat(4,minmax(0,1fr))}
@media (max-width:900px){.g3,.g4{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:600px){.g2{grid-template-columns:1fr}.g3,.g4{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}}
.stat{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:14px;box-shadow:var(--shadow)}
.stat .k{font-size:12px;color:var(--muted);font-weight:500}
.stat .v{font-size:20px;font-weight:700;color:var(--secondary);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stat.green .v{color:var(--green)}.stat.red .v{color:var(--red)}
@media (max-width:600px){.stat .v{font-size:16px}}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:9px 14px;border-radius:8px;border:1px solid #cfd6de;background:#fff;color:var(--text);font:inherit;font-weight:500;cursor:pointer;white-space:nowrap;text-decoration:none!important;line-height:1.2}
.btn:hover{border-color:#9aa4ae}
.btn.primary{background:var(--primary);border-color:var(--primary);color:#fff;font-weight:600}
.btn.primary:hover{filter:brightness(.94)}
.btn.dark{background:var(--secondary);border-color:var(--secondary);color:#fff}
.btn.danger{color:var(--red);border-color:#f1c4c7}
.btn.ghost{border-color:transparent;background:transparent}
.btn.sm{padding:6px 10px;font-size:13px}
.btn.block{width:100%}
.btn svg{width:16px;height:16px}
.icon-btn{border:0;background:none;padding:6px;border-radius:6px;cursor:pointer;color:var(--muted);display:inline-flex}
.icon-btn:hover{background:#f1f3f5;color:var(--text)}
.link{background:none;border:0;padding:0;font:inherit;color:var(--secondary);cursor:pointer;text-decoration:underline}
.link.danger{color:var(--red)}
.inline{display:inline}
.btns{display:flex;gap:8px;flex-wrap:wrap}

label.f{display:block;font-size:12px;font-weight:600;color:#4b5563;margin-bottom:12px}
label.f>span.h{display:block;font-weight:400;color:var(--muted);font-size:11px;margin-top:2px}
input,select,textarea{display:block;width:100%;margin-top:4px;padding:9px 11px;border:1px solid #cfd6de;border-radius:8px;font:inherit;color:var(--text);background:#fff;min-height:40px}
textarea{resize:vertical;min-height:70px}
input:focus,select:focus,textarea:focus{outline:2px solid rgba(var(--primary-rgb),.35);border-color:var(--primary)}
input[type=checkbox],input[type=radio]{width:auto;min-height:0;display:inline-block;margin:0;accent-color:var(--primary)}
input[type=color]{padding:2px;height:40px}
.check{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:500;color:var(--text);margin-bottom:10px;cursor:pointer}
.row{display:flex;gap:12px}.row>*{flex:1;min-width:0}
.row>.btn,.row>.icon-btn{flex:0 0 auto}
@media (max-width:600px){.row.wrap-sm{flex-wrap:wrap}.row.wrap-sm>*{flex:1 1 100%}}
.muted{color:var(--muted)}.small{font-size:12px}.r{text-align:right}.c{text-align:center}.nowrap{white-space:nowrap}.b{font-weight:600}
.err{color:var(--red);font-size:12px;margin-top:2px}
.mt{margin-top:12px}.mb0{margin-bottom:0!important}.p0{padding:0}

.flash{padding:10px 14px;border-radius:10px;margin-bottom:14px;background:#e9f7ef;border:1px solid #bfe5cf;color:#14532d}
.flash.err{background:#fdecee;border-color:#f5c2c7;color:#842029}
.flash ul{margin:4px 0 0 18px;padding:0}

.badge{display:inline-block;font-size:11px;font-weight:600;padding:2px 8px;border-radius:20px;background:#eef1f4;color:#4b5563;white-space:nowrap}
.badge-paid,.badge-active,.badge-completed{background:#e3f6e9;color:#1e7a3c}
.badge-unpaid,.badge-failed,.badge-cancelled,.badge-suspended,.badge-expired{background:#fdecee;color:#a1252e}
.badge-partial,.badge-pending,.badge-pending_dns,.badge-pending_ssl,.badge-draft,.badge-in_progress,.badge-planned{background:#fff4d6;color:#8a6100}
.badge-open,.badge-converted,.badge-removing{background:#e7eefb;color:#1b3a6b}

/* tables → cards on phones */
table.t{width:100%;border-collapse:collapse}
table.t th{font-size:12px;font-weight:600;color:var(--muted);text-align:left;padding:10px 12px;border-bottom:1px solid var(--line);background:#fafbfc;white-space:nowrap}
table.t td{padding:10px 12px;border-bottom:1px solid var(--line);vertical-align:top}
table.t tr:last-child td{border-bottom:0}
table.t tbody tr:hover{background:#fafcff}
table.t tfoot td{font-weight:700;background:#fafbfc;border-top:1px solid var(--line)}
.scroll-x{overflow-x:auto;-webkit-overflow-scrolling:touch}
@media (max-width:700px){
  table.t.stack thead{display:none}
  table.t.stack,table.t.stack tbody,table.t.stack tr,table.t.stack td{display:block;width:100%}
  table.t.stack tr{padding:10px 12px;border-bottom:1px solid var(--line)}
  table.t.stack td{border:0;padding:2px 0;display:flex;justify-content:space-between;gap:10px;text-align:right}
  table.t.stack td::before{content:attr(data-l);color:var(--muted);font-size:12px;text-align:left;flex:0 0 auto}
  table.t.stack td.lead{font-size:15px;text-align:left;display:block}
  table.t.stack td.lead::before{content:none}
  table.t.stack tfoot td{display:flex}
}

.empty{text-align:center;color:var(--muted);padding:40px 16px}
.empty .btn{margin-top:10px}
.filters{display:flex;gap:8px;flex-wrap:wrap;align-items:flex-end;margin-bottom:12px}
.filters input,.filters select{margin:0;min-width:0;width:auto;flex:1 1 140px}
.filters .btn{flex:0 0 auto}
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin-bottom:14px;overflow-x:auto}
.tabs a{padding:9px 14px;color:var(--muted);font-weight:500;border-bottom:2px solid transparent;white-space:nowrap;text-decoration:none}
.tabs a.on{color:var(--secondary);border-color:var(--primary);font-weight:600}
.kv{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;font-size:13px}
.kv dt{color:var(--muted)}.kv dd{margin:0;font-weight:500}
.list-links a{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;border-bottom:1px solid var(--line);color:var(--text);text-decoration:none}
.list-links a:last-child{border-bottom:0}
.list-links a:hover{background:#fafcff}
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
.tile{display:flex;flex-direction:column;align-items:flex-start;gap:6px;padding:14px;background:#fff;border:1px solid var(--line);border-radius:var(--radius);color:var(--text);text-decoration:none!important;box-shadow:var(--shadow)}
.tile:hover{border-color:rgba(var(--primary-rgb),.6)}
.tile svg{width:22px;height:22px;color:var(--primary)}
.tile b{font-size:13px}
.chart{display:flex;align-items:flex-end;gap:10px;height:150px;padding-top:10px}
.chart .col{flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;height:100%;justify-content:flex-end}
.chart .bar-v{width:100%;max-width:44px;background:linear-gradient(180deg,var(--primary),rgba(var(--primary-rgb),.6));border-radius:6px 6px 0 0;min-height:2px}
.chart small{font-size:11px;color:var(--muted)}

/* document editor */
.editor .lines{width:100%;border-collapse:collapse}
.editor .lines th{font-size:11px;font-weight:600;color:var(--muted);text-align:left;padding:6px 4px;border-bottom:1px solid var(--line);white-space:nowrap}
.editor .lines td{padding:6px 4px;vertical-align:top;border-bottom:1px solid #f0f2f5}
.editor .lines input,.editor .lines select,.editor .lines textarea{margin:0;padding:7px 8px;min-height:36px}
.editor .lines textarea{min-height:36px;height:36px}
.editor .lines .amt{font-weight:600;padding-top:14px;text-align:right;white-space:nowrap}
.editor .w-qty{width:80px}.editor .w-rate{width:110px}.editor .w-tax{width:84px}.editor .w-unit{width:76px}.editor .w-hsn{width:92px}.editor .w-disc{width:76px}.editor .w-amt{width:110px}
.picker{position:relative}
.picker .dd{position:absolute;left:0;right:0;top:100%;z-index:20;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.12);max-height:280px;overflow:auto;margin-top:2px}
.picker .dd div{padding:8px 10px;cursor:pointer;border-bottom:1px solid #f3f4f6;font-size:13px}
.picker .dd div:hover,.picker .dd div.hl{background:rgba(var(--primary-rgb),.1)}
.picker .dd .sub{font-size:11px;color:var(--muted)}
.totals div{display:flex;justify-content:space-between;padding:6px 0;border-bottom:1px solid #f0f2f5;gap:10px}
.totals .grand{font-size:18px;font-weight:700;color:var(--secondary);border-top:2px solid var(--primary);border-bottom:0;padding-top:10px}
.sticky-actions{position:sticky;bottom:0;background:rgba(243,245,248,.96);backdrop-filter:blur(4px);padding:10px 0;display:flex;gap:8px;justify-content:flex-end;z-index:5;border-top:1px solid var(--line)}
@media (max-width:900px){
  .sticky-actions{bottom:62px;padding:8px 0}
  .editor .lines thead{display:none}
  .editor .lines tr{display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;padding:10px 0;border-bottom:1px solid var(--line)}
  .editor .lines td{border:0;padding:0}
  .editor .lines td.desc{grid-column:1/-1}
  .editor .lines td[data-l]::before{content:attr(data-l);display:block;font-size:10px;color:var(--muted);font-weight:600}
  .editor .lines .amt{padding-top:16px}
  .editor .w-qty,.editor .w-rate,.editor .w-tax,.editor .w-unit,.editor .w-hsn,.editor .w-disc,.editor .w-amt{width:auto}
}
.preview-frame{width:100%;height:1120px;border:0;background:#fff;border-radius:8px;box-shadow:var(--shadow)}
@media (max-width:700px){.preview-frame{height:78vh}}
.swatch{display:inline-block;width:18px;height:18px;border-radius:4px;border:1px solid rgba(0,0,0,.1);vertical-align:middle}
.auth-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px;background:linear-gradient(160deg,rgba(var(--primary-rgb),.12),rgba(var(--secondary-rgb),.08))}
.auth{width:100%;max-width:400px}
.auth .logo{max-height:52px;max-width:220px;margin-bottom:6px}
.modal-bg{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:60;display:flex;align-items:center;justify-content:center;padding:16px}
.modal{background:#fff;border-radius:14px;width:100%;max-width:560px;max-height:90vh;overflow:auto;padding:18px;box-shadow:0 20px 60px rgba(0,0,0,.25)}
.modal h3{margin-bottom:12px}
details.more{border:1px dashed var(--line);border-radius:10px;padding:10px 12px;margin-bottom:12px}
details.more summary{cursor:pointer;font-weight:600;color:var(--secondary)}
.pager{display:flex;gap:6px;justify-content:center;align-items:center;padding:12px;flex-wrap:wrap}
.pager a,.pager span{padding:6px 11px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--text);font-size:13px}
.pager span.on{background:var(--primary);color:#fff;border-color:var(--primary)}
.pager span.dis{color:#bbb}
hr.sep{border:0;border-top:1px solid var(--line);margin:14px 0}
code.inline-code{background:#f3f4f6;border-radius:4px;padding:1px 6px;font-size:12px}
.line-extra{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.line-extra label{display:flex;flex-direction:column;font-size:10px;color:var(--muted);font-weight:600;min-width:92px;flex:1 1 92px}
.line-extra input{min-height:30px;padding:4px 7px;font-size:12px;margin-top:2px}
.company-switch{margin:0;min-height:34px;padding:5px 8px;max-width:220px;font-weight:600;color:var(--secondary)}
.cat-pill{display:inline-block;font-size:11px;background:rgba(var(--primary-rgb),.12);color:var(--secondary);border-radius:20px;padding:2px 8px}
.grid-att td,.grid-att th{padding:4px 3px!important;text-align:center;font-size:11px}
.att-P{background:#e3f6e9}.att-A{background:#fdecee}.att-H{background:#fff4d6}.att-L{background:#e7eefb}.att-WO,.att-HO{background:#f1f3f5;color:#888}
.seg{display:inline-flex;border:1px solid #cfd6de;border-radius:8px;overflow:hidden}
.seg label{margin:0;padding:6px 9px;font-size:12px;cursor:pointer;border-right:1px solid #e3e7eb;color:var(--text);font-weight:600}
.seg label:last-child{border-right:0}
.seg input{display:none}
.seg input:checked+span{color:#fff}
.seg label:has(input:checked){background:var(--primary);color:#fff}
.designer{display:grid;grid-template-columns:360px minmax(0,1fr);gap:16px;align-items:start}
.designer .preview-frame{height:1050px}
@media (max-width:1000px){.designer{grid-template-columns:1fr}.designer .preview-frame{height:80vh}}
.themes{display:grid;grid-template-columns:repeat(2,1fr);gap:6px}
.themes label{border:1px solid var(--line);border-radius:8px;padding:8px;font-size:12px;cursor:pointer;margin:0;color:var(--text);font-weight:600}
.themes label:has(input:checked){border-color:var(--primary);background:rgba(var(--primary-rgb),.08)}
.themes input{display:none}
.badge-filed,.badge-finalized{background:#e3f6e9;color:#1e7a3c}.badge-prepared{background:#fff4d6;color:#8a6100}
.seg button{border:0;border-right:1px solid #e3e7eb;background:#fff;padding:8px 12px;font:inherit;font-size:13px;color:var(--muted);cursor:pointer}
.seg button:last-child{border-right:0}
.seg button b{color:var(--text);margin-right:4px}
.seg button.on{background:var(--primary);color:#fff}
.seg button.on b{color:#fff}
.badge-b2b{background:#e7eefb;color:#1b3a6b}.badge-b2c{background:#f1f3f5;color:#4a5562}
.editor .amt-in{text-align:right;font-weight:600;margin:0}
.editor .hist{position:relative;display:flex;flex-wrap:wrap;gap:4px 12px;align-items:center;font-size:12px;margin-top:4px;line-height:1.4}
.editor .hist b{color:var(--text)}
.editor .hist button.link{background:none;border:0;padding:0;font:inherit;color:var(--secondary);cursor:pointer;text-decoration:underline dotted}
.editor .hist-pop{position:absolute;top:100%;left:0;z-index:40;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:0 14px 34px -14px rgba(0,0,0,.35);padding:10px 12px;display:grid;gap:10px;min-width:440px;max-width:92vw}
.editor .hist-pop h4{margin:0 0 4px;font-size:12px;color:var(--muted)}
.editor .hist-pop table{border-collapse:collapse;width:100%;font-size:12px}
.editor .hist-pop th,.editor .hist-pop td{padding:3px 6px;border-bottom:1px solid #eef1f4;text-align:left;white-space:nowrap}
.editor .hist-pop .r{text-align:right}
.below-cost{display:block;margin-top:4px;padding:4px 8px;border-radius:6px;background:#fdecec;color:#c62828;border:1px solid #f5b5b5;font-size:12px;font-weight:600;line-height:1.35}
.sticky-actions .below-cost{display:inline-block;margin-top:0;font-size:13px}
.editor select.w-unit{min-width:64px}
.editor .serials{display:block;min-width:220px}
.editor .serials .sn{margin-bottom:4px}
.editor .serials .sn-row{display:flex;gap:4px;align-items:center}
.editor .serials .sn-row input{flex:1;margin:0}
.editor .serials .sn-row input.bad{border-color:#e57373;background:#fff6f6}
.editor .serials .sn-warn{font-size:12px;color:#c62828;font-weight:600;margin:2px 0 0}
.editor .serials .sn-warn a{color:#c62828}
.editor .serials .sn-foot{display:flex;gap:8px;align-items:center;margin-top:2px}
.line-extra label.lx-serial{flex:1 1 100%;max-width:420px;margin-bottom:4px}
.line-extra{gap:8px 12px}
.perm-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:8px}
.perm{display:flex;gap:8px;align-items:flex-start;border:1px solid var(--line);border-radius:10px;padding:9px 10px;cursor:pointer;line-height:1.35}
.perm input{margin-top:3px}
.perm.sens{border-color:#f3c4c4;background:#fffafa}
.sens-tag{display:inline-block;font-size:10px;font-weight:700;color:#b91c1c;background:#fdecec;border-radius:6px;padding:1px 6px;vertical-align:1px}
.nox-net{position:fixed;left:50%;transform:translateX(-50%);top:8px;z-index:9000;padding:9px 16px;border-radius:10px;font-size:13px;box-shadow:0 6px 24px rgba(0,0,0,.18);max-width:calc(100% - 32px)}
.nox-net.off{background:#c62828;color:#fff}
.nox-net.on{background:#16a34a;color:#fff}
.nox-draft{display:flex;gap:8px;align-items:center;flex-wrap:wrap;background:#fff8e1;border-color:#f3d27a;color:#6b4e00}
.nox-draft span{margin-right:auto}
.perm-group{border-top:1px solid var(--line);padding:10px 0 4px}
.perm-group:first-of-type{border-top:0}
.perm-head{display:flex;gap:8px;align-items:center;margin-bottom:8px;cursor:pointer}
/* bill payment: mode + full / partial / credit */
.paybox{display:flex;flex-direction:column;gap:8px}
.paybox select,.paybox input[type=number]{width:100%}
.seg{display:flex;gap:6px;flex-wrap:wrap;margin:2px 0 6px}
.seg label{flex:1 1 130px;display:flex;align-items:center;gap:6px;padding:8px 10px;border:1px solid var(--line);border-radius:8px;cursor:pointer;font-size:13px;background:#fff;min-height:40px}
.seg label.on{border-color:var(--green);background:#eef9f0}
.seg input{margin:0;width:auto}
.seg b{margin-left:auto}
.pay-err,.qty-err{color:#c62828;background:#fdecec;border:1px solid #f5b5b5;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:600}
.qty-err{margin-top:3px;white-space:nowrap}
input.bad{border-color:#c62828!important;background:#fff6f6}
.totals .paybox div{display:block;border-bottom:0;padding:0}
.totals .paybox .row{display:flex}
.totals .paybox .seg{display:flex}
.totals .paybox .pay-err{padding:6px 8px;border-bottom:1px solid #f5b5b5}
.totals .paybox .small.mt{margin-top:2px}
@media (max-width:900px){
  .editor .lines,.editor .lines tbody{display:block;width:100%}
  .editor .lines tr{grid-template-columns:repeat(3,minmax(0,1fr))}
  .editor .lines td{min-width:0}
  .editor .lines td input,.editor .lines td select,.editor .lines td textarea{width:100%;max-width:100%;box-sizing:border-box}
  .editor .serials{min-width:0}
  .editor .line-extra label{min-width:0}
  .totals .paybox .row.wrap-sm>*{flex:1 1 100%}
}
/* small screens: nothing wider than the screen */
@media (max-width:600px){.g2{grid-template-columns:minmax(0,1fr)}}
.card{min-width:0}
input,select,textarea{max-width:100%}
input[type=file]{width:100%;font-size:13px}
.bk .row>.btn,.bk .row form .btn{min-height:40px}
.bk .row>form,.bk .row>.btn{flex:0 0 auto}
@media (max-width:600px){.bk .row>form,.bk .row>.btn{flex:1 1 100%}.bk .row form .btn{width:100%;justify-content:center}}
.bk .row{flex-wrap:wrap}
/* bill line extras: one compact row (MRP · batch · expiry · warranty · serial chip) */
.editor .line-extra{display:flex;flex-wrap:wrap;gap:6px 10px;margin-top:5px;align-items:center}
.editor .line-extra .lx{display:inline-flex;align-items:center;gap:4px;font-size:11px;color:var(--muted);font-weight:600}
.editor .line-extra .lx>span{display:inline-flex;align-items:center}
.editor .line-extra .lx-l{white-space:nowrap}
.editor .line-extra .lx input{width:82px;min-height:28px!important;height:28px;padding:3px 7px!important;font-size:12px;margin:0!important}
.editor .line-extra .lx-batch input{width:100px}
.editor .line-extra .lx-expiry input{width:130px}
.sn-chip{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border:1px dashed #b8c2cc;border-radius:7px;background:#fff;color:var(--secondary);font:inherit;font-size:12px;font-weight:600;cursor:pointer;max-width:320px;white-space:nowrap}
.sn-chip.has{border-style:solid;border-color:var(--primary);background:#f2faf3}
.sn-chip.bad{border-color:#c62828;background:#fff6f6;color:#c62828}
.sn-chip .sn-prev{font-weight:400;color:var(--muted);overflow:hidden;text-overflow:ellipsis;max-width:170px}
.sn-modal{max-width:460px}
.sn-modal .serials{max-height:55vh;overflow:auto;min-width:0}
.sn-modal .sn-n{width:22px;text-align:right;font-size:12px;color:var(--muted);flex:0 0 22px}
.sn-modal .sn-row input{min-height:38px}
@media (max-width:900px){
  .editor .line-extra .lx input{width:76px!important;max-width:none}
  .editor .line-extra .lx-expiry input{width:124px!important}
  .sn-chip{max-width:100%}
}
/* each bill line = a tbody: the main row + one slim row for MRP / warranty / serial */
.editor .lines tbody.ln tr:first-child td{border-bottom:0}
.editor .lines tr.lx-row td{padding:0 4px 8px;border-bottom:1px solid #f0f2f5}
.editor .lines tr.lx-row .line-extra{margin-top:0}
@media (max-width:900px){
  .editor .lines tbody.ln{border-bottom:1px solid var(--line)}
  .editor .lines tbody.ln tr:first-child{border-bottom:0;padding-bottom:4px}
  .editor .lines tr.lx-row{display:block;padding:0 0 10px;border:0}
  .editor .lines tr.lx-row td{display:block;padding:0;border:0}
  .editor .lines tr.lx-row td::before{display:none}
}
.sn-modal .sn-row{display:flex;gap:6px;align-items:center}
.sn-modal .sn-row input{flex:1;margin:0;min-width:0}
.sn-modal .sn-new{min-height:42px;font-size:15px}
.sn-modal .serials .sn{margin-bottom:4px}
/* icon buttons always have a visible icon */
.icon-btn svg{width:18px;height:18px;flex:0 0 18px}
.line-rm{color:#c62828;align-items:center;gap:4px;font:inherit;font-size:12px;font-weight:600}
.line-rm:hover{background:#fdecec;color:#b71c1c}
.editor .lines td.rm{padding-top:10px}
/* tablet / small laptop: narrower columns so the whole line (with Remove) fits */
@media (min-width:901px) and (max-width:1300px){
  .editor .w-qty{width:64px}.editor .w-rate{width:88px}.editor .w-tax{width:72px}.editor .w-unit{width:68px}.editor .w-hsn{width:74px}.editor .w-disc{width:62px}.editor .w-amt{width:88px}
  .editor .lines input,.editor .lines select{padding:7px 5px}
  .editor .lines .amt{font-size:13px}
}
@media (max-width:900px){
  .editor .lines td.rm{grid-column:3;justify-self:end;align-self:end;padding:0}
  .line-rm{border:1px solid #f5b5b5;padding:6px 10px}
}
@media (min-width:901px) and (max-width:1100px){
  .editor .w-qty{width:56px}.editor .w-rate{width:78px}.editor .w-tax{width:64px}.editor .w-unit{width:62px}.editor .w-hsn{width:62px}.editor .w-disc{width:54px}.editor .w-amt{width:76px}
  .editor .lines td{padding:6px 2px}
  .editor .lines td.rm{padding-left:0;padding-right:0}
  .editor .lines td.rm .icon-btn{padding:4px}
}
/* ===== bill entries: one numbered box per entry (all bill types) ===== */
.editor .lines .ln-desc{display:flex;gap:6px;align-items:flex-start}
.editor .lines .ln-desc .picker{flex:1;min-width:0}
.ln-no{flex:0 0 auto;min-width:26px;height:26px;margin-top:5px;padding:0 6px;border-radius:13px;background:var(--secondary);color:#fff;font-size:12px;font-weight:700;display:inline-flex;align-items:center;justify-content:center}
.ln-no-h{display:inline-block;min-width:26px;text-align:center;margin-right:6px}
@media (min-width:901px){
  .editor .lines{display:block;--lc:minmax(180px,1fr) 92px 80px 76px 110px 76px 84px 110px 36px}
  .editor .lines.has-cess{--lc:minmax(170px,1fr) 92px 80px 76px 110px 76px 84px 76px 110px 36px}
  .editor .lines thead,.editor .lines tbody.ln{display:block}
  .editor .lines thead tr,.editor .lines tbody.ln>tr:first-child{display:grid;grid-template-columns:var(--lc);column-gap:6px;align-items:start}
  .editor .lines thead tr{padding:0 10px}
  .editor .lines th{border:0;padding:6px 0}
  .editor .lines tbody.ln td{display:block;padding:0;border:0;min-width:0}
  .editor .lines tbody.ln>tr:first-child td input,.editor .lines tbody.ln>tr:first-child td select,.editor .lines tbody.ln>tr:first-child td textarea{width:100%}
  .editor .lines tbody.ln td.rm{padding-top:4px;justify-self:center}
  .editor .lines tbody.ln tr.lx-row{display:block}
  .editor .lines tbody.ln tr.lx-row td{padding:6px 0 0 32px}
}
@media (min-width:901px) and (max-width:1300px){
  .editor .lines{--lc:minmax(150px,1fr) 70px 64px 66px 88px 62px 72px 88px 32px}
  .editor .lines.has-cess{--lc:minmax(140px,1fr) 66px 60px 62px 84px 58px 68px 58px 84px 32px}
}
.editor .lines tbody.ln{border:1px solid #d5dce4!important;border-radius:10px;background:#fff;margin:0 0 10px;padding:10px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
.editor .lines tbody.ln:focus-within{border-color:var(--primary)!important;box-shadow:0 0 0 3px rgba(var(--primary-rgb),.12)}
.editor .lines tbody.ln tr:first-child td,.editor .lines tbody.ln tr.lx-row td{border-bottom:0!important}
@media (max-width:900px){
  .editor .lines tbody.ln{padding:10px;margin-bottom:12px}
  .editor .lines tbody.ln tr:first-child{padding:0 0 6px!important;border:0!important}
  .editor .lines tr.lx-row{padding:6px 0 0!important;border-top:1px dashed #e3e8ee!important}
}
@media (min-width:901px){
  .editor .lines tbody.ln tr.lx-row td input{width:82px}
  .editor .lines tbody.ln tr.lx-row .lx-expiry input{width:130px}
  .editor .lines tbody.ln tr.lx-row .lx-batch input{width:100px}
  .editor .lines th.r{text-align:right}
}
/* tablet / small laptop: item name across the top of the box, the numbers in one labelled row below */
@media (min-width:901px) and (max-width:1180px){
  .editor .lines thead{display:none}
  .editor .lines{--lc:repeat(7,minmax(0,1fr)) minmax(0,1.2fr) 34px}
  .editor .lines.has-cess{--lc:repeat(8,minmax(0,1fr)) minmax(0,1.2fr) 34px}
  .editor .lines tbody.ln>tr:first-child{row-gap:6px}
  .editor .lines tbody.ln td.desc{grid-column:1/-1}
  .editor .lines tbody.ln td[data-l]::before{content:attr(data-l);display:block;font-size:10px;color:var(--muted);font-weight:600;margin-bottom:2px}
  .editor .lines tbody.ln td.amt{padding-top:18px;text-align:right}
  .editor .lines tbody.ln td.rm{align-self:end;padding-bottom:4px}
  .editor .lines tbody.ln td input,.editor .lines tbody.ln td select{padding:7px 5px}
}
/* numbered entry boxes on other line screens (BOM, production) */
.ln-box{align-items:flex-end;border:1px solid #d5dce4;border-radius:10px;padding:10px;margin-bottom:10px;background:#fff}
.ln-box:focus-within{border-color:var(--primary);box-shadow:0 0 0 3px rgba(var(--primary-rgb),.12)}
.ln-box>.ln-no{align-self:center;margin-top:0}
@media (max-width:600px){.row.wrap-sm.ln-box>.ln-no{flex:0 0 auto}}
/* Cash & Bank: on/off switches for invoices */
.stat.acct{display:flex;flex-direction:column;gap:8px}
.acct-sw{display:flex;flex-direction:column;gap:4px;border-top:1px dashed var(--line);padding-top:8px}
.acct-sw form{margin:0}
.sw{display:inline-flex;align-items:center;gap:8px;border:0;background:none;padding:2px 0;font:inherit;font-size:12.5px;color:var(--text);cursor:pointer}
.sw span{position:relative;width:32px;height:18px;border-radius:9px;background:#cfd6de;flex:0 0 32px;transition:background .15s}
.sw span::after{content:'';position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:#fff;transition:left .15s}
.sw.on span{background:var(--green,#16a34a)}
.sw.on span::after{left:16px}
.totals .paybox .print-acc{border-top:1px dashed var(--line);padding-top:8px;margin-top:2px}
.totals .paybox .print-acc .row{display:flex;gap:8px}
.totals .paybox .print-acc .row>label{flex:1 1 160px;min-width:0}
.plan-screens{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px}
.plan-screens .ps-grp{border:1px solid var(--line);border-radius:10px;padding:6px 10px 8px;margin:0}
.plan-screens .ps-grp legend{padding:0 4px}
.plan-screens .ps-grp .check{font-size:13px;margin:3px 0}
/* WhatsApp result / warning on the bill page */
.wa-note{border-radius:10px;padding:9px 12px;margin:0 0 12px;font-size:13.5px;border:1px solid}
.wa-note.ok{background:#eef9f0;border-color:#bfe5c8;color:#14532d}
.wa-note.bad{background:#fff7e6;border-color:#f5d08a;color:#7a4b00}
.wa-off{display:block;margin:0 12px 8px;padding:7px 10px;border-radius:8px;background:#fff7e6;border:1px solid #f5d08a;color:#7a4b00!important;font-size:12px;line-height:1.35;text-decoration:none}
/* WhatsApp connect: QR popup + party popup */
.wa-connect{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin:8px 0 10px;background:#fbfdfb}
.wa-qr-modal{max-width:400px}
.wa-qr{display:flex;align-items:center;justify-content:center;min-height:260px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:10px}
.wa-qr img{width:240px;height:240px;image-rendering:pixelated}
.wa-code{font:700 28px/1.2 ui-monospace,Menlo,Consolas,monospace;letter-spacing:4px;text-align:center;margin:12px 0;color:var(--secondary)}
.wa-party{position:fixed;inset:0;z-index:2000;background:rgba(0,0,0,.35);display:flex;align-items:center;justify-content:center;overflow:hidden}
.wa-party-box{position:relative;z-index:2;background:#fff;border-radius:18px;padding:26px 28px;text-align:center;max-width:360px;box-shadow:0 20px 60px rgba(0,0,0,.3);animation:wa-pop .45s cubic-bezier(.2,1.6,.4,1)}
.wa-party-box h3{margin:6px 0}
.wa-party-emoji{font-size:54px;line-height:1}
.wa-party .cf{position:absolute;top:-12px;width:9px;height:14px;border-radius:2px;animation:wa-fall linear forwards;z-index:1}
@keyframes wa-pop{from{transform:scale(.6);opacity:0}to{transform:scale(1);opacity:1}}
@keyframes wa-fall{to{top:105%;transform:rotate(720deg)}}
/* guided tour */
.nt-block{position:fixed;inset:0;z-index:9990;background:transparent}
.nt-hole{position:fixed;z-index:9991;border-radius:10px;box-shadow:0 0 0 9999px rgba(10,22,40,.58);outline:3px solid var(--primary,#4cbb17);outline-offset:0;pointer-events:none;transition:all .2s ease}
.nt-pop{position:fixed;z-index:9992;width:min(380px,calc(100vw - 16px));background:#fff;border-radius:14px;box-shadow:0 18px 50px rgba(10,22,40,.35);padding:14px 16px 12px;font-size:14px;line-height:1.55}
.nt-pop.nt-center{left:50%!important;top:50%!important;transform:translate(-50%,-50%)}
.nt-pop h4{margin:6px 0 4px;font-size:16px;color:var(--secondary,#0f2747)}
.nt-pop .nt-text{color:#374151}
.nt-meta{display:flex;justify-content:space-between;font-size:11.5px;color:var(--muted,#6b7280);text-transform:uppercase;letter-spacing:.04em}
.nt-bar{height:4px;background:#eef1f5;border-radius:4px;margin-top:6px;overflow:hidden}.nt-bar i{display:block;height:100%;background:var(--primary,#4cbb17)}
.nt-btns{display:flex;align-items:center;gap:8px;margin-top:12px}.nt-btns span{flex:1}
.nt-skip{background:none;border:0;color:var(--muted,#6b7280);cursor:pointer;font:inherit;font-size:13px;padding:4px 0}
.nt-offer{position:fixed;right:18px;bottom:18px;z-index:9980;width:300px;background:#fff;border-radius:14px;box-shadow:0 14px 40px rgba(10,22,40,.25);padding:14px 16px;display:flex;flex-direction:column;gap:2px;border-top:4px solid var(--primary,#4cbb17)}
.nt-offer span{color:var(--muted,#6b7280);font-size:13.5px}
@media (max-width:640px){.nt-pop{width:auto}.nt-offer{left:10px;right:10px;bottom:80px;width:auto}}
@media print{.nt-block,.nt-hole,.nt-pop,.nt-offer{display:none!important}}
