/* Basic Invoicing — hosted app. Self-contained: does not build on the legacy stylesheet. */

/* ---------- Tokens ---------- */
:root{
  --ink:#1f1f1f;
  --muted:#676767;
  --line:#e3e3e3;
  --line-strong:#d0d0d0;
  --bg:#f6f6f6;
  --surface:#fff;
  --desk:#e9e9e9;
  --red:#b3323f;
  --green:#2f7556;
  /* Set from the business colours in app.js (theme()). */
  --brand:#111111;
  --brand-text:#fff;
  --ink-accent:#111111;
  --business-accent:#f0f0f0;
  --accent-text:#1f1f1f;
  --tint:color-mix(in srgb,var(--brand) 9%,#fff);
  --radius:12px;
  --sidebar-width:236px;
  --page-gutter:32px;
  --action-bottom:0px;
  --action-height:69px;
  --display:ui-rounded,"SF Pro Rounded","Hiragino Maru Gothic ProN","Nunito",system-ui,-apple-system,"Segoe UI",sans-serif;
  --body:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  font-family:var(--body);
  font-size:15px;
  line-height:1.5;
  color:var(--ink);
  background:var(--bg);
  font-synthesis:none;
  -webkit-text-size-adjust:100%;
}

/* ---------- Base ---------- */
*,*::before,*::after{box-sizing:border-box}
body{margin:0;min-height:100vh;background:var(--bg)}
h1,h2,h3,p,dl,dd{margin:0}
h1,h2,h3{font-family:var(--display);font-weight:650;letter-spacing:-.01em;line-height:1.2}
[hidden]{display:none!important}
button,input,select,textarea{font:inherit;color:inherit}
button,a,input,select,textarea,summary{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button{cursor:pointer}
button:disabled{opacity:.55;cursor:wait}

/* ---------- Loading: one look everywhere ---------- */
/* A single spinner is used for start-up, for sections that are fetching, and on the button whose action is running. */
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes appear{from{opacity:0}to{opacity:1}}
@keyframes progress{from{transform:translateX(-100%)}to{transform:translateX(250%)}}
.spinner{display:inline-block;width:18px;height:18px;flex:none;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .7s linear infinite}
.booting #app{display:none}
.boot-loader{display:none}
/* Fades in only if start-up takes a moment, so quick loads don't flash. */
.booting .boot-loader{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;min-height:100vh;color:var(--muted);animation:appear .3s ease .25s both}
.loading-state{display:flex;align-items:center;gap:10px;padding:28px 4px;font-size:14px;color:var(--muted);animation:appear .2s ease .15s both}
.loading-state .spinner{width:16px;height:16px}
/* While an action runs: a slim bar along the top and a spinner in the button that started it. Everything else keeps its normal look. */
body.is-busy{cursor:progress}
body.is-busy::after{content:"";position:fixed;top:0;left:0;z-index:100;width:40%;height:3px;border-radius:0 3px 3px 0;background:var(--brand);pointer-events:none;animation:progress 1.1s ease-in-out infinite,appear .2s ease .15s both}
.button.is-loading{position:relative;-webkit-text-fill-color:transparent}
.button.is-loading>*{visibility:hidden}
.button.is-loading::after{content:"";position:absolute;inset:0;width:16px;height:16px;margin:auto;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .7s linear infinite}
button[data-locked]:disabled{opacity:1;cursor:progress}
:is(input,select,textarea)[data-locked]:disabled{opacity:1;color:var(--ink);-webkit-text-fill-color:var(--ink);cursor:progress}
@media (prefers-reduced-motion:reduce){.spinner,.button.is-loading::after{animation-duration:1.6s}body.is-busy::after{animation:appear .2s ease .15s both;width:100%;opacity:.6}}
@media print{body::after{display:none!important}}
a{color:var(--ink-accent)}
:focus-visible{outline:3px solid color-mix(in srgb,var(--brand) 55%,#fff);outline-offset:2px}
.sr-only{position:absolute;top:0;left:0;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.icon{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* ---------- Form controls ---------- */
label{display:block;font-size:13.5px;font-weight:550;color:var(--ink)}
label>input,label>select,label>textarea{display:block;margin-top:6px}
.optional{font-weight:400;color:var(--muted)}
input,select,textarea{
  width:100%;min-width:0;min-height:44px;padding:9px 12px;
  border:1px solid var(--line-strong);border-radius:10px;
  background:var(--surface);font-size:15px;font-weight:400;
}
textarea{resize:vertical;line-height:1.5}
/* iPhones draw date fields their own way: wider than the form and centred. These match the other fields. */
input[type=date]{appearance:none;-webkit-appearance:none;display:block;text-align:left}
input[type=date]::-webkit-date-and-time-value{min-height:1.5em;margin:0;text-align:left}
select{
  appearance:none;-webkit-appearance:none;padding-right:38px;cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23676767' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;background-size:16px;
}
input:focus,select:focus,textarea:focus{outline:0;border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 22%,transparent)}
input[readonly]{background:var(--bg);color:var(--muted)}
input::placeholder,textarea::placeholder{color:#9c9c9c}
input[type=checkbox]{width:18px;height:18px;min-height:0;padding:0;flex:none;accent-color:var(--brand)}
.checkbox-label{display:flex;align-items:flex-start;gap:10px;font-weight:400;font-size:14px;margin-top:14px}
.checkbox-label>input{margin-top:2px}
.fields{display:flex;flex-direction:column;gap:16px}
.fields-two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.field-help,.help-copy{font-size:13px;color:var(--muted);line-height:1.55}
.field-hint{display:block;margin-top:6px;font-weight:400}
.help-copy{margin-top:12px}
.field-label{font-size:13.5px;font-weight:550}

/* ---------- Buttons ---------- */
.button{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-height:44px;padding:0 18px;border:1px solid transparent;border-radius:10px;
  font-size:15px;font-weight:600;text-decoration:none;white-space:nowrap;
  background:transparent;color:var(--ink);
}
.button-primary{background:var(--brand);border-color:var(--brand);color:var(--brand-text)}
/* Hover styles only where there is a pointer: a phone would keep them after a tap, so a button looked stuck pressed.
   On touch screens a button shows it is pressed only while a finger is on it. */
@media(hover:none){.button-primary:active{filter:brightness(.9)}.button-quiet:active,.button-outline:active,.row-menu>summary:active{background:color-mix(in srgb,var(--ink) 8%,transparent)}}
@media(hover:hover){.button-primary:hover{filter:brightness(.93)}}
.button-outline{background:var(--surface);border-color:var(--line-strong)}
@media(hover:hover){.button-outline:hover{border-color:var(--ink)}}
.button-danger{color:#8c2430}
@media(hover:hover){.button-danger:hover{border-color:#8c2430}}
.button-primary.button-danger-solid{background:#8c2430;border-color:#8c2430;color:#fff}
.button-primary.button-danger-solid:disabled{opacity:.45;cursor:not-allowed;filter:none}
.leave-panel{margin-top:20px;display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
.leave-panel>.settings-row-intro{margin-bottom:0;flex:1 1 280px}
.owner-tag{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:999px;background:color-mix(in srgb,var(--ink) 8%,transparent);color:var(--muted);font-size:12px;font-weight:500;vertical-align:1px}
.button-quiet{color:var(--muted)}
@media(hover:hover){.button-quiet:hover{background:color-mix(in srgb,var(--ink) 6%,transparent);color:var(--ink)}}
.button-small{min-height:36px;padding:0 12px;font-size:13.5px;border-radius:8px}
.nowrap{white-space:nowrap}
.text-button{border:0;background:none;padding:2px 0;font-size:inherit;font-weight:550;color:var(--ink-accent);text-align:left;text-decoration:underline;text-underline-offset:3px}

/* ---------- Brand ---------- */
.brand{display:flex;align-items:center;gap:10px;color:var(--ink);text-decoration:none;font-family:var(--display);font-size:17px;font-weight:700;white-space:nowrap}
.brand-icon{width:34px;height:34px;flex:none;display:grid;place-items:center;border-radius:10px;background:var(--brand);color:var(--brand-text)}
.brand-icon svg{width:20px;height:20px}

/* ---------- Signed-in layout: sidebar + page ---------- */
.app-layout{display:grid;grid-template-columns:var(--sidebar-width) minmax(0,1fr);min-height:100vh}
.sidebar{
  position:sticky;top:0;height:100vh;height:100dvh;z-index:20;
  display:flex;flex-direction:column;gap:22px;padding:20px 14px 16px;
  background:var(--surface);border-right:1px solid var(--line);
}
.sidebar .brand{padding:0 6px}
.nav-tabs{display:flex;flex-direction:column;gap:6px}
.nav-tab{
  display:flex;align-items:center;gap:12px;width:100%;min-height:44px;padding:0 12px;
  border:0;border-radius:10px;background:none;color:var(--ink);font-size:15px;font-weight:500;text-align:left;
}
@media(hover:hover){.nav-tab:hover{background:color-mix(in srgb,var(--ink) 5%,transparent)}}
.nav-tab.active{background:var(--tint);color:var(--ink-accent);font-weight:650}
.nav-tab .icon{color:var(--muted)}
.nav-tab.active .icon{color:inherit}
.nav-create,.nav-create.active{background:var(--brand);color:var(--brand-text);font-weight:650}
@media(hover:hover){.nav-create:hover{background:var(--brand);filter:brightness(.93)}}
.nav-create .icon,.nav-create.active .icon{color:inherit;stroke-width:2.2}
.nav-create.active{box-shadow:0 0 0 3px var(--tint)}
.label-short{display:none}
/* More: on phones, the places that don't fit in the bottom bar. Wide screens list them all in the sidebar instead. */
.nav-more{display:none}
.nav-more>summary{list-style:none;cursor:pointer}
.nav-more>summary .icon{stroke-width:3.4}
.nav-more>summary::-webkit-details-marker{display:none}
.nav-more-content{
  position:fixed;right:max(8px,env(safe-area-inset-right));bottom:calc(var(--action-bottom,0px) + 8px);z-index:30;min-width:220px;padding:6px;
  background:var(--surface);border:1px solid var(--line);border-radius:14px;box-shadow:0 12px 32px rgb(31 31 31/.18);
}
.nav-more-content>button{display:flex;align-items:center;gap:12px;width:100%;min-height:48px;padding:0 12px;border:0;border-radius:10px;background:none;color:var(--ink);font-size:15.5px;font-weight:500;text-align:left}
.nav-more-content>button .icon{color:var(--muted)}
.nav-more-content>button.active{background:var(--tint);color:var(--ink-accent);font-weight:650}
.nav-more-content>button.active .icon{color:inherit}
@media(hover:hover){.nav-more-content>button:hover{background:var(--tint)}}
.sidebar-foot{margin-top:auto;display:flex;flex-direction:column;gap:10px}
.business-choice label{font-size:12.5px;color:var(--muted);font-weight:500}
.business-choice label>span:first-child{padding-left:2px}
.business-choice select{min-height:40px;font-size:14px;font-weight:550;text-overflow:ellipsis}
.app-menu{position:relative}
.app-menu>summary{
  display:flex;align-items:center;gap:12px;min-height:44px;padding:0 12px;border-radius:10px;
  list-style:none;cursor:pointer;font-weight:500;color:var(--ink);
}
.app-menu>summary::-webkit-details-marker{display:none}
.app-menu[open]>summary{background:color-mix(in srgb,var(--ink) 5%,transparent)}
@media(hover:hover){.app-menu>summary:hover{background:color-mix(in srgb,var(--ink) 5%,transparent)}}
.app-menu>summary .icon{color:var(--muted)}
.app-menu-content{
  position:absolute;left:0;right:0;bottom:calc(100% + 6px);z-index:30;padding:6px;
  background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 32px rgb(31 31 31/.14);
}
.menu-account{display:block;padding:8px 10px 10px;margin-bottom:4px;border-bottom:1px solid var(--line);font-size:12.5px;color:var(--muted);overflow-wrap:anywhere}
.app-menu-content>:is(button,a){display:block;width:100%;min-height:40px;padding:0 10px;border:0;border-radius:8px;background:none;text-align:left;font-size:14.5px}
@media(hover:hover){.app-menu-content>:is(button,a):hover{background:var(--tint)}}
.app-menu-content>a{display:flex;align-items:center;color:inherit;text-decoration:none}

.main-container{width:100%;min-width:0;padding:24px var(--page-gutter) 48px}
.main-container:has(.action-bar){padding-bottom:calc(var(--action-height) + var(--action-bottom) + 32px)}
/* Page actions stay outside the scrolling content, with one surface and spacing throughout. */
.action-bar{position:fixed;left:var(--sidebar-width);right:0;bottom:var(--action-bottom);z-index:15;display:flex;align-items:center;gap:10px;min-height:var(--action-height);margin:0;padding:12px var(--page-gutter);border-top:1px solid var(--line);background:var(--surface);box-shadow:0 -4px 14px rgb(31 31 31/.04)}
.action-bar>.button:first-child:not(:last-child){margin-right:auto}
body:has(#app .action-bar) .toast{bottom:calc(var(--action-height) + var(--action-bottom) + 16px)}
.page-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;flex-wrap:wrap;margin-bottom:24px}
.page-heading h1{font-size:28px}
.page-heading p{margin-top:6px;color:var(--muted);max-width:60ch}
.heading-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}

/* ---------- Notices, toast, dialog ---------- */
.notice{padding:12px 14px;border-radius:10px;font-size:14px;line-height:1.5;margin-bottom:18px}
.notice-error{background:#fbecee;border:1px solid #efc4c9;color:#8c2430}
.notice-success{background:#eaf5ef;border:1px solid #bcdccb;color:#235a41}
.notice-warning{background:#fdf4e3;border:1px solid #ecd6a8;color:#6e4a0b}
.global-error-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.invitation-banner{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;padding:14px 18px;margin-bottom:24px;border-radius:var(--radius);background:var(--tint);border:1px solid color-mix(in srgb,var(--brand) 25%,#fff)}
.toast{
  /* Its own width up to the screen's: centred from left:50%, it would otherwise wrap at half the screen. */
  position:fixed;left:50%;bottom:28px;transform:translateX(-50%);z-index:60;width:max-content;max-width:calc(100vw - 32px);
  padding:12px 18px;border-radius:22px;background:var(--ink);color:#fff;font-size:14.5px;font-weight:500;box-shadow:0 10px 30px rgb(31 31 31/.25);
}
dialog.settings-dialog{
  width:min(520px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;padding:24px;
  border:0;border-radius:16px;background:var(--surface);color:var(--ink);box-shadow:0 24px 70px rgb(31 31 31/.3);
}
dialog::backdrop{background:rgb(31 31 31/.45)}
.dialog-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:20px}
.dialog-heading h2{font-size:21px}
/* The title takes focus when a dialog opens (so it is read out), without a focus ring. */
#modal-title:focus{outline:none}
.dialog-heading p{margin-top:6px;color:var(--muted);font-size:14px}
.modal-close{flex:none;width:36px;height:36px;border:0;border-radius:8px;background:none;font-size:24px;line-height:1;color:var(--muted)}
@media(hover:hover){.modal-close:hover{background:var(--bg);color:var(--ink)}}
.dialog-actions{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap;margin-top:22px}

/* ---------- Bank accounts ---------- */
.bank-picker{display:flex;align-items:flex-end;gap:10px}
.bank-picker>label{flex:1;min-width:0}
.bank-summary{padding:14px 16px;border-radius:10px;background:var(--bg);font-size:14px;line-height:1.55}
.bank-summary .field-help{margin:0}
.bank-summary>p:not(.field-help){margin-top:8px;color:var(--muted);white-space:pre-line}
.bank-summary>p.bank-text{margin-top:0;color:var(--ink);overflow-wrap:anywhere}
.bank-lines{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:4px 20px;margin:0}
.bank-lines dt{color:var(--muted)}
.bank-lines dd{margin:0;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.bank-form label>.field-help{display:block;margin-top:6px;font-weight:400}
.bank-delete{margin-right:auto;color:#8c2430}
@media (max-width:520px){.bank-lines{grid-template-columns:minmax(0,1fr);gap:0}.bank-lines dd{margin-bottom:6px}}

/* ---------- Disclosures ---------- */
/* The arrow stays beside the question, centred on its first line, however many lines the question wraps to. */
.landing-faq summary{display:flex;align-items:flex-start;gap:10px;list-style:none}
.landing-faq summary::-webkit-details-marker{display:none}
.landing-faq summary::before{content:"";flex:none;width:14px;height:14px;margin-right:-2px;margin-top:5px;margin-top:calc((1lh - 14px)/2);background:var(--muted);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;transform:rotate(-90deg)}
.landing-faq details[open]>summary::before{transform:none}

/* ---------- Invoice editor ---------- */
.invoice-back{margin-bottom:8px}
.save-status{display:flex;align-items:center;gap:8px;margin-top:6px;font-size:13.5px;color:var(--muted)}
.status-dot{width:8px;height:8px;border-radius:50%;background:var(--green)}
.status-dot.status-dot-pending{background:#c8902e}
/* The invoice editor. Narrow screens stack the editor above the preview; wide screens get the full-height two-pane layout further down. */
.compose-bar{display:flex;align-items:center;gap:6px 16px;flex-wrap:wrap;margin-bottom:16px}
.compose-bar h1{font-size:22px}
.compose-bar .invoice-back,.compose-bar .save-status{margin:0}
.compose-bar .save-status{margin-left:auto}
.workspace{display:grid;grid-template-columns:minmax(0,1fr);gap:28px;align-items:start}
.editor-column{min-width:0;container:invoice-editor / inline-size}
.editor-panel{padding:22px;margin-bottom:16px;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
.editor-panel>h2{font-size:18px;margin-bottom:14px}
.editor-panel>h2 label{font:inherit;display:block}
/* Each line is its own tinted card: what it is on top, then quantity, price and amount. */
.invoice-lines{display:grid;gap:10px}
.line-row{position:relative;display:grid;grid-template-columns:minmax(150px,168px) minmax(0,1fr);gap:12px 10px;align-items:end;padding:14px 16px;background:var(--bg);border:1px solid var(--line);border-radius:12px}
.line-label{display:block;margin-bottom:4px;font-size:12.5px;font-weight:550;color:var(--muted)}
.line-row label>select,.line-row label>input,.line-row .unit-field{margin-top:0}
.line-row input[type=number]{-moz-appearance:textfield;font-variant-numeric:tabular-nums}
.line-row input[type=number]::-webkit-inner-spin-button,.line-row input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.line-item{grid-column:1/-1}
.unit-field{position:relative;display:block}
.unit-field input{padding-right:52px}
.unit-suffix{position:absolute;right:10px;top:50%;transform:translateY(-50%);max-width:46px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;color:var(--muted);pointer-events:none}
.line-amount{grid-column:2/-1;min-width:0;text-align:right}
.line-unit-price{font-weight:400}
.line-amount strong{display:block;line-height:44px;font-size:15px;font-weight:650;font-variant-numeric:tabular-nums;white-space:nowrap}
/* The × sits in the card's top corner, level with the label, clear of the dropdown below it. */
.line-remove{position:absolute;top:6px;right:8px;width:28px;height:26px;padding:0;border:0;border-radius:6px;background:none;font-size:19px;line-height:1;color:var(--muted)}
@media(hover:hover){.line-remove:hover{background:#fbecee;color:var(--red)}}
/* The handle sits beside the ×; dragging it (or arrow keys on it) puts the lines in order. */
.line-handle{position:absolute;top:6px;right:40px;display:grid;place-items:center;width:28px;height:26px;padding:0;border:0;border-radius:6px;background:none;color:var(--muted);cursor:grab;touch-action:none}
.line-handle svg{width:16px;height:16px;fill:currentColor}
/* A long press on the handle starts a drag, not text selection or the phone's press-and-hold menu. */
.line-handle{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
@media(hover:hover){.line-handle:hover{background:var(--line);color:var(--ink)}}
.is-sorting,.is-sorting *{cursor:grabbing;user-select:none;-webkit-user-select:none}
.line-row.is-dragging{z-index:2;box-shadow:0 10px 28px rgba(0,0,0,.14)}
.line-details{grid-column:1/-1;min-width:0}
.line-discount{grid-column:1/-1;font-size:13.5px}
.lines-foot{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;padding-top:14px}
.add-line{color:var(--ink-accent)}
.editor-total{display:flex;align-items:baseline;gap:12px;margin-left:auto;color:var(--muted)}
.editor-total strong{font-family:var(--display);font-size:24px;font-weight:700;color:var(--ink);font-variant-numeric:tabular-nums}
/* Flat progress tabs: the underline marks the current step; all steps remain clickable. */
.steps-nav{margin-bottom:20px;border-bottom:1px solid var(--line)}
.steps{display:flex;gap:12px;margin:0;padding:0;list-style:none}
.steps li{display:flex;flex:1;min-width:0}
.step{position:relative;display:flex;align-items:center;justify-content:center;gap:7px;width:100%;min-height:52px;padding:10px 2px;border:0;border-radius:0;background:none;font-size:14px;font-weight:550;color:var(--muted);text-align:center;cursor:pointer}
.step::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:3px;border-radius:2px 2px 0 0;background:transparent}
@media(hover:hover){.step:hover{color:var(--ink);background:var(--tint)}}
.step-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.step-done{color:var(--ink)}
.step[aria-current="step"]{color:var(--ink);font-weight:700}
.step[aria-current="step"]::after{background:var(--brand)}
.step-title:focus{outline:none}
.step-intro{margin:-6px 0 16px;font-size:14px;color:var(--muted)}
.step-next,.step-actions-end{margin-left:auto}
.step-actions-end{display:flex;gap:10px}
/* Review: one row per step, each with its own way back. */
.review-list{display:grid}
.review-row{display:grid;grid-template-columns:minmax(96px,140px) minmax(0,1fr) auto;align-items:baseline;gap:4px 16px;padding:12px 0;border-bottom:1px solid var(--line)}
.review-row:first-child{padding-top:0}
.review-row dt{font-size:13.5px;font-weight:550;color:var(--muted)}
.review-row dd{min-width:0;overflow-wrap:anywhere}
.review-missing{color:var(--red)}
.lines-needed{font-size:13.5px;color:var(--red)}
.review-total{display:flex;align-items:baseline;justify-content:space-between;gap:16px;padding-top:16px;color:var(--muted)}
.review-total strong{font-family:var(--display);font-size:26px;font-weight:700;color:var(--ink);font-variant-numeric:tabular-nums}
.review-help{margin-top:14px}
.review-warning{margin-bottom:14px}
.review-warning .text-button{color:inherit}
.review-logo{padding-top:12px}
.print-sheet{display:none}
/* After saving: print or email the invoice. */
.share-options{display:grid;gap:10px}
.share-option{display:flex;align-items:flex-start;gap:14px;width:100%;padding:14px 16px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface);color:var(--ink);text-align:left;text-decoration:none;cursor:pointer}
@media(hover:hover){.share-option:hover{border-color:var(--brand);background:var(--tint)}}
.share-option .icon{margin-top:2px;color:var(--ink-accent)}
.share-option strong{display:block;font-size:15px}
.share-option small{display:block;margin-top:3px;font-size:13px;line-height:1.45;color:var(--muted)}
.email-preview{margin-top:8px;border:1px solid var(--line);border-radius:12px;background:var(--surface);overflow:hidden}
.email-message{display:grid;gap:10px;padding:16px 18px;overflow-wrap:anywhere;font-size:14px;line-height:1.5}
.email-message .email-signoff{margin-top:4px;padding-top:12px;border-top:1px solid var(--line);font-size:12.5px;color:var(--muted)}
.email-attachment{display:flex;align-items:center;gap:8px;padding:10px 18px;border-top:1px solid var(--line);background:var(--bg);font-size:13.5px;color:var(--muted)}
.email-attachment .icon{width:18px;height:18px;color:var(--ink-accent)}
.email-attachment a{font-weight:600;color:var(--ink-accent)}

/* ---------- Invoice preview: a sheet of paper on the desk ---------- */
.preview-column{min-width:0;padding:16px 20px 18px;border-radius:16px;background:var(--desk)}
.preview-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;font-size:13.5px;font-weight:550;color:var(--muted)}
/* A status chip, not a tab: it labels the pane and must not read as another step beside the step buttons. */
.preview-label{display:inline-flex;align-items:center;gap:6px;padding:4px 10px 4px 8px;border:1px solid var(--line);border-radius:99px;background:var(--surface);font-size:12.5px;font-weight:550;color:var(--muted)}
.preview-label .icon{width:15px;height:15px}
.preview-footnote{margin-top:12px;font-size:13px;color:var(--muted);text-align:center}
.paper-frame{max-width:850px;margin:0 auto}
/* The sheet is laid out as the PDF is (business/pdf.py): A4, 16mm margins and 10pt text, with the same spacing, so it
   breaks into pages where the PDF does. It is always laid out at full size, then shrunk to fit its frame (fitPaper in
   web/app.js), so it is the same on every screen. The coloured bar and the 8mm under it come first. */
.invoice-paper{
  --p-ink:#222222;--p-muted:#696969;--p-line:#e6e6e6;
  position:relative;display:flex;flex-direction:column;width:210mm;min-height:297mm;padding:25.4mm 16mm 16mm;transform-origin:0 0;
  font-family:Inter,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:10pt;line-height:1.45;color:var(--p-ink);overflow-wrap:anywhere;
  /* Phones would otherwise enlarge the text, and the pages would no longer match the PDF. */
  -webkit-text-size-adjust:none;text-size-adjust:none;
  background:#fff;border-radius:2px;box-shadow:0 1px 2px rgb(31 31 31/.08),0 14px 34px rgb(31 31 31/.12);
}
.invoice-paper::before{content:"";position:absolute;inset:0 0 auto;height:.55em;background:var(--paper-primary,var(--brand));border-radius:2px 2px 0 0}
.paper-top{display:flex;justify-content:space-between;gap:2em;margin-bottom:2em}
.paper-brand{max-width:58%;font-size:1.65em;font-weight:700;line-height:1.3;letter-spacing:-.01em}
.paper-logo{display:block;width:auto;max-width:7.5em;max-height:3em;object-fit:contain;margin-bottom:.6em}
.paper-contact{margin-top:.5em;font-size:.55em;font-weight:400;letter-spacing:0;line-height:1.5;color:var(--p-muted);white-space:pre-line}
.paper-title{text-align:right}
.paper-title h2{font-size:2.6em;font-weight:300;letter-spacing:-.02em;line-height:1.05}
.paper-number{margin-top:.6em;font-size:.95em;color:var(--p-muted);font-variant-numeric:tabular-nums}
.paper-billing{display:grid;grid-template-columns:1.2fr 1fr;gap:2em;padding-top:1.4em;margin-bottom:2em;border-top:1px solid var(--p-line)}
.paper-label{margin-bottom:.5em;font-size:.9em;color:var(--p-muted)}
.paper-client{font-size:1.2em;font-weight:650}
.paper-client-details{margin-top:.3em;font-size:.95em;line-height:1.6;color:var(--p-muted);white-space:pre-line}
.paper-date-row{display:flex;justify-content:space-between;gap:1em;font-size:.95em;line-height:2}
.paper-date-row span:first-child{color:var(--p-muted)}
.paper-table{width:100%;border-collapse:collapse;table-layout:fixed}
.paper-table th{padding:.9em .8em;font-size:.88em;font-weight:600;text-align:left;background:var(--paper-accent,#f0f0f0);color:var(--paper-accent-text,#222222)}
.paper-table th:first-child{width:44%}
.paper-table th:nth-child(2){width:18%}
.paper-table th:nth-child(3),.paper-table th:nth-child(4){width:19%}
.paper-table th:not(:first-child),.paper-table td:not(:first-child){text-align:right;white-space:nowrap;overflow-wrap:normal}
.paper-table td{padding:.85em .8em;border-bottom:1px solid var(--p-line);vertical-align:top;font-size:.95em;color:var(--p-muted);font-variant-numeric:tabular-nums}
.paper-lesson{font-size:1.05em;font-weight:600;color:var(--p-ink);white-space:pre-line}
.paper-lesson-date{display:block;margin-top:.3em;font-size:.9em;white-space:pre-line}
.paper-totals{width:62%;margin:1.2em 0 0 auto}
.paper-totals>div{display:flex;justify-content:space-between;gap:1em;padding:.45em .8em;font-size:.95em;color:var(--p-muted)}
.paper-totals strong{font-weight:500;color:var(--p-ink);font-variant-numeric:tabular-nums;white-space:nowrap}
.paper-totals .paper-grand-total{align-items:center;margin:.4em 0;padding:.6em .8em;border-radius:.3em;font-size:1.1em;background:var(--paper-accent,#f0f0f0);color:var(--paper-accent-text,#222222)}
.paper-grand-total strong{font-size:1.5em;font-weight:700;color:inherit}
.paper-payment{margin-top:5mm;padding-top:1em;border-top:1px solid var(--p-line)}
.paper-payment h3,.paper-note h3{margin-bottom:.5em;font-size:.95em;font-weight:600}
.paper-payment p,.paper-note p{font-size:.95em;line-height:1.65;color:var(--p-muted);white-space:pre-line}
.paper-payment p.bank-text{color:var(--p-ink);overflow-wrap:anywhere}
.paper-reference{margin-top:.8em}
.paper-bank{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:.15em 1.6em;margin:0 0 .6em;font-size:.95em;line-height:1.55}
.paper-bank>div,.bank-lines>div{display:contents}
.paper-bank dt{color:var(--p-muted)}
.paper-bank dd{margin:0;color:var(--p-ink);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.paper-note{margin-top:1.4em}
.paper-footer{margin-top:2em;padding-top:1em;border-top:1px solid var(--p-line);font-size:.82em;text-align:center;color:var(--p-muted)}
/* Pages, as the PDF has them (paginate in web/app.js): spacers push a line or block onto the next sheet, a band of
   background separates the sheets, and each sheet is numbered when there is more than one. */
.paper-gap{position:absolute;left:-2px;right:-2px;background:var(--desk);box-shadow:inset 0 9px 9px -9px rgb(31 31 31/.18),inset 0 -9px 9px -9px rgb(31 31 31/.18);pointer-events:none}
.paper-page-number{position:absolute;left:0;right:0;font-size:.8em;line-height:1;text-align:center;color:var(--p-muted);transform:translateY(-50%);pointer-events:none}
.paper-table tr.paper-spacer td{padding:0;border:0}
.paper-measure{position:fixed;left:-10000px;top:0;visibility:hidden;pointer-events:none}
/* Until the sheet is shrunk to fit, its full A4 width mustn't widen the page. */
#marketing-view{overflow-x:clip}

/* ---------- Lists and tables ---------- */
.list-tools{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.list-tools input{max-width:400px}
.history-tools .segmented{margin:0;flex:none}
.history-tools input{flex:1}
@media(max-width:640px){.history-tools .segmented{display:flex;width:100%}.history-tools .segmented button{flex:1;padding:0 8px;white-space:nowrap}.history-tools input{max-width:none}}
.table-shell{position:relative;overflow-x:auto;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
/* A titled table: the section title sits inside the card, like every other panel. */
.table-card{margin-bottom:20px;overflow:hidden;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
.table-card>h2{padding:22px 22px 6px;font-size:18px}
.table-card>.analytics-panel-header{margin:0;padding:22px 22px 6px}
.table-card>.table-shell{border:0;border-radius:0;background:none}
.table-card .record-table :is(th,td):first-child{padding-left:22px}
.table-card .record-table :is(th,td):last-child{padding-right:22px}
.record-table{width:100%;border-collapse:collapse;text-align:left;font-size:14.5px}
.record-table th{padding:12px 18px;font-size:13px;font-weight:550;color:var(--muted);border-bottom:1px solid var(--line);white-space:nowrap}
.record-table td{padding:14px 18px;border-bottom:1px solid var(--line);vertical-align:middle}
.record-table tbody tr:last-child td{border-bottom:0}
/* Calm data tables: a lightly tinted header, numbers aligned right, and rows that highlight and open when clicked. */
.record-table thead th{background:color-mix(in srgb,var(--ink) 2.5%,var(--surface))}
.record-table :is(th,td).num{text-align:right}
.amount.is-reversed{text-decoration:line-through;color:var(--muted)}
.record-table tbody tr[data-row-open]{cursor:pointer}
@media(hover:hover){.record-table tbody tr[data-row-open]:hover>td{background:color-mix(in srgb,var(--ink) 2.5%,var(--surface))}}
.row-primary{padding:0;border:0;background:none;font:inherit;font-weight:600;color:var(--ink);text-align:left;cursor:pointer}
.client-identity{display:inline-flex;align-items:center;gap:12px;max-width:100%}
.client-identity>span:last-child{min-width:0;overflow-wrap:anywhere}
.client-mark{display:grid;place-items:center;flex:none;width:36px;height:36px;border-radius:50%;background:var(--tint);color:var(--ink-accent);font-size:12px;font-weight:700;letter-spacing:.02em;line-height:1}
.row-title{font-weight:600}
.row-primary:focus-visible{outline:2px solid var(--brand);outline-offset:3px;border-radius:4px}
.record-table .text-button{padding:0;font-weight:650}
.secondary{display:block;margin-top:3px;font-size:13px;font-weight:400;color:var(--muted);white-space:pre-line}
.amount{font-variant-numeric:tabular-nums;white-space:nowrap;font-weight:600}
/* Cells are centred in their row, like standard data tables. A borderless first button lines up with its column heading. */
/* A trailing actions column hugs its buttons and sits against the right edge. */
.record-table .actions-cell{width:1%;white-space:nowrap}
/* The "⋯" glyph's edge, not its hit area, lines up with the table's right padding. */
.actions-cell{text-align:right}
.actions-cell>.row-menu{display:inline-block;margin-right:-6px;vertical-align:middle;text-align:left}
.row-menu>summary{display:grid;place-items:center;width:34px;height:34px;border-radius:8px;list-style:none;cursor:pointer;color:var(--muted)}
.row-menu>summary svg{width:18px;height:18px;fill:currentColor}
.row-menu>summary::-webkit-details-marker{display:none}
.row-menu[open]>summary{background:color-mix(in srgb,var(--ink) 6%,transparent);color:var(--ink)}
@media(hover:hover){.row-menu>summary:hover{background:color-mix(in srgb,var(--ink) 6%,transparent);color:var(--ink)}}
.row-menu-content{position:fixed;z-index:40;display:flex;flex-direction:column;min-width:170px;padding:6px;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 32px rgb(31 31 31/.14)}
.row-menu-content>.button{justify-content:flex-start;width:100%;min-height:38px;padding:0 10px;font-size:14px;font-weight:500;color:var(--ink);text-align:left}
@media(hover:hover){.row-menu-content>.button:hover{background:color-mix(in srgb,var(--ink) 5%,transparent)}}
.row-menu-content>.button[data-action^="delete"]{color:var(--red)}
/* Credit notes: listed under their invoice, and issued from a dialog listing the invoice's lines. */
.credit-note-link,.row-link{display:block;margin-top:4px;font-size:13px;font-weight:500}
.document-quick{margin-top:12px}
.credit-lines{border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--surface)}
.credit-lines-head,.credit-line{display:grid;grid-template-columns:minmax(0,1fr) 132px;gap:12px;align-items:center;padding:12px 14px}
.credit-lines-head{padding-block:8px;font-size:12.5px;font-weight:550;color:var(--muted);background:var(--bg);border-bottom:1px solid var(--line)}
.credit-line+.credit-line{border-top:1px solid var(--line)}
.credit-line strong{display:block;font-weight:600;overflow-wrap:anywhere}
.credit-line .secondary{margin-top:2px}
.credit-line input{margin-top:0}
@media(max-width:400px){.credit-lines-head,.credit-line{grid-template-columns:minmax(0,1fr) 112px;padding-inline:12px}}
/* A saved invoice or credit note: the sheet full width, with the send icons and the ⋯ menu just above it. */
.document-heading h1{margin-top:6px}
.document-heading p{margin-top:4px;color:var(--muted)}
.document-related{font-size:14px}
.document-view{padding:12px 16px 20px;border-radius:16px;background:var(--desk)}
.document-bar{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 12px}
.document-bar-end{display:flex;gap:8px;margin-left:auto}
.document-view{overflow-x:auto}
.preview-scroll{overflow-x:auto}
.zoom-page{min-height:100vh;min-height:100dvh}
/* Zoom: out, a size, in. */
.zoom-tools{display:flex;align-items:center;gap:4px}
.zoom-tools select{width:auto;min-width:0;min-height:40px;padding:0 28px 0 10px;font-size:14px}
.icon-button.icon-button-small{width:40px;height:40px;border-radius:8px}
.icon-button-small .icon{width:16px;height:16px}
@media(max-width:900px){.zoom-tools select{min-height:44px}.icon-button.icon-button-small{width:44px;height:44px}}
/* Phones pinch to zoom, so the zoom menu alone sits beside the ⋯ menu, with Download, Print and Email sharing the row below. */
@media(max-width:560px){.zoom-tools .icon-button{display:none}.document-bar-end{display:contents}.document-bar .document-menu{order:1;margin-left:auto}
  .document-bar .document-tools{order:2;width:100%;gap:6px}.document-bar .tool-button{flex:1;padding:0 8px}}
.document-tools{display:flex;flex-wrap:wrap;gap:8px}
/* Download, Print and Email: an icon with its name, so nobody has to guess. */
.tool-button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:0 14px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface);color:var(--ink);font:inherit;font-size:14px;font-weight:500;line-height:1;white-space:nowrap;cursor:pointer;text-decoration:none}
@media(hover:hover){.tool-button:hover{border-color:var(--brand);background:var(--tint)}}
.tool-button .icon{width:18px;height:18px;flex:none}
.icon-button{display:grid;place-items:center;width:44px;height:44px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface);color:var(--ink);cursor:pointer;text-decoration:none}
@media(hover:hover){.icon-button:hover{border-color:var(--brand);background:var(--tint)}}
.icon-button .icon{width:20px;height:20px}
.document-menu>summary{width:44px;height:44px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface)}
.dialog-heading+.notice+.document-tools,#modal>.document-tools{justify-content:center;margin:4px 0 8px}
@media(max-width:560px){.document-view{padding:8px;margin-inline:-8px}}
.payment-facts .review-row{grid-template-columns:minmax(96px,140px) minmax(0,1fr)}
/* Label and value stay side by side on phones too, so the actions are close to the top. */
.payment-facts .review-row{padding:9px 0}
/* A label lines up with the first line of its value, even a value that wraps (a long client name). */
.payment-facts .review-row{align-items:start}
.payment-facts{margin-bottom:8px}
@media(max-width:560px){.payment-facts .review-row{grid-template-columns:minmax(76px,104px) minmax(0,1fr)}.payment-facts .review-row :is(dt,dd){grid-column:auto;grid-row:auto}}
.badge{display:inline-block;margin-left:8px;padding:1px 8px;border-radius:99px;background:var(--bg);border:1px solid var(--line);font-size:12px;color:var(--muted)}
.empty-state{padding:56px 24px;text-align:center;background:var(--surface);border:1px dashed var(--line-strong);border-radius:var(--radius)}
.empty-state h2{font-size:20px}
.empty-state p{margin:8px auto 20px;max-width:44ch;color:var(--muted)}
.empty-state p:last-child{margin-bottom:0}

/* ---------- Client account ---------- */
.account-balance{display:flex;align-items:baseline;gap:8px;white-space:nowrap;font-variant-numeric:tabular-nums}
.account-balance+.account-balance{margin-top:4px}
td.num .account-balance{justify-content:flex-end}
.account-balance small{font-size:13px;color:var(--muted)}
.account-credit strong{color:var(--green)}
.account-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px;margin-bottom:24px}
.account-summary .settings-panel{margin:0}
.account-summary-values>div{display:flex;justify-content:space-between;gap:16px;margin:10px 0}
.account-summary-values dt{color:var(--muted)}
.account-summary-values dd{font-weight:600;font-variant-numeric:tabular-nums}
.account-summary-values .balance-total{margin-top:14px;padding-top:14px;border-top:1px solid var(--line);font-size:17px}
.balance-total dt{color:var(--ink);font-weight:600}
.statement-section .record-table{min-width:720px}
.reversed-payment td{color:var(--muted)}
.reversed-payment td:nth-child(4){text-decoration:line-through}
#view-statement .page-heading .text-button{display:inline-block;margin-bottom:10px;font-size:14px}

/* ---------- Settings and team ---------- */
/* Settings read as one column of rows: what the section is on the left, its controls on the right. */
.settings-row{display:grid;grid-template-columns:minmax(0,240px) minmax(0,720px);gap:16px 40px;align-items:start}
.settings-row-intro h2{font-size:18px;margin-bottom:6px}
.branding-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:start}
.settings-panel{padding:22px;margin-bottom:20px;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
.settings-panel>h2{font-size:18px;margin-bottom:16px}
.settings-panel p{color:var(--muted);font-size:14px;line-height:1.6}
.logo-preview{display:flex;align-items:center;justify-content:center;width:100%;height:112px;padding:14px;border:1px dashed var(--line-strong);border-radius:10px;background:var(--bg);cursor:pointer}
@media(hover:hover){.logo-preview:hover{border-color:var(--brand);background:var(--tint)}}
.logo-preview img{max-width:170px;max-height:80px;object-fit:contain}
.logo-preview span{font-size:14px;font-weight:550;color:var(--muted)}
.logo-upload{display:flex;flex-direction:column;gap:8px}
.logo-frame{position:relative}
.logo-remove{position:absolute;top:8px;right:8px;display:grid;place-items:center;width:28px;height:28px;padding:0;border:1px solid var(--line-strong);border-radius:50%;background:var(--surface);color:var(--muted);cursor:pointer}
@media(hover:hover){.logo-remove:hover{color:var(--ink);border-color:var(--ink)}}
.logo-remove svg{width:14px;height:14px}
.brand-colours{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.colour-control{min-width:0}
.colour-control>label{margin-bottom:6px}
.colour-inputs{display:flex;align-items:center;min-width:0;overflow:hidden;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface)}
.colour-inputs:focus-within{border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 22%,transparent)}
.colour-inputs input{border:0;border-radius:0;box-shadow:none!important;min-height:42px}
.colour-inputs input[type=color]{flex:0 0 46px;width:46px;padding:6px;border-right:1px solid var(--line);cursor:pointer}
.colour-inputs input[type=color]::-webkit-color-swatch-wrapper{padding:0}
.colour-inputs input[type=color]::-webkit-color-swatch{border:0;border-radius:5px}
.colour-inputs input[type=color]::-moz-color-swatch{border:0;border-radius:5px}
.colour-inputs input[type=text]{flex:1;width:0;min-width:0;font-variant-numeric:tabular-nums}
.branding-links{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:-6px;font-size:13.5px}
.branding-links [data-action=reset-colours]{margin-left:auto}
.branding-preview{min-height:112px;padding:16px 18px 18px;border:1px solid var(--line);border-top:5px solid var(--brand);border-radius:4px}
.branding-preview div{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin-bottom:12px}
.branding-preview strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px}
.branding-preview div span{font-size:20px;font-weight:300}
/* A placeholder bar, like the home page sketches, so the sample never reads as a real amount. */
.branding-preview p{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-radius:4px;background:var(--business-accent);color:var(--accent-text);font-weight:600}
.branding-pill{flex:none;width:72px;height:8px;border-radius:4px;background:currentColor;opacity:.3}
.staff-invite-form{display:grid;grid-template-columns:minmax(0,1fr) 182px;align-items:end;gap:12px}
.settings-panel>.settings-row-intro{margin-bottom:16px}

/* ---------- Overview ---------- */
.filter-label{display:flex;align-items:center;gap:10px;color:var(--muted)}
.filter-label>select{width:auto;min-width:130px;margin-top:0}
.analytics-currency-header{margin:8px 0 16px}
.analytics-currency-header h2{font-size:20px}
.analytics-currency-header p{margin-top:4px;font-size:13.5px;color:var(--muted)}
/* A two-part switch, as for service or item: radios drawn as one pill with the choice raised inside it. */
.segmented{display:inline-flex;max-width:100%;gap:2px;margin:0 0 18px;padding:3px;border:0;border-radius:10px;background:var(--desk);min-width:0}
.segmented label{position:relative;display:block;cursor:pointer}
.unit-field{display:grid;gap:8px}
.unit-field .field-help{margin:0}
.unit-chips{display:flex;flex-wrap:wrap;gap:6px}
.unit-chip{min-height:32px;padding:0 12px;border:1px solid var(--line-strong);border-radius:99px;background:var(--surface);font:inherit;font-size:13.5px;color:var(--ink);cursor:pointer}
@media(hover:hover){.unit-chip:hover{border-color:var(--brand)}}
.unit-chip[aria-pressed="true"]{border-color:var(--ink);background:var(--ink);color:var(--surface)}
@media(max-width:900px){.unit-chip{min-height:36px;padding:0 11px}}
.segmented input{position:absolute;opacity:0;width:1px;height:1px;min-height:0;padding:0;margin:0}
.segmented span{display:flex;align-items:center;min-height:36px;padding:0 18px;border-radius:8px;font-size:14.5px;font-weight:550;color:var(--muted)}
@media(hover:hover){.segmented label:hover span{color:var(--ink)}}
.segmented input:checked+span{color:var(--ink);background:var(--surface);box-shadow:0 1px 2px rgba(0,0,0,.08),0 0 0 1px var(--line)}
.segmented input:focus-visible+span{box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 22%,transparent)}
.segmented button{min-height:36px;padding:0 16px;border:0;border-radius:8px;background:none;font:inherit;font-size:14.5px;font-weight:550;color:var(--muted);cursor:pointer}
@media(hover:hover){.segmented button:hover{color:var(--ink)}}
.segmented button[aria-pressed="true"]{color:var(--ink);background:var(--surface);box-shadow:0 1px 2px rgba(0,0,0,.08),0 0 0 1px var(--line)}
/* Site analytics: one small daily chart per measure. Each day is a full-height column so it is easy to point at. */
.stat-card-note{display:block;margin-top:6px;font-size:13px;color:var(--muted)}
.site-shell{max-width:1280px;margin:0 auto;padding:24px max(16px,4vw) 56px}
.site-head{display:flex;align-items:center;justify-content:space-between;gap:12px 24px;flex-wrap:wrap;margin-bottom:32px;font-size:14px;color:var(--muted)}
.site-charts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin:16px 0}
/* The tabs sit on a rule that runs the width of the page; the period, where it applies, is at the end of it. */
.site-bar{display:flex;align-items:flex-end;justify-content:space-between;gap:0 20px;flex-wrap:wrap;margin-bottom:20px;border-bottom:1px solid var(--line)}
.site-bar .segmented{margin:0 0 8px}
.site-tabs{display:flex;gap:4px;margin-bottom:-1px}
.site-tabs button{min-height:44px;padding:0 14px;border:0;border-bottom:2px solid transparent;border-radius:6px 6px 0 0;background:none;font:inherit;font-size:15px;font-weight:550;color:var(--muted);cursor:pointer}
@media(hover:hover){.site-tabs button:hover{color:var(--ink)}}
.site-tabs button[aria-current="page"]{color:var(--ink);border-bottom-color:var(--ink)}
.site-tools{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.site-tools input{flex:1 1 240px;max-width:400px;margin:0}
.site-tools .segmented{margin:0}
.table-card>.site-tools{padding:18px 22px}
.table-card>div>.table-shell{border:0;border-top:1px solid var(--line);border-radius:0;background:none}
.table-card .site-more{margin:14px 22px 18px}
.site-none{margin:0;padding:0 22px 22px}
.site-note{margin-top:16px}
.site-more{margin-top:12px}
/* Each day's heading stays in view while its events scroll under it. */
#site-events .site-day{position:sticky;top:0;z-index:1;margin:0;padding:18px 0 8px;background:var(--surface);font-size:13.5px;font-weight:600;color:var(--ink)}
@media (max-width:640px){.site-tools .segmented{display:flex;width:100%}.site-tools .segmented button{flex:1;padding:0 6px;font-size:13.5px}.site-tools input{max-width:none}.site-bar{gap:10px}.site-tabs button{padding:0 12px}}
.site-events{list-style:none;margin:0;padding:0}
.site-events li{display:grid;grid-template-columns:76px minmax(0,1fr) auto;align-items:baseline;gap:12px;padding:10px 0;border-top:1px solid var(--line);font-size:14px;overflow-wrap:anywhere}
.site-events strong{font-weight:600}
.site-events time{font-size:13px;color:var(--muted);white-space:nowrap}
.site-event-kind{font-size:12.5px;font-weight:600;color:var(--muted)}
.day-chart-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;flex-wrap:wrap;font-size:13.5px;color:var(--muted)}
.day-chart-head h2{font-size:17px;color:var(--ink)}
.day-chart-head strong{font-family:var(--display);font-size:20px;color:var(--ink);font-variant-numeric:tabular-nums}
.day-bars{display:flex;gap:2px;height:104px;margin-top:16px;border-bottom:1px solid var(--line)}
.day{flex:1;min-width:0;display:flex;align-items:flex-end}
.day>i{display:block;width:100%;border-radius:3px 3px 0 0;background:var(--ink-accent)}
.day>i.is-empty{height:2px;border-radius:0;background:var(--line-strong)}
@media(hover:hover){.day:hover>i{opacity:.65}}
.day-axis{display:flex;justify-content:space-between;margin-top:6px;font-size:12px;color:var(--muted)}
@media (max-width:1100px){.site-charts{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:640px){.site-charts{grid-template-columns:minmax(0,1fr)}.site-events li{grid-template-columns:minmax(0,1fr) auto}.site-event-kind{grid-column:1/-1}}
/* Several currencies: one shows at a time, chosen from a row of flags. */
.currency-tabs{display:flex;flex-wrap:wrap;gap:6px;margin-left:-6px}
.currency-tab{min-height:44px;padding:6px 16px 6px 10px;border:1px solid transparent;border-radius:999px;background:none;font-size:15px;font-weight:550;color:var(--muted);cursor:pointer}
@media(hover:hover){.currency-tab:hover{color:var(--ink);background:var(--tint)}}
.currency-tab[aria-pressed="true"]{color:var(--ink);background:var(--surface);border-color:var(--line-strong)}
.analytics-currency-header .currency-tabs+p{margin-top:10px}
.analytics-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px;margin-bottom:20px}
.stat-card{min-width:0;padding:18px;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
.stat-card-label{display:block;font-size:13.5px;color:var(--muted)}
.stat-card-value{display:block;margin-top:6px;font-family:var(--display);font-size:24px;font-weight:700;font-variant-numeric:tabular-nums;white-space:normal;overflow-wrap:anywhere}
.analytics-grid{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);gap:16px;margin-bottom:20px;align-items:start}
.analytics-panel{padding:20px;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
.analytics-panel-header{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:14px}
.analytics-panel-header h2{font-size:18px}
.analytics-panel-header .help-copy{margin:0;flex-basis:100%}
.chart-legend{display:flex;gap:14px;font-size:13px;color:var(--muted)}
.legend-item{display:inline-flex;align-items:center;gap:6px}
.legend-swatch{width:10px;height:10px;border-radius:3px}
.legend-swatch-paid,.chart-paid{background:var(--ink-accent)}
.legend-swatch-unpaid,.chart-unpaid{background:color-mix(in srgb,var(--ink-accent) 40%,#fff)}
.activity-month{display:grid;grid-template-columns:70px minmax(0,1fr);gap:12px;margin-bottom:16px;font-size:13px;color:var(--muted)}
.activity-pair{display:flex;flex-direction:column;gap:6px}
.activity-row{display:grid;grid-template-columns:64px minmax(30px,1fr) auto;gap:10px;align-items:center}
.activity-row .amount{min-width:0;text-align:right;color:var(--ink);white-space:normal;overflow-wrap:anywhere}
.chart-track{display:flex;height:12px;overflow:hidden;border-radius:4px;background:var(--bg)}
.chart-track span{height:100%;border-radius:4px}
.unit-tags{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.unit-tag{padding:6px 12px;border-radius:99px;background:var(--tint);color:var(--ink-accent);font-size:13.5px;font-weight:550}

/* ---------- Sign in, first run ---------- */
.auth-shell{display:flex;flex-direction:column;align-items:center;gap:24px;min-height:100vh;padding:56px 16px 40px}
.auth-card{width:100%;max-width:420px;padding:28px;background:var(--surface);border:1px solid var(--line);border-radius:16px}
.auth-card h1{font-size:24px}
.auth-card>p{margin:8px 0 22px;color:var(--muted)}
.auth-card form>.button{width:100%;margin-top:20px}
.auth-links{display:flex;flex-wrap:wrap;justify-content:space-between;gap:10px 16px;margin-top:18px;font-size:14px}
.auth-email-actions{display:grid;gap:12px;margin-top:20px}
.auth-recovery-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.button-google{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:42px;padding:10px 12px;background:#fff;color:#1f1f1f;border:1px solid #747775;font-family:"Google Sans",Roboto,Arial,sans-serif;font-size:14px;font-weight:500}
.button-google img{width:20px;height:20px;flex:none}
@media(hover:hover){.button-google:hover{background:#f7f8f8;border-color:#1f1f1f}}
.auth-divider{display:flex;align-items:center;gap:12px;margin:16px 0;color:var(--muted);font-size:12px}
.auth-divider::before,.auth-divider::after{content:"";height:1px;flex:1;background:var(--line)}
.auth-card .help-copy{margin-top:14px;font-size:13px;color:var(--muted)}
.auth-footnote{font-size:13px;color:var(--muted)}
.onboard{max-width:520px;margin:6vh auto 0;padding:28px;background:var(--surface);border:1px solid var(--line);border-radius:16px}
.onboard h1{font-size:26px}
.onboard>p{margin:10px 0 22px;color:var(--muted)}
.onboard-shell>:is(#view,.invitation-banner,.global-error){width:100%;max-width:520px}
.onboard-shell .invitation-banner{margin-bottom:0}
.onboard-shell .onboard{max-width:none;margin:0}
.startup-message{max-width:560px;margin:10vh auto;padding:24px;line-height:1.7}
.startup-message h1{margin:28px 0 14px;font-size:28px}

/* ---------- Public page ---------- */
.landing-header,.landing-hero,.landing-steps,.landing-faq,.landing-footer{max-width:1120px;margin:0 auto;padding-left:32px;padding-right:32px}
.landing-header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding-top:20px;padding-bottom:20px}
.landing-header nav{display:flex;align-items:center;gap:8px}
.landing-hero{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,.9fr);gap:64px;align-items:center;padding-top:56px;padding-bottom:88px}
.landing-intro h1{font-size:clamp(44px,6.4vw,76px);font-weight:750;letter-spacing:-.03em;line-height:1.02}
.landing-intro>p{margin:24px 0 28px;max-width:44ch;font-size:18px;line-height:1.6;color:var(--muted)}
.landing-cta{display:flex;gap:12px;flex-wrap:wrap}
.landing-cta .button{min-height:50px;padding:0 22px;font-size:16px}
.landing-reassure{margin-top:14px;font-size:14.5px;color:var(--muted)}
/* width:100% because the frame is a size container with auto margins: as a grid item it would otherwise shrink to nothing. */
.landing-example{width:100%;transform:rotate(1.2deg)}
.landing-steps{padding-top:72px;padding-bottom:80px;border-top:1px solid var(--line)}
.landing-steps>h2{margin-bottom:56px;font-size:clamp(28px,3.4vw,38px);font-weight:700;letter-spacing:-.02em;text-align:center}
.landing-steps ol{display:grid;gap:48px;max-width:940px;margin:0 auto;padding:0;list-style:none}
/* Zig-zag: the picture swaps sides on every other step. */
.landing-step{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:56px;align-items:center}
.landing-step:nth-child(even) .step-art{order:2}
.step-copy h3{margin-bottom:10px;font-size:24px}
.step-copy p{max-width:40ch;font-size:16.5px;line-height:1.65;color:var(--muted)}
/* Every step's picture is the same size and drawn with the same parts: white cards, one accent colour, real text for labels and grey pills for values. */
.step-art{display:grid;place-items:center;height:340px;padding:20px;border:1px solid var(--line);border-radius:20px;background:color-mix(in srgb,var(--ink) 3.5%,var(--bg))}
.mock{--mock-brand:#2f6f5e;--mock-tint:color-mix(in srgb,var(--mock-brand) 14%,#fff);--mock-pill:#e3e3e3;--mock-pill-strong:#c6c6c6;display:flex;flex-direction:column;gap:12px;width:100%;min-width:0;max-width:300px;height:256px;font-size:13px;line-height:18px;color:var(--ink)}
.mock-card{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;padding:16px;border-radius:12px;background:#fff;box-shadow:0 1px 2px rgb(31 31 31/.06),0 10px 28px rgb(31 31 31/.09)}
.mock-text{font-weight:650}
.mock-label{font-size:11.5px;font-weight:550;line-height:16px;color:var(--muted)}
.mock-pill{display:block;flex:none;height:8px;border-radius:4px;background:var(--mock-pill)}
.mock-pill-strong{background:var(--mock-pill-strong)}
.w-qty{width:34px}.w-value{width:56px}.w-35{width:35%}.w-50{width:50%}.w-65{width:65%}.w-80{width:80%}.w-100{width:100%}
.mock-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:auto}
/* 1. A small invoice in the business's colour, with the colour choices beneath. */
.mock-paper{position:relative;overflow:hidden;padding-top:21px}
.mock-paper::before{content:"";position:absolute;inset:0 0 auto;height:5px;background:var(--mock-brand)}
.mock-paper-top{display:flex;align-items:center;gap:10px;margin-bottom:14px}
.mock-logo{display:grid;place-items:center;width:34px;height:34px;flex:none;border-radius:9px;background:var(--mock-brand);color:#fff;font-size:12px;font-weight:700;letter-spacing:.02em}
.mock-doc{margin-left:auto;font-size:18px;font-weight:300;color:var(--muted)}
.mock-th{height:18px;border-radius:4px;background:var(--mock-tint)}
.mock-row{display:flex;justify-content:space-between;padding:10px 6px;border-bottom:1px solid var(--line)}
.mock-words{margin-top:auto;font-size:12px;color:var(--ink)}
.mock-words .mock-label{display:block}
.mock-swatches{display:flex;justify-content:center;gap:12px;padding:2px 0 4px}
.mock-swatches span{width:20px;height:20px;border-radius:50%;background:#111}
.mock-swatches span:nth-child(2){background:var(--mock-brand)}
.mock-swatches span:nth-child(3){background:#b3323f}
.mock-swatches span:nth-child(4){background:#2d4f9e}
.mock-swatches .is-picked{box-shadow:0 0 0 2px color-mix(in srgb,var(--ink) 3.5%,var(--bg)),0 0 0 4px var(--mock-brand)}
/* 2. The editor's Items step: one card per line, then Add a line and the total. */
.mock-form{gap:8px}
.mock-line{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:var(--bg)}
.mock-field .mock-label{display:block;margin-bottom:5px}
.mock-field-wide{grid-column:1/-1}
.mock-field-end{text-align:right}
.mock-field-end .mock-pill{margin-left:auto}
.mock-add{color:var(--mock-brand)}
.mock-total{display:flex;align-items:center;gap:10px}
/* 3. The email with the PDF attached, then the payment arriving. */
.mock-mail-row{display:flex;align-items:center;gap:10px;height:34px;border-bottom:1px solid var(--line)}
.mock-mail-row:first-child{margin-top:-8px}
.mock-mail-row .mock-label{flex:none;width:46px}
.mock-body{display:grid;gap:8px;margin-top:14px}
.mock-file{display:flex;align-items:center;gap:6px;min-width:0;height:30px;padding:0 10px;border:1px solid var(--line);border-radius:8px}
.mock-file .mock-pill{flex:0 1 56px}
.mock-file svg{width:15px;height:15px;flex:none;color:var(--mock-brand)}
.mock-button{flex:none;height:30px;padding:0 16px;border-radius:8px;background:var(--mock-brand);color:#fff;font-weight:650;line-height:30px}
.mock-paid{flex:none;flex-direction:row;align-items:center;gap:10px;padding:12px 16px}
.mock-paid .mock-text{white-space:nowrap}
.mock-paid .mock-pill{flex:0 1 56px;margin-left:auto}
.mock-tick{display:grid;place-items:center;width:22px;height:22px;flex:none;border-radius:50%;background:var(--mock-brand);color:#fff}
.mock-tick svg{width:13px;height:13px}
.landing-faq{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.6fr);gap:40px;padding-top:56px;padding-bottom:72px;border-top:1px solid var(--line)}
.landing-faq h2{font-size:26px}
.landing-faq details{padding:16px 0;border-bottom:1px solid var(--line)}
.landing-faq details:first-child{padding-top:0}
.landing-faq summary{cursor:pointer;font-weight:600}
.landing-faq p{margin-top:10px;max-width:60ch;color:var(--muted);line-height:1.65}
.landing-footer{display:flex;justify-content:space-between;gap:16px;padding-top:20px;padding-bottom:28px;border-top:1px solid var(--line);font-size:14px;color:var(--muted)}

/* ---------- Narrower screens ---------- */
/* Wide screens: the invoice editor fills the window. A slim bar on top, then two panes that scroll on their own:
   the steps on the left, as a card on the page background like Business settings, and the invoice on the right. Each pane's header and the step buttons stay put. */
@media(min-width:1061px){
  .main-container:has(#view-compose){display:flex;flex-direction:column;height:100vh;height:100dvh;padding:0;overflow:hidden}
  .main-container:has(#view-compose)>:not(#view){flex:none;margin:12px 20px 0}
  .main-container:has(#view-compose)>#view,#view-compose{flex:1;min-height:0;display:flex;flex-direction:column}
  .compose-bar{flex:none;flex-wrap:nowrap;min-height:52px;margin:0;padding:8px 20px;background:var(--surface);border-bottom:1px solid var(--line)}
  .compose-bar h1{font-size:17px;white-space:nowrap}
  .workspace{flex:1;min-height:0;grid-template-columns:minmax(420px,1fr) minmax(0,1.15fr);grid-template-rows:minmax(0,1fr);gap:0;align-items:stretch}
  .editor-column{--gutter:max(28px,calc((100% - 640px)/2));display:flex;flex-direction:column;min-height:0;border-right:1px solid var(--line)}
  .steps-nav,.preview-toolbar{flex:none;display:flex;align-items:center;min-height:61px;border-bottom:1px solid var(--line)}
  .steps-nav{margin:0;padding:0 max(18px,calc((100% - 660px)/2))}
  .steps{flex:1;align-self:stretch;margin:0}
  .editor-scroll{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:24px var(--gutter) 32px}
  .editor-scroll .editor-panel{margin-bottom:0}
  .step-actions{position:relative;left:auto;right:auto;bottom:auto;flex:none;padding:12px var(--gutter)}
  .preview-column{display:flex;flex-direction:column;min-height:0;padding:0;border-radius:0}
  .preview-toolbar{justify-content:space-between;margin:0;padding:8px 20px;background:var(--bg)}
  .preview-scroll{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:24px 28px 28px}
}
@media(max-width:1060px){
  .paper-frame{max-width:640px}
}
@media(max-width:900px){
  :root{--sidebar-width:0px;--page-gutter:16px;--mobile-nav-height:64px;--action-bottom:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom))}
  input,select,textarea{font-size:16px}
  .app-layout{display:block}
  .sidebar{height:auto;flex-direction:row;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)}
  .sidebar .brand{padding:0}
  .sidebar>.brand{min-width:44px;min-height:44px;justify-content:center}
  /* In the top bar the logo sits beside the business picker: same height, same corners, same centre line. */
  .sidebar .brand-icon{width:40px;height:40px}
  .business-choice .business-pick{margin-top:0}
  .business-choice select{height:40px}
  .colour-inputs input{min-height:44px}
  .brand-name{display:none}
  .sidebar .brand-name{display:none}
  .sidebar-foot{flex:1;min-width:0;margin:0;flex-direction:row;align-items:center;justify-content:flex-end;gap:6px}
  .business-choice{flex:1;min-width:0;max-width:280px;margin-right:auto}
  .business-choice label>span:first-child{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
  .app-menu>summary{padding:0 10px}
  .app-menu-content{top:calc(100% + 6px);bottom:auto;left:auto;right:0;width:240px}
  .nav-tabs{
    position:fixed;left:0;bottom:0;z-index:20;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;width:100vw;
    height:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding:6px max(6px,env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));background:var(--surface);border-top:1px solid var(--line);
  }
  .nav-tab{min-width:0;flex-direction:column;justify-content:center;gap:3px;min-height:50px;padding:4px 2px;margin:0;font-size:12px;font-weight:550;background:none;color:var(--muted);box-shadow:none}
  .nav-tab.active{color:var(--ink-accent);background:none}
  .nav-tab .icon{width:22px;height:22px;color:inherit}
  .nav-tabs .nav-create,.nav-tabs .nav-extra{display:none}
  .nav-more{display:block;min-width:0}
  .nav-more>summary.nav-tab{display:flex;align-items:center;height:100%}
  .label-full{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
  .label-short{display:block}
  .main-container{padding:20px max(16px,env(safe-area-inset-right)) calc(var(--action-bottom) + 24px) max(16px,env(safe-area-inset-left))}
  .action-bar{padding-left:max(16px,env(safe-area-inset-left));padding-right:max(16px,env(safe-area-inset-right))}
  .page-heading{margin-bottom:18px}
  .page-heading h1{font-size:24px}
  .toast{bottom:calc(84px + env(safe-area-inset-bottom))}
  .settings-row,.analytics-grid{grid-template-columns:minmax(0,1fr)}
  .record-table{min-width:560px}
  .landing-header,.landing-hero,.landing-steps,.landing-faq,.landing-footer{padding-left:20px;padding-right:20px}
  .landing .brand-name{display:inline}
  .landing-hero{grid-template-columns:minmax(0,1fr);gap:40px;padding-top:32px;padding-bottom:56px}
  .landing-faq{grid-template-columns:minmax(0,1fr);gap:24px;padding-top:40px;padding-bottom:40px}
  .landing-steps{padding-top:48px;padding-bottom:48px}
  .landing-steps>h2{margin-bottom:32px}
  .landing-steps ol{gap:40px;max-width:520px}
  .landing-step{grid-template-columns:minmax(0,1fr);gap:20px}
  .landing-step:nth-child(even) .step-art{order:0}
  .step-art{height:300px}
  .step-copy h3{font-size:21px}
  .step-copy p{max-width:none;font-size:16px}
}
@container invoice-editor (max-width:700px){
  .line-row{grid-template-columns:repeat(2,minmax(0,1fr));padding:14px 12px;gap:12px}
  .line-item{grid-column:1;grid-row:1;min-width:0}
  .line-row .line-item{grid-column:1/-1}
  .line-qty{grid-column:1;grid-row:2;min-width:0}
  .line-amount{grid-column:2;grid-row:2;min-width:0}
  .lines-foot{flex-wrap:wrap;gap:12px}
  .editor-total{flex-wrap:wrap;justify-content:flex-end;gap:4px 10px}
}
@container invoice-editor (max-width:330px){
  .line-row{grid-template-columns:minmax(0,1fr)}
  .line-qty{grid-column:1/-1;grid-row:2}
  .line-amount{grid-column:1/-1;grid-row:3}
}
@media(max-width:560px){
  /* Reuse the full table content as labelled records; nothing needs a sideways swipe. */
  .table-shell .record-table,.record-table tbody{display:block;width:100%;min-width:0}
  .record-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .record-table tbody tr{position:relative;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:16px;border-bottom:1px solid var(--line)}
  .record-table tbody tr:last-child{border-bottom:0}
  .record-table tbody td,.table-card .record-table tbody td:first-child,.table-card .record-table tbody td:last-child{grid-column:1/-1;min-width:0;width:auto;padding:0;border:0;text-align:left;white-space:normal;overflow-wrap:anywhere}
  .record-table tbody td:first-child{padding-right:44px}
  .record-table td[data-label]::before{content:attr(data-label);display:block;margin-bottom:3px;font-size:12px;font-weight:500;color:var(--muted)}
  .record-table td:first-child::before,.record-table td.actions-cell::before{display:none}
  .record-table tbody .actions-cell{position:absolute;top:10px;right:12px;display:block;width:44px;grid-column:auto}
  .record-table .row-primary{min-height:44px;overflow-wrap:anywhere}
  .record-table tbody td:empty{display:none}
  #view-history .record-table td:nth-child(3){grid-column:1}
  #view-history .record-table td:nth-child(4){grid-column:2;text-align:right}
  .record-table .account-balance{align-items:flex-start}
  .row-menu-content{max-width:calc(100vw - 16px)}
  .button-small{min-height:44px}
  .modal-close{width:44px;height:44px}
  .fields-two{grid-template-columns:minmax(0,1fr)}
  .fields>*{min-width:0}
  .page-heading>*{min-width:0}
  .page-heading>.button{width:100%}
  /* Buttons keep their whole label: those that don't fit side by side take a row each, the main one last. */
  .dialog-actions{display:flex;flex-wrap:wrap}
  .dialog-actions>.button{flex:1 0 auto}
  /* On a phone a long form scrolls under its buttons, which stay at the foot of the dialog. */
  dialog.settings-dialog>.dialog-actions:last-child,dialog.settings-dialog>form:last-child>.dialog-actions:last-child{position:sticky;bottom:-24px;z-index:1;margin:22px -24px -24px;padding:12px 24px 24px;background:var(--surface);border-top:1px solid var(--line)}
  .row-menu>summary{width:44px;height:44px}
  .row-menu-content>.button{min-height:44px}
  .logo-remove{width:44px;height:44px}
  .analytics-cards{grid-template-columns:minmax(0,1fr)}
  .account-summary{grid-template-columns:minmax(0,1fr)}
  .account-summary-values>div{flex-wrap:wrap}
  .account-summary-values dd{min-width:0;margin-left:auto;overflow-wrap:anywhere}
  .stat-card-value{white-space:normal;overflow-wrap:anywhere}
  .editor-total strong,.line-amount strong{overflow-wrap:anywhere}
  .editor-panel,.settings-panel{padding:16px}
  .steps{gap:0}
  .step{padding:10px 0;font-size:12.5px}
  .step-label{max-width:100%}
  .review-row{grid-template-columns:minmax(0,1fr) auto}
  .review-row dt{grid-column:1;grid-row:1}
  .review-row>.button{grid-column:2;grid-row:1}
  .review-row dd{grid-column:1/-1;grid-row:2}
  .action-bar .button{padding:0 12px;font-size:14px}
  .preview-column{padding:12px}
  .staff-invite-form,.branding-grid{grid-template-columns:minmax(0,1fr)}
  .list-tools{flex-wrap:wrap}
  .list-tools input{max-width:none}
  /* Page buttons share rows and fill them, so they line up whatever their labels. */
  .heading-actions>.button{flex:1 1 auto}
  .table-card>h2{padding:18px 16px 4px}
  .activity-month{grid-template-columns:minmax(0,1fr);gap:6px}
  .landing-header nav .button-quiet{display:none}
  .landing-header .brand-name{display:inline}
}
/* The smallest phones: keep the public header's brand and button on one line without spilling off the side. */
@media(max-width:360px){
  .landing-header{gap:8px}
  .landing-header .brand{gap:8px;font-size:15.5px}
  .landing-header nav .button{padding:0 12px;font-size:14px}
}
@media(prefers-reduced-motion:no-preference){
  .button,.nav-tab,input,select,textarea{transition:background-color .12s,border-color .12s,box-shadow .12s,filter .12s}
}

/* ---------- Print: only the invoice ---------- */
@page{size:A4;margin:16mm}
@media print{
  html,body{background:#fff!important}
  /* Only the print sheet prints: the saved invoice, whatever page is open. */
  #app,.toast,dialog,noscript,#boot-loader{display:none!important}
  .print-sheet{display:block!important}
  /* The page margins come from @page; the bar and the 8mm under it lead, as in the PDF. */
  .invoice-paper{display:block;width:auto;min-height:0!important;padding:9.4mm 0 0;transform:none!important;box-shadow:none;border-radius:0;print-color-adjust:exact;-webkit-print-color-adjust:exact}
  .invoice-paper::before{height:1.4mm}
  .paper-table thead{display:table-header-group}
  .paper-table tr,.paper-totals,.paper-payment,.paper-note,.paper-footer{break-inside:avoid}
}

/* ---------- Currency picker: the round flag sits inside the select ---------- */
.currency-select{position:relative;display:block;margin-top:6px}
.currency-select>select{margin-top:0;padding-left:46px;text-overflow:ellipsis;white-space:nowrap}
/* Headings named by a currency carry the same flag. */
.currency-title{display:inline-flex;align-items:center;gap:10px;vertical-align:bottom}
.flag{flex:none;width:22px;height:22px;border-radius:50%;box-shadow:0 0 0 1px rgba(0,0,0,.06)}
.heading-kind{font-weight:400;color:var(--muted)}
/* The business switcher shows the current business the same way. */
.business-pick{position:relative;display:block;margin-top:6px}
.business-pick>select{margin-top:0;padding-left:46px}
.business-mark{position:absolute;left:8px;top:50%;display:grid;place-items:center;width:28px;height:28px;margin-top:-14px;border-radius:8px;pointer-events:none;background:var(--brand);color:var(--brand-text);font-size:11.5px;font-weight:700;letter-spacing:.02em;line-height:1}
.currency-flag{position:absolute;left:12px;top:50%;width:24px;height:24px;margin-top:-12px;border-radius:50%;pointer-events:none;box-shadow:0 0 0 1px rgba(0,0,0,.06)}
.details-current{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;margin-bottom:18px;padding:12px 14px;border:1px solid var(--line-strong);border-radius:10px;background:var(--bg)}
.details-current .help-copy{margin:0;flex:1 1 240px}
/* Tax: the rate on each line, the tax rows under the totals and the business's rates in settings. */
.paper-table-taxed th:first-child{width:38%}
.paper-table-taxed th:nth-child(2){width:15%}
.paper-table-taxed th:nth-child(3){width:16%}
.paper-table-taxed th:nth-child(4){width:12%}
.paper-table-taxed th:nth-child(5){width:19%}
.paper-totals small{font-size:.88em}
.paper-tax-note{width:62%;margin:.6em 0 0 auto;font-size:.88em;line-height:1.5;color:var(--p-muted);text-align:right;white-space:pre-line}
.line-tax{grid-column:1/-1;min-width:0}
.tax-switch{margin:0}
.tax-rates .field-label{margin-bottom:8px}
.tax-rate-list{display:flex;flex-direction:column;gap:8px;margin-bottom:10px}
.tax-rate{position:relative;display:grid;grid-template-columns:28px minmax(0,1fr) 28px;gap:10px;align-items:start;padding:12px 10px 12px 12px;background:var(--bg);border:1px solid var(--line);border-radius:12px}
.tax-default{display:grid;place-items:center;height:44px}
.tax-default input{width:18px;height:18px;min-height:0;margin:0;accent-color:var(--brand)}
.tax-rate-body{display:flex;flex-direction:column;gap:8px;min-width:0}
.tax-parts{display:flex;flex-direction:column;align-items:flex-start;gap:8px}
.tax-part{display:grid;grid-template-columns:minmax(64px,110px) 104px 28px;gap:6px;align-items:center}
.tax-part .unit-field input{padding-right:30px}
.tax-none{font-size:13.5px;color:var(--muted)}
.tax-add-part{font-size:13.5px}
.tax-rate-remove,.tax-part-remove{width:28px;height:28px;padding:0;border:0;border-radius:6px;background:none;font-size:18px;line-height:1;color:var(--muted)}
.tax-rate-remove{margin-top:8px}
@media(hover:hover){.tax-rate-remove:hover,.tax-part-remove:hover{background:#fbecee;color:var(--red)}}
@media(max-width:520px){.tax-part{grid-template-columns:minmax(0,1fr) 96px 28px;width:100%}}
.tax-switch{width:fit-content}
.tax-invoice-help{display:block;margin-top:4px}
.add-fields{display:flex;flex-wrap:wrap;gap:6px 20px}
.add-fields .text-button{font-size:14px}
.setup-summary{display:flex;align-items:center;gap:14px}
.setup-summary p{flex:1;min-width:0;margin:0;font-size:14.5px}
.setup-summary .secondary{display:block;margin-top:2px;font-size:13.5px;color:var(--muted)}
.setup-summary .button{flex:none}
.setup-brand{display:flex;align-items:center;gap:6px;flex:none}
.setup-brand img{max-width:72px;max-height:36px;object-fit:contain}
.setup-swatch{width:20px;height:20px;border-radius:50%;border:1px solid var(--line-strong)}
