:root{color-scheme:light;--canvas:#eef2f5;--ink:#182b39;--muted:#4c6171;--line:#d4dee6;--accent:#264f68;--accent-dark:#1c4058;--positive:#245b47;--negative:#8b2f31}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;background:var(--canvas);color:var(--ink);font:1rem/1.5 "DM Sans",system-ui,sans-serif}
button,input,select,textarea{font:inherit}
button,select{cursor:pointer}
button:disabled,select:disabled{cursor:default;opacity:.56}
a{color:var(--accent-dark)}
:focus-visible{outline:3px solid #4185a9;outline-offset:3px}
.site-header{background:#fff;border-bottom:1px solid var(--line)}
.header-inner{display:flex;align-items:center;justify-content:space-between;gap:12px;max-width:1400px;margin:auto;padding:14px clamp(14px,3.4vw,44px);flex-wrap:wrap}
.wordmark{display:inline-flex;align-items:center;gap:10px;font-weight:700;letter-spacing:-.025em}
.brand-mark{display:grid;place-items:center;width:34px;height:34px;background:#224861;color:#fff;border-radius:9px}
nav{display:flex;align-items:center;gap:4px;flex-wrap:wrap}
nav button,.text-button,.close-button{border:0;background:transparent;color:var(--accent-dark);font-weight:650;border-radius:8px;min-height:44px;padding:8px 10px}
nav button:hover,.text-button:hover,.close-button:hover{background:#e8eff4}
nav button[aria-current=page]{background:#e5edf2}
.page{max-width:1400px;padding:26px clamp(14px,3.4vw,44px) 34px;margin:auto}
.page-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:22px}
h1,h2,p{margin:0}
.page-heading h1,.sign-in-view h1{font:580 clamp(33px,4vw,51px)/1.1 Fraunces,Georgia,serif;letter-spacing:-.04em}
.page-heading p,.sign-in-view>p{margin-top:7px;color:var(--muted)}
.status-chip{background:#e1eaf0;color:#234961;border:1px solid #cadce6;border-radius:100px;padding:5px 12px;font-weight:700;font-size:.875rem}
.status-chip[data-state=sent]{background:#e3f0e9;border-color:#c0dacd;color:var(--positive)}
.workspace{display:grid;grid-template-columns:minmax(0,.83fr) minmax(0,1.17fr);align-items:start;gap:24px}
.edit-panel,.preview-panel{min-width:0}
fieldset{min-width:0;margin:0;padding:0;border:0}
.editor-card{background:#fff;border:1px solid var(--line);border-radius:13px;padding:18px 20px}
.editor-card+.editor-card{margin-top:12px}
.editor-card h2,.preview-toolbar h2{font-size:1rem;font-weight:720}
.card-heading,.preview-toolbar,.dialog-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.card-heading{margin:-5px -3px 0 0}
.muted,.optional{color:var(--muted)}
.editor-card .muted{font-size:.94rem}
.field{display:grid;gap:5px;min-width:0}
.editor-card>.field,.dialog-heading+.field,.field+.field{margin-top:11px}
.editor-card>.field:only-child{margin-top:0}
.field label,.label-settings legend,.preview-toolbar label{font-size:.9rem;font-weight:670}
input:not([type=file]),textarea,select{min-height:44px;width:100%;min-width:0;border:1px solid #c9d6df;border-radius:8px;background:#fff;color:var(--ink);padding:9px 11px}
textarea{resize:vertical}
select{appearance:none;padding-right:32px;background-image:url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%234c6171' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center}
.line-item{display:grid;grid-template-columns:minmax(68px,.7fr) minmax(80px,1fr) auto;gap:9px 10px;padding-top:9px}
.line-item+.line-item{border-top:1px solid var(--line);margin-top:13px}
.line-item .field{margin:0}
.line-item-description{grid-column:1/-1}
.line-item .remove-item{align-self:end;padding:7px;min-height:44px;color:var(--negative);border:1px solid transparent}
.preview-panel{background:#e8eef2;border:1px solid var(--line);border-radius:15px;padding:14px 16px 16px;
  position:sticky;top:12px;max-height:calc(100dvh - 24px);overflow:auto}
.preview-toolbar{margin-bottom:13px}
.preview-toolbar label{display:flex;align-items:center;gap:8px}
.preview-toolbar select{font-size:1rem;width:auto}
.action-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;position:sticky;bottom:0;
  background:#f8fafb;border:1px solid var(--line);border-radius:12px;margin-top:18px;padding:11px 14px;z-index:1}
.action-amount{display:flex;align-items:baseline;gap:10px}.action-amount span{font-weight:650;color:var(--muted)}
.action-amount strong{font-size:1.2rem;font-variant-numeric:tabular-nums}
.action-buttons,.dialog-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.action-buttons{margin-left:auto}
.button{min-height:44px;border:1px solid transparent;border-radius:8px;padding:9px 14px;font-weight:700;text-decoration:none;display:inline-flex;justify-content:center;align-items:center}
.primary{background:var(--accent);color:#fff}.primary:hover{background:var(--accent-dark)}
.secondary{background:#fff;border-color:#bfcfd9;color:var(--accent-dark)}.secondary:hover{background:#edf3f7}
.feedback{margin:0 0 14px;border:1px solid #bdd7c9;border-radius:8px;padding:10px 12px;color:var(--positive);background:#ecf5ef}
.feedback[data-error=true]{border-color:#e7c9c9;background:#fbebeb;color:var(--negative)}
.mobile-tabs{display:none}
.sign-in-view{max-width:460px;margin:38px auto}
.sign-in-view #clerk-sign-in{margin-top:18px}
.sign-in-view .button{margin-top:14px}
dialog{width:min(100% - 28px,550px);max-height:calc(100dvh - 26px);border:1px solid var(--line);border-radius:14px;padding:20px;color:var(--ink);background:#fff}
dialog::backdrop{background:#1227378a}
.dialog-heading{margin-bottom:12px}
.dialog-heading h2{font:580 1.6rem Fraunces,Georgia,serif}
.close-button{font-size:1.6rem;line-height:1;min-width:44px}
.dialog-actions{margin-top:16px}
dialog .feedback{margin-top:12px}
.label-settings{margin-top:14px;padding-top:10px;border-top:1px solid var(--line);display:grid;grid-template-columns:1fr 1fr;gap:10px}
.label-settings .field{margin:0}
.logo-tools{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.logo-tools img{max-width:145px;max-height:70px;object-fit:contain}
.history-list{list-style:none;padding:0;display:grid;gap:9px;max-width:850px}
.history-list button{width:100%;text-align:left;display:grid;grid-template-columns:1fr auto;gap:4px 10px;padding:12px 15px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--ink)}
.history-list button:hover{border-color:#6f93a9}.history-list button .status-chip{grid-row:1;grid-column:2}.history-list button .muted{grid-column:1/-1;overflow-wrap:anywhere}
@media (max-width:790px){
  .workspace{display:block}
  .mobile-tabs{display:flex;gap:5px;margin-bottom:12px;background:#dfe8ee;padding:4px;border-radius:10px}
  .mobile-tabs button{flex:1;min-height:44px;border:0;background:transparent;color:var(--accent-dark);font-weight:700;border-radius:7px}
  .mobile-tabs button[aria-selected=true]{color:var(--ink);background:#fff}
  #editor[data-tab=edit] .preview-panel,#editor[data-tab=preview] .edit-panel{display:none}
  .preview-panel{padding:10px;position:static;max-height:none;overflow:visible}
  .editor-card{padding:15px}
  .action-bar{border-radius:10px}
}
@media (max-width:400px){
  .preview-toolbar label{flex-wrap:wrap}
  .page{padding-inline:12px}
  .action-amount{width:100%}
  .action-buttons{margin-left:0;width:100%}
  .action-buttons .button{flex:1;font-size:.93rem;padding-inline:9px}
  .label-settings{grid-template-columns:1fr}
  .invoice-paper{padding:15px}
}
