:root {
  --blue: #0B57D0;
  --blue-dark: #0842A0;
  --blue-soft: #E8F0FE;
  --blue-softer: #F4F8FF;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --bg: #F5F8FE;
  --white: #FFFFFF;
  --green: #0F9D58;
  --green-soft: #E6F4EA;
  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --red: #D93025;
  --red-soft: #FDECEA;
  --grey-soft: #F1F5F9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.hidden { display: none !important; }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--white); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #CBD5E1; background: #FAFCFF; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(11, 87, 208, .25); }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); border-color: #F5C2BE; }
.btn.danger:hover { background: var(--red-soft); }
.btn.primary.danger-fill { background: var(--red); border-color: var(--red); box-shadow: none; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--grey-soft); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > span i { color: var(--red); font-style: normal; }
.input, .field input, .field select, .field textarea { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); outline: none; transition: border-color .15s, box-shadow .15s; }
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 87, 208, .12); }
.field small { color: var(--muted); font-size: 12px; }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); }

.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)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--white); }
.auth-side { position: relative; overflow: hidden; background: linear-gradient(150deg, #0B57D0 0%, #0842A0 60%, #062F73 100%); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.auth-side::before { content: ""; position: absolute; left: -80px; top: 38%; width: 240px; height: 240px; border-radius: 50%; background: rgba(255, 255, 255, .05); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; background: #fff; }
.auth-side h1 { font-size: 38px; line-height: 1.15; margin: auto 0 16px; max-width: 460px; font-weight: 800; }
.auth-side p.lead { color: rgba(255, 255, 255, .82); font-size: 16px; max-width: 440px; margin: 0 0 28px; }
.auth-points { display: grid; gap: 12px; margin-bottom: auto; position: relative; z-index: 1; }
.auth-points div { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.auth-points svg { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: rgba(255, 255, 255, .16); flex: none; }
.auth-side .foot { color: rgba(255, 255, 255, .6); font-size: 12.5px; position: relative; z-index: 1; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--white); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card h2 { font-size: 24px; font-weight: 800; }
.auth-card .sub { color: var(--muted); margin: 6px 0 26px; }
.phone-box { display: flex; height: 48px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.phone-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 87, 208, .12); }
.phone-box b { display: grid; place-items: center; padding: 0 14px; background: var(--blue-softer); border-right: 1px solid var(--line); color: var(--ink-2); }
.phone-box input { flex: 1; border: 0; outline: none; padding: 0 14px; font-size: 16px; letter-spacing: .04em; min-width: 0; }
.otp-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp-row input { height: 52px; text-align: center; font-size: 20px; font-weight: 700; border: 1px solid var(--line); border-radius: 12px; outline: none; min-width: 0; }
.otp-row input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 87, 208, .12); }
.auth-card .btn.primary { height: 48px; font-size: 15px; border-radius: 12px; }
.auth-note { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 18px; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; cursor: pointer; }
.linkish[disabled] { color: var(--muted); cursor: default; }
.err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--white); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; z-index: 30; }
.side .brand { padding: 4px 8px 18px; font-size: 15.5px; color: var(--ink); }
.side .brand img { width: 36px; height: 36px; background: var(--blue-soft); }
.side .brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .label { font-size: 11px; font-weight: 700; color: #94A3B8; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; }
.nav a svg { width: 19px; height: 19px; color: #94A3B8; flex: none; }
.nav a:hover { background: var(--blue-softer); color: var(--ink); }
.nav a.on { background: var(--blue-soft); color: var(--blue); }
.nav a.on svg { color: var(--blue); }
.side { overflow-y: auto; }
.side .nav a { height: 36px; }
.side .nav .label { padding: 12px 12px 4px; }
.side .plan { margin-top: auto; padding: 14px; border-radius: 12px; background: linear-gradient(135deg, var(--blue-soft), #F4F8FF); border: 1px solid #D6E4FD; }
.side .plan b { display: block; font-size: 13px; }
.side .plan span { font-size: 12px; color: var(--muted); }
.side .plan a { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 700; }

.top { position: sticky; top: 0; z-index: 20; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .menu-btn { display: none; }
.top .search { flex: 1; max-width: 420px; position: relative; }
.top .search input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px 0 38px; background: var(--bg); outline: none; }
.top .search input:focus { background: #fff; border-color: var(--blue); }
.top .search svg { position: absolute; left: 12px; top: 11px; width: 18px; height: 18px; color: #94A3B8; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; cursor: pointer; border: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.menu { position: absolute; right: 0; top: 46px; width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.menu .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .who b { display: block; }
.menu .who span { color: var(--muted); font-size: 12.5px; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; border: 0; background: none; color: var(--ink-2); font-weight: 600; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--grey-soft); }
.menu svg { width: 17px; height: 17px; }

.main { min-width: 0; }
.page { padding: 26px 28px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.crumb:hover { color: var(--blue); }
.crumb svg { width: 16px; height: 16px; }

/* ---------- cards ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15.5px; font-weight: 700; }
.card-head a { font-weight: 600; font-size: 13px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title::before { content: ""; width: 4px; height: 18px; border-radius: 4px; background: var(--blue); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start; }
.stat .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .ic svg { width: 21px; height: 21px; }
.stat span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat b { display: block; font-size: 21px; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.stat small { color: var(--muted); font-size: 12px; }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-red { background: var(--red-soft); color: var(--red); }

.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.quick a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font-weight: 700; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.quick a:hover { transform: translateY(-2px); border-color: #BFD3FB; }
.quick a .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.quick a .ic svg { width: 19px; height: 19px; }
.quick a small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }

.two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }

.chart { display: flex; align-items: flex-end; gap: 14px; height: 210px; padding: 20px 20px 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart .bar i { display: block; width: 100%; max-width: 46px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #4C8DF6, var(--blue)); min-height: 4px; position: relative; }
.chart .bar i.zero { background: var(--grey-soft); }
.chart .bar span { font-size: 12px; color: var(--muted); font-weight: 600; }
.chart .bar em { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--ink-2); }

/* ---------- tables ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .input { max-width: 300px; height: 38px; }
.toolbar select.input { width: auto; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--grey-soft); border-radius: 10px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13px; }
.tabs button.on { background: #fff; color: var(--blue); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; background: #FAFBFE; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { cursor: pointer; transition: background .12s; }
table.list tbody tr:hover { background: var(--blue-softer); }
table.list .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list td b { font-weight: 700; }
table.list td small { display: block; color: var(--muted); font-size: 12px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 46px; height: 46px; color: #CBD5E1; margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.grey { background: var(--grey-soft); color: var(--muted); }

/* ---------- document form ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.form-card { padding: 22px; margin-bottom: 20px; }
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.items td { padding: 8px 6px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.items input, .items select { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 9px; outline: none; background: #fff; min-width: 0; }
.items input:focus, .items select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 87, 208, .1); }
.items .amt { text-align: right; font-weight: 700; padding-top: 17px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.items .n { text-align: right; }
.items .sno { color: var(--muted); padding-top: 17px; font-weight: 600; }
.add-row { margin-top: 12px; }
.totals { position: sticky; top: 84px; }
.totals .row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; color: var(--ink-2); }
.totals .row b { font-variant-numeric: tabular-nums; color: var(--ink); }
.totals .grand { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; font-size: 18px; font-weight: 800; color: var(--ink); }
.totals .grand b { color: var(--blue); }
.totals .words { color: var(--muted); font-size: 12.5px; margin: 6px 0 16px; }
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; z-index: 15; min-width: 260px; }
.suggest-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; }
.suggest-list button:hover, .suggest-list button.hl { background: var(--blue-softer); }
.suggest-list button b { display: block; font-weight: 600; }
.suggest-list button small { color: var(--muted); font-size: 12px; }

/* ---------- document view (printable) ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.paper { background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 36px 40px; color: #111827; font-size: 12.5px; }
.paper .p-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 3px solid var(--blue); }
.paper .p-biz { display: flex; gap: 14px; }
.paper .p-biz img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; }
.paper .p-biz h2 { font-size: 20px; font-weight: 800; color: var(--blue); }
.paper .p-biz div div { color: #4B5563; line-height: 1.55; }
.paper .p-title { text-align: right; }
.paper .p-title h3 { font-size: 22px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #111827; }
.paper .p-title table { margin-left: auto; margin-top: 8px; border-collapse: collapse; }
.paper .p-title td { padding: 2px 0 2px 14px; text-align: right; }
.paper .p-title td:first-child { color: #6B7280; }
.paper .p-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 18px 0; }
.paper .p-parties h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); }
.paper .p-parties b { font-size: 14px; }
.paper .p-parties div { color: #374151; line-height: 1.55; }
.paper table.p-items { width: 100%; border-collapse: collapse; }
.paper table.p-items th { background: var(--blue); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 8px; text-align: left; }
.paper table.p-items th.n, .paper table.p-items td.n { text-align: right; }
.paper table.p-items td { padding: 8px; border-bottom: 1px solid #E5E7EB; vertical-align: top; }
.paper table.p-items tr:nth-child(even) td { background: #F8FAFF; }
.paper .p-sum { display: grid; grid-template-columns: 1fr 280px; gap: 24px; margin-top: 16px; }
.paper .p-sum table { width: 100%; border-collapse: collapse; }
.paper .p-sum td { padding: 5px 0; }
.paper .p-sum td.n { text-align: right; font-variant-numeric: tabular-nums; }
.paper .p-sum tr.grand td { border-top: 2px solid #111827; font-size: 15px; font-weight: 800; padding-top: 9px; }
.paper .p-words { color: #374151; }
.paper .p-words b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); margin-bottom: 4px; }
.paper .p-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; padding-top: 16px; border-top: 1px solid #E5E7EB; }
.paper .p-foot h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); }
.paper .p-foot div { color: #374151; white-space: pre-line; line-height: 1.55; }
.paper .p-sign { text-align: right; }
.paper .p-sign img { max-height: 56px; max-width: 180px; display: block; margin: 8px 0 6px auto; }
.paper .p-sign > div { display: block; width: 200px; margin-left: auto; text-align: center; }
.paper .p-sign .line { margin-top: 56px; border-top: 1px solid #9CA3AF; padding-top: 6px; }
.paper .p-scroll { overflow-x: auto; }
.paper .p-scroll table { min-width: 560px; }
.paper .stamp { display: inline-block; margin-top: 6px; padding: 3px 10px; border: 2px solid currentColor; border-radius: 6px; font-weight: 800; font-size: 12px; letter-spacing: .08em; transform: rotate(-4deg); }
.side-card { padding: 18px; margin-bottom: 16px; }
.side-card .btn { width: 100%; margin-bottom: 8px; justify-content: flex-start; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; gap: 10px; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; box-shadow: 0 24px 60px rgba(15, 23, 42, .25); animation: pop .18s; max-height: calc(100vh - 40px); overflow-y: auto; }
.modal.wide { max-width: 720px; }
.modal h3 { font-size: 17px; font-weight: 800; padding: 20px 22px 0; }
.modal .body { padding: 14px 22px 4px; color: var(--ink-2); }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 22px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #0F172A; color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600; z-index: 60; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px); animation: pop .18s; }
.toast.bad { background: var(--red); }
.loader { display: grid; place-items: center; padding: 70px 0; }
.spin { width: 30px; height: 30px; border: 3px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; background: var(--amber-soft); color: #78350F; margin-bottom: 18px; font-weight: 500; }
.banner.blue { background: var(--blue-soft); color: #0B3B8C; }
.banner svg { width: 20px; height: 20px; flex: none; }
.banner .btn { margin-left: auto; }
.logo-pick { display: flex; align-items: center; gap: 16px; }
.logo-pick .box { width: 84px; height: 84px; border-radius: 14px; border: 1px dashed #BFD3FB; background: var(--blue-softer); display: grid; place-items: center; overflow: hidden; color: var(--blue); }
.logo-pick .box img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.muted { color: var(--muted); }
.right { text-align: right; }
.scrim { display: none; }
.print-only { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1440px) {
  /* the items table needs the full width; the summary moves under it */
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > aside { display: flex; justify-content: flex-end; }
  .form-grid > aside .totals { position: static; width: 100%; max-width: 420px; }
}
@media (max-width: 1100px) {
  .stats, .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two, .form-grid, .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .totals { position: static; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 24px; }
  .auth-side h1 { font-size: 28px; margin-top: 28px; }
  .auth-side .foot { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 25; }
  .top { padding: 0 16px; }
  .top .menu-btn { display: inline-grid; }
  .page { padding: 20px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .paper { padding: 22px 18px; min-width: 0; }
  .doc-layout > div { min-width: 0; }
  .paper .p-head, .paper .p-parties, .paper .p-sum, .paper .p-foot { grid-template-columns: 1fr; display: grid; }
  .paper .p-title { text-align: left; }
  .paper .p-title table { margin-left: 0; }
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .items td { border: 0; padding: 0; }
  .items td.sno { display: none; }
  .items td.c-name { grid-column: span 6; }
  .items td.c-hsn, .items td.c-unit { grid-column: span 2; }
  .items td.c-qty, .items td.c-rate, .items td.c-disc, .items td.c-gst { grid-column: span 2; }
  .items td.amt { grid-column: span 4; padding-top: 10px; }
  .items td.c-del { grid-column: span 2; text-align: right; }
}
@media (max-width: 520px) {
  .stats, .quick { grid-template-columns: minmax(0, 1fr); }
  .top .search { display: none; }
}

/* ---------- print: only the document ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .side, .top, .no-print, .doc-layout > aside, .toast, .scrim { display: none !important; }
  .shell { display: block; }
  .print-only { display: block; }
  .page-head .actions { display: none !important; }
  .card { box-shadow: none; }
  .page { padding: 0; max-width: none; }
  .doc-layout { display: block; }
  .paper { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .paper table.p-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .paper table.p-items tr:nth-child(even) td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .paper .p-scroll { overflow: visible; }
  .paper .p-scroll table { min-width: 0; }
}
