/* Goel Ganga Tools — design system.
   Porcelain surfaces, ink type, one project accent that changes with the project. Built for iPad first (touch targets 48px). */
:root {
  --bg: #f4f5f3; --paper: #ffffff; --ink: #15171a; --slate: #5f656d; --mute: #8a9098; --line: #e1e4e1; --line-2: #cfd4d0;
  --accent: #15171a;            /* replaced per project by app.js */
  --accent-ink: #ffffff; --tint: color-mix(in srgb, var(--accent) 8%, white);
  --gg-red: #e3001b; --ok: #1f7a4d; --ok-bg: #e6f3ec; --warn: #9a5b00; --warn-bg: #fff4de; --bad: #b3261e; --bad-bg: #fbe9e7;
  --display: "Newsreader", "Times New Roman", serif; --ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px; --r-s: 6px; --side: 236px; --touch: 48px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--ui); font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(24px, 2.2vw + 16px, 34px); line-height: 1.1; } h2 { font-size: clamp(20px, 1vw + 16px, 24px); line-height: 1.2; } h3 { font-size: clamp(17px, .5vw + 15px, 19px); }
p { margin: 0 0 10px; }
.hint { font-size: 13px; color: var(--slate); }
.muted { color: var(--slate); }
.num { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Shell: sidebar + main ─────────────────────────────── */
body.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { background: var(--paper); border-right: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand img { height: 42px; display: block; }
.proj { position: relative; }
.proj > button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); cursor: pointer; text-align: left; min-height: var(--touch); }
.proj > button:hover { border-color: var(--line-2); }
.proj .sw { width: 10px; height: 36px; border-radius: 3px; background: var(--accent); flex: none; }
.proj .pn { font-family: var(--display); font-size: 19px; line-height: 1.1; }
.proj .pt { font-size: 12px; color: var(--slate); }
.proj .chev { margin-left: auto; color: var(--mute); }
.proj menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(21,23,26,.12); z-index: 20; }
.proj menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: var(--r-s); background: none; cursor: pointer; text-align: left; min-height: 44px; }
.proj menu button:hover { background: var(--bg); }
.proj menu button[disabled] { color: var(--mute); cursor: default; }
.proj menu button .sw { width: 8px; height: 26px; }
.proj menu button[aria-current] { font-weight: 600; }
nav.tools { display: flex; flex-direction: column; gap: 2px; }
nav.tools a { display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: var(--touch); border-radius: var(--r-s); text-decoration: none; color: var(--slate); }
nav.tools a:hover { background: var(--bg); color: var(--ink); }
nav.tools a[aria-current] { background: var(--tint); color: var(--ink); font-weight: 600; }
nav.tools a .n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 11px; color: var(--slate); flex: none; }
nav.tools a[aria-current] .n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
nav.tools .gap { height: 10px; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--slate); }
.me .av { width: 34px; height: 34px; border-radius: 50%; background: var(--tint); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.me .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.me button { border: 0; background: none; color: var(--slate); cursor: pointer; padding: 8px; min-height: 40px; }
main.page { padding: 28px 36px 120px; max-width: 1280px; width: 100%; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.top .crumb { font-size: 13px; color: var(--slate); margin-bottom: 6px; }
.top .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.navbtn { display: none; }
@media (max-width: 1000px) {   /* phones and upright tablets: the sidebar becomes a top bar with a Menu button */
  body.app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); border-right: 0; border-bottom: 1px solid var(--line); z-index: 30; overflow: visible; }
  .brand img { height: 30px; }
  .proj { flex: 1 1 0; min-width: 0; }
  .proj > button { padding: 4px 10px; min-height: 44px; }
  .proj .pn { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; } .proj > button > span:nth-child(2) { min-width: 0; } .proj > button br { display: none; }
  .proj .pt { display: none; }
  .navbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--paper); font-weight: 600; cursor: pointer; }
  .navbtn::before { content: ""; width: 16px; height: 10px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); box-shadow: inset 0 4px 0 -2px var(--ink); }
  nav.tools, .me { display: none; }
  .side.open nav.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 8px; flex: 1 1 100%; order: 5; padding: 6px 0 2px; max-height: calc(100vh - 140px); overflow: auto; }
  .side.open nav.tools a { min-height: 48px; } nav.tools .gap { display: none; }
  .side.open .me { display: flex; flex: 1 1 100%; order: 6; margin: 0; padding: 10px 0 4px; border-top: 1px solid var(--line); }
  main.page { padding: 20px 18px 150px; }
  .top { flex-direction: column; align-items: stretch; }
}

