:root{
  font:15px/1.5 system-ui,sans-serif;
  --background:#f8f9fb;--surface:#fff;--text:#172b44;--border:#e0e5ec;
  --sidebar:#ffffff;--sidebar-text:#43556b;--accent:#235ed8;--accent-text:#fff;
  --hover:#eef4ff;--hover-text:#172b44;--focus:#2467e8;
  --selection:#cfe1ff;--selection-text:#172b44;--active-tab:#e8f0ff;--active-tab-text:#1d4fb9;
  --button-radius:7px;--panel-radius:8px;--button-shadow:none;--line:var(--border);--ink:var(--text);
  color:var(--text);background:var(--background);
}
*{box-sizing:border-box}
::selection{background:var(--selection);color:var(--selection-text)}
body{margin:0}
button,input,select,textarea{font:inherit}
button,.button{cursor:pointer;border:1px solid var(--line);border-radius:var(--button-radius);background:var(--surface);color:var(--ink);padding:.47rem .8rem;text-decoration:none;box-shadow:var(--button-shadow)}
.primary{background:var(--accent);color:var(--accent-text);border-color:var(--accent)}
button:hover,.button:hover{background:var(--hover);color:var(--hover-text)}
:is(button,a,input,select,textarea):focus-visible,
:root[data-mouse-focus=true] :is(button,a,input,select,textarea):focus{outline:2px solid var(--focus);outline-offset:2px}
.shell{display:grid;grid-template-columns:208px minmax(0,1fr);min-height:100vh}
aside{background:var(--sidebar);color:var(--sidebar-text);padding:27px 13px;border-right:1px solid var(--border)}
.brand{display:flex;align-items:center;gap:5px;padding:0 11px 32px;color:var(--sidebar-text);font-weight:700;font-size:1.3rem;text-decoration:none}
.brand-mark{color:#35383d;line-height:1.35}
.brand-plus{color:#c55216}
nav button{display:block;width:100%;text-align:left;background:transparent;color:inherit;border:0;margin-bottom:4px;box-shadow:none}
nav button[aria-current=page]{background:var(--active-tab);color:var(--active-tab-text);font-weight:600}
main{min-width:0}
header{background:var(--surface);border-bottom:1px solid var(--line);padding:15px clamp(16px,4vw,44px);display:flex;gap:12px;align-items:end;flex-wrap:wrap}
header label{font-size:.8rem;color:var(--text)}
header select{min-width:12rem}
#workspace,#notice{margin:0 clamp(16px,4vw,44px)}
#notice:not(:empty){margin-top:14px;padding:10px 12px;background:#e0efeb;border-radius:7px}
#notice.error{background:#fbe4e1;color:#862a26}
#workspace{padding:24px 0}
h1,h2,h3{line-height:1.15;margin:0 0 14px}
h1{font-size:clamp(1.7rem,3vw,2.45rem)}
.top,.actions,.tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.top{justify-content:space-between;margin-bottom:16px}
.top h1,.top h2{margin:0}
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px}
.card,.panel{background:var(--surface);padding:16px;border:1px solid var(--line);border-radius:var(--panel-radius);box-shadow:0 2px 5px #172b4408}
.card strong{display:block;font-size:1.4rem}
.panel{margin-bottom:14px}
.table-wrap,.paper-wrap{overflow:auto}
table{border-collapse:collapse;width:100%}
th,td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--line)}
th{background:var(--background)}
label{display:block}
label>input:not([type=checkbox]),label>select,label>textarea{display:block;width:100%;margin-top:4px}
input:not([type=checkbox]),select,textarea{background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:6px 8px;min-width:0}
textarea{resize:vertical;min-height:64px}
.fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin-bottom:14px}
.wide{grid-column:1/-1}
.split{display:grid;grid-template-columns:minmax(300px,1fr) minmax(0,1.2fr);gap:14px;align-items:start}
dialog{color:var(--text);background:var(--surface);width:min(670px,calc(100% - 28px));border:1px solid var(--line);border-radius:var(--panel-radius);padding:20px}
dialog::backdrop{background:#17222e88}
.preview{overflow:auto;background:#eaf0f6;padding:12px;border-radius:var(--panel-radius)}
.template-viewer{min-width:0}
.view-tools{margin-bottom:8px}
.view-tools output{min-width:3.5em;text-align:center}
.template-preview{max-height:72vh;overscroll-behavior:contain}
.template-preview.pan-enabled,.template-preview.pan-enabled *{cursor:grab;touch-action:none}
.template-preview.panning,.template-preview.panning *{cursor:grabbing}
.view-tools [aria-pressed=true]{background:var(--accent);color:var(--accent-text)}
.board{position:relative;width:max-content;padding:22px 0 0 22px;user-select:none}
.paper{position:relative;background:white;color:#20252a;box-shadow:0 2px 7px #20313d33;overflow:hidden}
.ruler{position:absolute;background-color:#dae4ea;color:#435966;touch-action:none;cursor:crosshair;font:9px system-ui}
.ruler.top-ruler{height:22px;left:22px;top:0;background-image:repeating-linear-gradient(90deg,#8197a3 0 1px,transparent 1px 12px);background-size:auto 5px;background-repeat:repeat-x;background-position:bottom}
.ruler.left-ruler{width:22px;left:0;top:22px;background-image:repeating-linear-gradient(#8197a3 0 1px,transparent 1px 12px);background-size:5px auto;background-repeat:repeat-y;background-position:right}
.ruler span{position:absolute;pointer-events:none}
.element{position:absolute;white-space:pre-wrap;overflow:visible;line-height:1.25;overflow-wrap:anywhere}
.editable .element{outline:1px dashed #b5c5ce;cursor:move;touch-action:none}
.editable .element.selected{outline:2px solid #25786f}
.element:focus-visible,.guide:focus-visible{outline:2px solid var(--focus)}
.resize{position:absolute;bottom:-1px;right:-1px;width:10px;height:10px;background:#25786f;cursor:nwse-resize}
.guide{position:absolute;z-index:2;touch-action:none;background:transparent;color:#117b96}
.guide.x{width:7px;height:100%;top:0;transform:translateX(-3px);cursor:ew-resize;border-left:0}
.guide.y{height:7px;width:100%;left:0;transform:translateY(-3px);cursor:ns-resize}
.guide::after{content:"";position:absolute;background:currentColor;pointer-events:none}
.guide.x::after{left:3px;width:1px;height:100%}
.guide.y::after{top:3px;height:1px;width:100%}
.guide.selected{color:#b74528}
.box-content{width:100%;height:100%;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere}
.separator-stroke{position:absolute;top:50%;left:0;width:100%;transform:translateY(-50%);pointer-events:none}
.artwork{display:block;object-fit:contain}
.artwork-placeholder{display:grid;place-items:center;color:#435966;background:#f0f4f6}
.invoice-table{table-layout:fixed}
.invoice-table td,.invoice-table th{padding:3px 4px;border:1px solid var(--border);vertical-align:top;overflow-wrap:anywhere}
.invoice-table th{background:var(--header-fill);color:var(--header-text)}
.invoice-table td{background:var(--body-fill);color:var(--body-text)}
.invoice-table.hide-item-dividers .item-row + .item-row td{border-top-style:hidden}
.invoice-table .numeric{text-align:right}
.invoice-table .invoice-total{background:#f0f1f3;font-weight:700}
.invoice-table .invoice-footer-gap{height:8px;padding:0;border-left:0;border-right:0;background:transparent}
.element-inspector{display:grid;gap:12px;min-width:0;scroll-margin-top:12px}
.element-inspector>button{justify-self:start}
.element-inspector>h3,.element-inspector>p{margin:0}
.table-colors{grid-template-columns:repeat(auto-fit,minmax(105px,1fr));margin:0}
.column-controls{overflow-x:auto;padding:2px 3px 8px}
.column-editor{display:grid;grid-template-columns:minmax(100px,1.2fr) minmax(102px,1fr) minmax(98px,1fr) minmax(68px,.65fr) auto;align-items:end;gap:8px;min-width:490px;padding:8px 0;border-top:1px solid var(--border)}
.column-editor label{font-size:.79rem}
.column-editor input,.column-editor select{font-size:.88rem}
.column-editor .tools{gap:4px;flex-wrap:nowrap}
.column-editor .tools button{width:30px;padding:4px 0}
.template-split>.template-viewer{width:min(100%,var(--paper-viewport-width));justify-self:end}
.template-divider{display:none}
@media(max-width:1000px){.split{grid-template-columns:1fr}}
@media(min-width:1001px){
  .shell:has(.template-split){height:100vh;height:100dvh;grid-template-rows:minmax(0,1fr);overflow:hidden}
  .shell:has(.template-split)>aside{min-height:0;overflow:auto}
  main:has(.template-split){display:flex;flex-direction:column;min-height:0}
  main:has(.template-split)>header{flex:none}
  #workspace:has(.template-split){display:flex;flex-direction:column;flex:1;min-height:0}
  .template-split{flex:1;min-height:0;grid-template-rows:minmax(0,1fr)}
  .resizable-split{align-items:start;gap:0;grid-template-columns:minmax(280px,1fr) 18px clamp(240px,var(--preview-width,min(53%,var(--paper-viewport-width,100%))),calc(100% - 298px))}
  .template-inspector{max-height:100%;min-height:0;margin:0;overflow:auto;overscroll-behavior:contain}
  .template-divider{display:grid;place-items:center;align-self:stretch;cursor:col-resize;touch-action:none;user-select:none}
  .template-divider::before{content:"";width:3px;height:36px;border-radius:4px;background:var(--border)}
  .template-divider:hover::before,.template-divider:focus-visible::before{background:var(--accent)}
  .template-divider:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
  .template-split>.template-viewer{display:flex;flex-direction:column;width:100%;max-height:100%}
  .template-preview{min-height:0;max-height:none}
}
@media(max-width:720px){.shell{display:block}aside{padding:12px}.brand{padding:0 0 8px}nav{display:flex;gap:3px;overflow:auto}nav button{width:auto;white-space:nowrap}}

.appearance-colors{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))}
.appearance-colors input[type=color]{height:36px;padding:3px}

.preview-number{margin:0 0 8px;font-size:.85rem}
.invoice-items{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}
.invoice-item{display:flex;align-items:end;flex-wrap:wrap;gap:8px;margin:0}
.invoice-item:last-child{margin-bottom:14px}
.invoice-item label{flex:1 1 90px;min-width:0}
.invoice-item label.wide{flex:2 1 170px}
.invoice-item textarea{min-height:36px}
.issue-draft{margin-inline-start:auto;background:#187347;border-color:#187347;color:#fff}
.issue-draft:hover{background:#125c38;border-color:#125c38;color:#fff}
.issue-draft:disabled,.issue-draft:disabled:hover{background:#e1e5eb;border-color:#d6dce4;color:#556274;cursor:not-allowed}
.delete-draft{display:inline-grid;place-items:center;color:#3c4651;min-width:2.5em;min-height:2.4em;padding:.35rem;box-shadow:none}
.delete-draft:hover{background:#eef0f2;color:#222932}
.delete-draft:disabled,.delete-draft:disabled:hover{color:#d0d5dc;background:#f8f9fa;border-color:#e9ecf0;cursor:not-allowed}
.trash-icon{position:relative;display:block;width:11px;height:11px;margin-top:4px;border:1.5px solid currentColor;border-top:0;border-radius:0 0 2px 2px}
.trash-icon::before,.trash-icon::after{content:"";position:absolute;left:50%;transform:translateX(-50%)}
.trash-icon::before{width:15px;top:-2px;border-top:1.5px solid currentColor}
.trash-icon::after{width:6px;height:3px;top:-5px;border:1.5px solid currentColor;border-bottom:0;border-radius:2px 2px 0 0}
.invoice-actions{justify-content:flex-end}
.draft-watermark{position:absolute;z-index:3;top:50%;left:50%;transform:translate(-50%,-50%) rotate(-32deg);font-family:Arial,Helvetica,sans-serif;font-weight:700;color:#526174;opacity:.18;pointer-events:none}
.agent-setup li{margin-bottom:.4em}
.agent-setup pre{background:var(--background);padding:12px;white-space:pre-wrap;overflow-wrap:anywhere}
.issue-status{margin:8px 0 0;font-size:.85rem;color:var(--text)}
.proposal-scopes .panel{margin:0 0 10px}
.proposal-source pre{white-space:pre-wrap;overflow-wrap:anywhere;font:inherit}
.proposal-source summary{cursor:pointer;font-weight:600}
.template-checks{display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:6px 10px}

[hidden]{display:none!important}
.portal-header{justify-content:space-between;align-items:center}
.portal-header .brand{padding:0}
.portal-main{max-width:1100px;margin:0 auto;padding:24px clamp(14px,4vw,36px)}
.portal-login{max-width:420px;margin:32px auto}
.portal-login label{margin-bottom:14px}
.portal-nav{display:flex;gap:6px;flex-wrap:wrap;margin:0 0 20px}
.portal-nav button{width:auto;border:1px solid var(--border);padding:.45rem .85rem}
.portal-error{color:#962932}