/* ── Buttons ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--touch); padding: 0 20px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 15px; transition: transform .08s ease, background .15s; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { background: none; border-color: transparent; color: var(--slate); padding: 0 10px; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Sections & forms ──────────────────────────────────── */
.sec { padding: 28px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; padding-top: 0; }
.sec > header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.sec > header .step { font-family: var(--display); font-size: 15px; color: var(--mute); min-width: 26px; }
.sec > header p { margin: 0; flex-basis: 100%; }
.sec > header .step + h2 + p { padding-left: 40px; }
.sec[data-off] { display: none; }
.grid:not(table) { display: grid; gap: 16px 20px; grid-template-columns: repeat(12, 1fr); }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c12 { grid-column: 1 / -1; }
@media (max-width: 900px) { .c2, .c3, .c4 { grid-column: span 6; } .c8 { grid-column: 1 / -1; } }
@media (max-width: 520px) { .c2, .c3, .c4, .c6 { grid-column: 1 / -1; } }
.f { display: block; }
.f > span { display: block; font-size: 13px; color: var(--slate); margin-bottom: 6px; }
.f > span b { color: var(--bad); font-weight: 600; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: var(--touch); padding: 10px 14px; font-size: 16px; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--paper); color: var(--ink); }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235f656d' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
textarea { min-height: 84px; resize: vertical; }
input[type=date], input[type=time], input[type=datetime-local], input[type=month] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; line-height: 1.5; }   /* iPhone draws these wider than the form otherwise */
input::-webkit-date-and-time-value { text-align: left; min-height: 1.5em; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
input:disabled, select:disabled { background: var(--bg); color: var(--slate); }
input[type=file] { font-size: 14px; width: 100%; max-width: 100%; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px 0 10px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; font-size: 14px; background: var(--paper); }
.checks label:has(input:checked) { border-color: var(--accent); background: var(--tint); }
.checks input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-s); overflow: hidden; }
.seg label { padding: 0 14px; min-height: var(--touch); display: inline-flex; align-items: center; cursor: pointer; font-size: 14px; border-right: 1px solid var(--line-2); background: var(--paper); white-space: nowrap; }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: var(--touch); cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.sub { padding: 16px 0 0; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: var(--r-s); padding: 12px 14px; font-size: 14px; margin: 12px 0; }
.note b { color: #6b3f00; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.internal { position: relative; background: #fbf7ee; border: 1px dashed #d9c9a3; color: #6b5a33; border-radius: var(--r-s); padding: 12px 14px 12px 14px; font-size: 13.5px; margin: 12px 0; }
.internal::before { content: "Internal only"; position: absolute; top: -9px; left: 12px; background: #fbf7ee; padding: 0 6px; font-size: 11px; font-weight: 700; color: #a3832f; }
.empty { padding: 40px 20px; text-align: center; color: var(--slate); border: 1px dashed var(--line-2); border-radius: var(--r); }

/* two-column page: form + sticky ledger */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; align-items: start; }
.ledger { position: sticky; top: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ledger .lh { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.ledger .lh h3 { font-size: 17px; }
.ledger .unit { padding: 14px 22px; font-size: 14px; color: var(--slate); border-bottom: 1px solid var(--line); }
.ledger .unit b { color: var(--ink); font-weight: 600; }
.ledger table { width: 100%; border-collapse: collapse; }
.ledger td { padding: 9px 22px; font-size: 14px; }
.ledger td.r { text-align: right; white-space: nowrap; }
.ledger tr.sub td { color: var(--slate); }
.ledger .tot { padding: 16px 22px 20px; background: var(--tint); border-top: 1px solid var(--line); }
.ledger .tot .k { font-size: 13px; color: var(--slate); }
.ledger .tot .v { font-family: var(--display); font-size: 34px; line-height: 1.1; letter-spacing: -0.01em; }
.ledger .tot .w { font-size: 12px; color: var(--slate); margin-top: 6px; }
.ledger .foot { padding: 12px 22px; font-size: 12px; color: var(--slate); }
@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .ledger { position: fixed; left: 0; right: 0; bottom: 0; top: auto; border-radius: 16px 16px 0 0; border-bottom: 0; box-shadow: 0 -8px 30px rgba(21,23,26,.10); z-index: 12; }
  .ledger:not(.open) .unit, .ledger:not(.open) table, .ledger:not(.open) .foot { display: none; }
  .ledger .lh { cursor: pointer; }
  .ledger .tot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
  .ledger .tot .v { font-size: 26px; } .ledger .tot .w { display: none; }
  #toast { bottom: 150px; }
}

/* ── Signature pads ────────────────────────────────────── */
.sig { margin: 14px 0 22px; }
.sig .who { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.sig .who b { font-weight: 600; }
.sig .pad { position: relative; height: 220px; background: var(--paper); border: 1.5px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.sig .pad canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sig .pad::after { content: ""; position: absolute; left: 28px; right: 28px; bottom: 48px; border-bottom: 1px dashed var(--line-2); pointer-events: none; }
.sig .pad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); font-size: 14px; pointer-events: none; }
.sig .pad.signed .ph { display: none; }
.sig .pad.signed { border-color: var(--accent); }
.sig .tools { display: flex; gap: 8px; margin-top: 8px; }
.sig .thumb { height: 60px; display: block; }

/* ── Customer sheet (Review & sign) ────────────────────── */
.sheet { position: fixed; inset: 0; background: var(--bg); z-index: 50; overflow: auto; }
.sheet .sh { position: sticky; top: 0; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 12px 24px; z-index: 2; }
.sheet .sh img { height: 34px; }
.sheet .sh .t { font-family: var(--display); font-size: 20px; }
.sheet .sh .back { margin-left: auto; }
.sheet .body { max-width: 860px; margin: 0 auto; padding: 32px 24px 160px; }
.sheet .body h2 { margin: 28px 0 12px; }
.sheet .money { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.sheet .money td { padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.sheet .money td.r { text-align: right; }
.sheet .money tr.tot td { font-family: var(--display); font-size: 24px; border: 0; background: var(--tint); }
.sheet .kvs { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 18px; }
.sheet .kvs div { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.sheet .kvs div:last-child { border: 0; }
.sheet .kvs span { color: var(--slate); min-width: 180px; }
.sheet .terms { font-size: 13.5px; color: var(--slate); }
.sheet .terms li { margin-bottom: 6px; }
.sheet .done { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); display: flex; justify-content: center; gap: 12px; }

/* ── Dashboard ─────────────────────────────────────────── */
.estates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; }
.estate { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 14px; text-align: left; cursor: pointer; min-height: 200px; transition: border-color .15s, transform .12s; color: inherit; font: inherit; }
.estate:hover { border-color: var(--line-2); }
.estate[aria-current] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.estate .logo { height: 44px; display: flex; align-items: center; }
.estate .logo img { max-height: 44px; max-width: min(200px, 100%); }
.estate.soon .logo { display: none; }
.estate h3 { font-size: 24px; }
.estate .tag { color: var(--slate); font-size: 14px; }
.estate .strip { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.estate .strip i { width: 10px; height: 10px; border-radius: 2px; background: var(--line); }
.estate .strip i.a { background: var(--estate-accent, var(--ink)); }
.estate .strip i.h { background: var(--warn); }
.estate .counts { display: flex; gap: 18px; font-size: 13px; color: var(--slate); }
.estate .counts b { font-family: var(--display); font-size: 22px; color: var(--ink); font-weight: 500; margin-right: 4px; }
.estate.soon { opacity: .6; cursor: default; }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.flow a { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; text-decoration: none; display: flex; flex-direction: column; gap: 6px; min-height: 120px; transition: border-color .15s; }
.flow a:hover { border-color: var(--ink); }
.flow a .n { font-family: var(--display); color: var(--mute); font-size: 15px; }
.flow a h3 { font-size: 21px; }
.flow a p { margin: 0; color: var(--slate); font-size: 13.5px; }
.flow a[data-off] { display: none; }

/* ── Tables (on screen) ────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.tbl th { font-weight: 600; color: var(--slate); font-size: 13px; background: var(--bg); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tblwrap { overflow-x: auto; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--slate); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.inv { display: grid; gap: 4px; font-size: 12px; }
.inv div { padding: 6px; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); text-align: center; min-height: 34px; }
.inv .b { background: var(--ink); color: #fff; border-color: var(--ink); } .inv .hd { background: var(--warn-bg); color: var(--warn); } .inv .sd { background: var(--bg); color: var(--mute); text-decoration: line-through; }
.inv .h { background: none; border: 0; font-weight: 600; color: var(--slate); }

#toast { position: fixed; bottom: 24px; left: 12px; right: 12px; margin: 0 auto; width: fit-content; max-width: min(560px, calc(100% - 24px)); transform: translateY(20px); background: var(--ink); color: #fff; padding: 14px 20px; border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 99; font-size: 14px; text-align: center; }
#toast.show { opacity: 1; transform: none; } #toast.bad { background: var(--bad); }

/* ── Login ─────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .art { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login .art h1 { font-size: 46px; font-weight: 400; max-width: 420px; }
.login .art .marks { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; opacity: .9; }
.login .art .marks img { height: 40px; }
.login .box { display: grid; place-items: center; padding: 40px 24px; }
.login .box > div { width: 100%; max-width: 380px; }
.login .box img { height: 56px; margin-bottom: 28px; }
.login .box h2 { font-size: 30px; margin-bottom: 6px; }
.login .box .btn { width: 100%; margin-top: 24px; }
#msg { margin-top: 14px; font-size: 14px; color: var(--bad); min-height: 20px; }
@media (max-width: 800px) { .login { grid-template-columns: 1fr; } .login .art { display: none; } }

/* ── Printed documents ─────────────────────────────────── */
#print-area { display: none; }
.doc { background: #fff; color: #15171a; font: 12.6px/1.62 var(--ui); font-feature-settings: "tnum" 1; }
.doc-head { background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 24px; }
.doc-head img { height: 50px; width: auto; }
.doc-head .pn { font-family: var(--display); font-style: italic; font-size: 16px; letter-spacing: .01em; opacity: .9; text-align: right; }
.doc-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 22px 0 18px; padding-bottom: 12px; border-bottom: 1.5px solid #15171a; }
.doc-title h1 { font-size: 28px; font-weight: 500; }
.doc-meta { text-align: right; font-size: 12px; color: #444; line-height: 1.6; white-space: nowrap; }
.doc-sec { break-inside: avoid; margin-bottom: 14px; }
.doc-sec h2 { font-size: 14px; font-weight: 600; font-family: var(--ui); color: var(--accent); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid #ddd; }
.doc table { width: 100%; border-collapse: collapse; }
.doc table.kv { margin-bottom: 4px; }
.doc table.kv th { width: 32%; text-align: left; font-weight: 500; color: #555; padding: 5px 10px 5px 0; vertical-align: top; }
.doc table.kv td { padding: 5px 0; border-bottom: 1px solid #eee; }
.doc table.grid { margin: 12px 0 14px; }
.doc table.grid th, .doc table.grid td { border: 1px solid #bbb; padding: 7px 9px; text-align: left; vertical-align: top; }
.doc table.grid th { background: #f3f4f2; font-weight: 600; }
.doc .r { text-align: right; } .doc tr.tot td { font-weight: 700; background: #f7f7f5; }
.doc p, .doc li { margin: 0 0 9px; text-align: justify; orphans: 3; widows: 3; }
.doc ol { padding-left: 20px; } .doc ol li { margin-bottom: 7px; }
.doc .sigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 32px; margin-top: 22px; break-inside: avoid; }
.doc .sigs div { font-size: 11.5px; line-height: 1.6; }
.doc .sigs .sigcell { display: flex; flex-direction: column; }
.doc .sigcell .sigimg, .doc .sigcell .sigspace { height: 64px; display: block; align-self: flex-start; max-width: 100%; object-fit: contain; object-position: left bottom; }
.doc .sigcell .siglabel { display: block; border-top: 1px solid #333; padding-top: 8px; }
.doc .small { font-size: 11px; color: #444; line-height: 1.55; }
.doc-foot { display: flex; align-items: stretch; gap: 22px; border-top: 1.5px solid #15171a; margin-top: 18px; padding-top: 14px; font-size: 10.5px; line-height: 1.6; color: #4a4a4a; break-inside: avoid; }
.doc-foot .mark { height: 74px; width: auto; align-self: center; }
.doc-foot .who { display: flex; flex-direction: column; justify-content: center; border-left: 1px solid #d6d6d6; padding-left: 22px; }
.doc-foot .pname { font-family: var(--display); font-size: 16px; color: #15171a; line-height: 1.25; }
.doc-foot .paddr { margin-top: 4px; }
.doc-foot .contact { margin-left: auto; text-align: right; display: flex; flex-direction: column; justify-content: center; }
.letter p { font-size: 12.4px; }
.letter .clause { margin-bottom: 11px; }
.letter .clause b { color: var(--accent); }
.letter .after-table { margin-top: 12px; }
#preview .doc { border: 1px solid var(--line); padding: 24px; margin-top: 16px; border-radius: var(--r); }

@media print {
  @page { size: A4; margin: 12mm; }
  body, body.app { display: block; background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .doc { break-after: page; }
  .doc-head, .doc table.grid th, .doc tr.tot td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ══ Any screen: phones, tablets, laptops, wall TVs, vertical kiosks ═══════════════════════════ */
html { overflow-x: clip; } body { overflow-wrap: anywhere; min-width: 0; } img, canvas, video { max-width: 100%; }
main.page, .sec, .grid:not(table), .f, .top > div { min-width: 0; }
main.page, .drawer, .sheet .body { container-type: inline-size; }
@container (max-width: 860px) { .c2, .c3, .c4 { grid-column: span 6; } .c8 { grid-column: 1 / -1; } }
@container (max-width: 560px) { .grid:not(table) { gap: 12px; } .c2, .c3, .c4, .c5, .c6, .c8, .c12, .grid:not(table) > [style*="grid-column"] { grid-column: 1 / -1 !important; } }
a, button, label, select, input, summary { touch-action: manipulation; }
.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.tbl th, .tbl td { overflow-wrap: normal; }

@media (max-width: 700px) {   /* phones */
  main.page { padding: 16px max(14px, env(safe-area-inset-right)) 150px max(14px, env(safe-area-inset-left)); }
  .top { margin-bottom: 18px; } .top .actions { display: grid; grid-template-columns: 1fr 1fr; } .top .actions > * { width: 100%; justify-content: center; text-align: center; }
  .grid:not(table) { gap: 12px; } .c2, .c3, .c4, .c5, .c6, .c8, .c12, .grid:not(table) > [style*="grid-column"] { grid-column: 1 / -1 !important; }
  .btns > .btn:not(.sm), .btns > a.btn:not(.sm) { flex: 1 1 100%; }
  .seg { display: flex; flex-wrap: wrap; } .seg label { flex: 1 1 auto; justify-content: center; white-space: normal; text-align: center; border-bottom: 1px solid var(--line-2); margin-bottom: -1px; }
  .sec > header .step + h2 + p, .sec > header p { padding-left: 0; }
  .sheet .sh { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; gap: 10px; } .sheet .sh .t { font-size: 17px; } .sheet .sh img { height: 26px; }
  .sheet .body { padding: 18px 14px 170px; } .sheet .kvs div { flex-direction: column; gap: 2px; } .sheet .kvs span { min-width: 0; }
  .sheet .money td { padding: 10px 12px; font-size: 14px; } .sheet .money tr.tot td { font-size: 19px; }
  .sheet .done { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; } .sheet .done .btn { flex: 1 1 auto; }
  .sig .pad { height: 180px; }
  .doc { font-size: 12px; } .doc-head { padding: 12px 14px; } .doc-title { flex-direction: column; align-items: flex-start; } .doc-title h1 { font-size: 22px; } .doc-meta { text-align: left; white-space: normal; }
  .doc table.kv th { width: 42%; } .doc .sigs { grid-template-columns: 1fr !important; gap: 22px; } .doc-foot { flex-wrap: wrap; gap: 12px; } .doc-foot .contact { margin-left: 0; text-align: left; }
  .doc table.grid { display: block; overflow-x: auto; }
  /* list tables become one card per row; each cell shows its column name */
  table.cards thead, table.cards tr:has(> th) { display: none; } table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards { border: 0; background: none; } table.cards tr { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
  table.cards td { border: 0 !important; padding: 4px 0 !important; text-align: left !important; } table.cards td:empty { display: none; }
  table.cards td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--slate); font-weight: 600; }
}
@media (max-width: 380px) { .btn { padding: 0 14px; } main.page { padding-left: 12px; padding-right: 12px; } }

@media (pointer: coarse) {   /* fingers: nothing smaller than a fingertip */
  .btn.sm, .chip, .checks label, nav.tools a, .proj menu button { min-height: 44px; } a[data-verify], a[data-reject], a[data-open] { display: inline-block; padding: 8px 2px; }
  input[type=checkbox], input[type=radio] { min-width: 20px; min-height: 20px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px !important; }   /* under 16px an iPhone zooms the page when you tap a box */
}

@media (min-width: 1700px) { main.page { max-width: 1480px; } }
@media (min-width: 2300px) { body { zoom: 1.4; } }   /* wall screens: everything scales up, nothing stretches thin */
@media (min-width: 3300px) { body { zoom: 2; } }
@media (min-width: 1000px) and (min-height: 1500px) and (orientation: portrait) { body { zoom: 1.3; } body.app { grid-template-columns: var(--side) minmax(0, 1fr); } }   /* vertical kiosk */

body:has(.sheet) #gg-demo { display: none !important; }   /* nothing covers the signing buttons */
.sheet .live .agr { border-radius: 12px; }
