:root {
  --ivory:#f6f2e9;
  --paper:#fffdf8;
  --graphite:#252522;
  --muted:#716e66;
  --gold:#a88445;
  --gold-light:#eadcc0;
  --line:#ded7c9;
  --green:#496b5a;
  --red:#935a4f;
  --shadow:0 18px 50px rgba(44,39,29,.10);
}

* { box-sizing:border-box; }
[hidden] { display:none !important; }
html { color-scheme:light; }
body { margin:0; background:var(--ivory); color:var(--graphite); font-family:Arial,Helvetica,sans-serif; font-size:16px; }
a { color:inherit; text-decoration-color:var(--gold); text-underline-offset:3px; }
button,input,select,textarea { font:inherit; }
button,a { -webkit-tap-highlight-color:transparent; }

.brand-lockup { display:flex; align-items:center; gap:14px; color:inherit; text-decoration:none; }
.brand-lockup img { width:58px; height:58px; object-fit:contain; }
.brand-lockup div { display:flex; flex-direction:column; gap:4px; }
.brand-lockup span,.editor-brand small { color:var(--gold); font-weight:700; font-size:.67rem; letter-spacing:.19em; }
.brand-lockup strong { font:500 1.15rem Georgia,serif; }
.brand-lockup.compact img { width:42px; height:42px; }
.brand-lockup.compact strong { font-size:1rem; }
.kicker { color:var(--gold); font-size:.7rem; letter-spacing:.19em; font-weight:700; margin:30px 0 9px; }

.site-header { min-height:78px; padding:14px clamp(20px,4vw,64px); background:rgba(255,253,248,.96); border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:25px; position:sticky; top:0; z-index:20; }
.site-header nav { display:flex; align-items:center; gap:22px; font-size:.82rem; }
.site-header nav form { margin:0; }
.site-header nav a,.link-button { border:0; background:transparent; color:var(--muted); text-decoration:none; cursor:pointer; padding:8px 0; }
.site-header nav a:hover,.link-button:hover { color:var(--graphite); }

.flash-stack { width:min(1120px,calc(100% - 40px)); margin:18px auto -4px; position:relative; z-index:10; }
.flash { border:1px solid var(--line); padding:12px 14px; background:white; color:var(--muted); font-size:.84rem; margin-bottom:8px; }
.flash.success { border-color:#a7c0b3; background:#f0f6f2; color:#365849; }
.flash.error { border-color:#d7b5af; background:#faf1ef; color:#7d433a; }
.flash.warning { border-color:#dfc99f; background:#fcf7ed; color:#735c30; }

.auth-page,.auth-shell { min-height:100vh; }
.auth-shell,.install-shell { min-height:100vh; display:grid; place-items:center; padding:36px 20px; background:radial-gradient(circle at 10% 0%,#fffdf8 0,transparent 35%),var(--ivory); }
.auth-card { width:min(100%,520px); background:var(--paper); border:1px solid var(--line); padding:clamp(28px,5vw,50px); box-shadow:var(--shadow); }
.install-shell { align-items:start; }
.install-card { width:min(100%,820px); }
.auth-card h1,.page-heading h1,.privacy-copy h1 { font:500 clamp(2rem,5vw,3.15rem)/1.08 Georgia,serif; margin:0 0 16px; }
.auth-card>p:not(.kicker):not(.auth-foot),.page-heading p,.info-card p,.danger-zone p { color:var(--muted); line-height:1.65; }
.auth-foot { text-align:center; color:var(--muted); font-size:.82rem; margin:20px 0 0; }

.stack-form { display:grid; gap:15px; margin-top:24px; }
fieldset { border:1px solid var(--line); padding:20px; margin:4px 0 10px; }
legend { font:500 1rem Georgia,serif; padding:0 8px; }
label { display:flex; flex-direction:column; gap:7px; color:var(--muted); font-size:.8rem; margin-bottom:16px; }
.stack-form label { margin:0; }
label small { line-height:1.45; }
input,select,textarea { width:100%; border:1px solid var(--line); background:white; color:var(--graphite); border-radius:2px; padding:11px 12px; outline:none; }
input:focus,select:focus,textarea:focus { border-color:var(--gold); box-shadow:0 0 0 2px rgba(168,132,69,.14); }
textarea { min-height:76px; resize:vertical; }
.form-columns,.two { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.check-label { display:grid !important; grid-template-columns:20px 1fr; align-items:start; gap:10px; line-height:1.5; }
.check-label input { width:18px; height:18px; margin:1px 0 0; }
.button { display:inline-flex; align-items:center; justify-content:center; border-radius:2px; padding:11px 15px; border:1px solid transparent; font-weight:700; font-size:.82rem; cursor:pointer; text-decoration:none; }
.primary-button,.primary,.report { background:var(--graphite); color:white; border-color:var(--graphite); }
.quiet-button { background:white; color:var(--graphite); border-color:var(--line); }
.danger-button { background:white; color:var(--red); border-color:#d9b9b3; }
.button:hover,.primary:hover,.report:hover { filter:brightness(.95); }

.page-shell { width:min(1240px,calc(100% - 40px)); margin:0 auto; padding:60px 0 90px; }
.narrow-shell { width:min(820px,calc(100% - 40px)); }
.page-heading { display:flex; justify-content:space-between; align-items:end; gap:40px; margin-bottom:38px; }
.page-heading h1 { margin-bottom:8px; }
.page-heading .kicker { margin-top:0; }
.page-heading p { margin:0; max-width:680px; }
.new-case-form { display:grid; grid-template-columns:minmax(180px,270px) auto; gap:8px; flex-shrink:0; }
.case-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
.case-card,.info-card,.table-card,.danger-zone,.empty-state,.import-box { background:var(--paper); border:1px solid var(--line); padding:24px; }
.case-card { min-height:220px; display:flex; flex-direction:column; }
.case-date { color:var(--gold); letter-spacing:.1em; font-size:.63rem; font-weight:700; }
.case-card h2,.info-card h2,.danger-zone h2,.table-card h2,.empty-state h2 { font:500 1.3rem Georgia,serif; margin:16px 0; overflow-wrap:anywhere; }
.case-actions { margin-top:auto; display:flex; flex-wrap:wrap; gap:7px; }
.case-actions form { margin:0; }
.empty-state { text-align:center; padding:70px 25px; }
.empty-state img { object-fit:contain; opacity:.72; }
.empty-state p { color:var(--muted); line-height:1.6; }
.import-box { margin-top:24px; }
.import-box summary { cursor:pointer; font-weight:700; }
.import-box form { margin-top:20px; max-width:460px; }
.account-grid,.admin-grid { display:grid; grid-template-columns:1fr 1fr; gap:18px; margin-bottom:18px; }
.danger-zone { border-color:#d9b9b3; margin:24px 0; }
.danger-zone form { max-width:430px; margin-top:20px; }
.badge { display:inline-block; border-radius:20px; padding:4px 9px; font-size:.7rem; font-weight:700; background:#eee; color:var(--muted); }
.badge.active,.badge.processed { background:#e3efe8; color:#365849; }
.badge.revoked,.badge.error { background:#f3e3e0; color:#7d433a; }
.badge.ignored { background:#f1eadc; color:#735c30; }
.metrics-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:1px; background:var(--line); border:1px solid var(--line); margin-bottom:20px; }
.metrics-grid article { background:var(--paper); padding:23px; }
.metrics-grid small { display:block; color:var(--gold); letter-spacing:.08em; font-size:.62rem; font-weight:700; }
.metrics-grid strong { display:block; font:500 2rem Georgia,serif; margin-top:9px; }
.table-card { margin-top:18px; }
.table-scroll { overflow:auto; }
.table-card table { width:100%; border-collapse:collapse; font-size:.78rem; }
.table-card th,.table-card td { text-align:left; padding:11px 8px; border-bottom:1px solid var(--line); }
.table-card th { color:var(--muted); font-size:.65rem; letter-spacing:.06em; }
.privacy-copy { background:var(--paper); margin-top:40px; margin-bottom:40px; padding:clamp(28px,5vw,64px); border:1px solid var(--line); }
.privacy-copy h2 { font:500 1.25rem Georgia,serif; margin:30px 0 9px; }
.privacy-copy p { color:var(--muted); line-height:1.7; }

.editor-topbar { min-height:92px; padding:14px 2.5vw; display:grid; grid-template-columns:minmax(210px,1fr) minmax(240px,520px) minmax(290px,1fr); align-items:center; gap:22px; border-bottom:1px solid var(--line); background:rgba(255,253,248,.96); position:sticky; top:0; z-index:30; }
.editor-brand { display:flex; align-items:center; gap:11px; text-decoration:none; }
.editor-brand img { width:44px; height:44px; object-fit:contain; }
.editor-brand span { display:flex; flex-direction:column; gap:3px; }
.editor-brand strong { font:500 1.08rem Georgia,serif; }
.case-title-wrap { display:grid; grid-template-columns:auto minmax(0,1fr); gap:10px; align-items:center; }
.case-title-wrap label { margin:0; white-space:nowrap; }
.case-title-wrap input { padding:9px 10px; }
.editor-controls { display:flex; justify-content:flex-end; align-items:center; gap:8px; }
.save-status { color:var(--muted); font-size:.73rem; min-width:105px; text-align:right; }
.save-status.saved { color:var(--green); }
.save-status.error { color:var(--red); }

.workspace { display:grid; grid-template-columns:minmax(250px,.72fr) minmax(480px,1.55fr) minmax(290px,.83fr); gap:1px; background:var(--line); min-height:calc(100vh - 92px); }
.panel { background:var(--paper); padding:30px; }
.section-title { display:flex; gap:14px; align-items:flex-start; margin-bottom:26px; }
.section-title>span { color:var(--gold); font-family:Georgia,serif; font-size:.8rem; margin-top:4px; }
.section-title h2 { font:500 1.45rem Georgia,serif; margin:0; }
.section-title p { color:var(--muted); font-size:.82rem; line-height:1.5; margin:5px 0 0; }
.row-title { align-items:center; }
.row-title .primary { margin-left:auto; }
.setup,.result { position:sticky; top:92px; align-self:start; min-height:calc(100vh - 92px); }
.legal-note,.notice { font-size:.76rem; line-height:1.55; padding:14px; border-left:2px solid var(--gold); background:#f3ede1; color:var(--muted); }
.primary,.classification button,.report { border:0; padding:11px 15px; border-radius:2px; font-weight:700; cursor:pointer; }
.item-tabs { display:flex; gap:7px; overflow:auto; padding-bottom:13px; margin-bottom:20px; border-bottom:1px solid var(--line); }
.item-tabs button { white-space:nowrap; border:1px solid var(--line); background:white; padding:9px 12px; color:var(--muted); cursor:pointer; }
.item-tabs button.active { border-color:var(--gold); color:var(--graphite); background:#f8f1e5; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 16px; }
.wide { grid-column:1/-1; }
.classification { display:flex; justify-content:space-between; gap:18px; align-items:center; border:1px solid #d9c69f; background:#fbf5e9; padding:15px; margin-bottom:16px; }
.classification small { display:block; text-transform:uppercase; letter-spacing:.08em; color:var(--gold); font-weight:700; }
.classification strong { display:block; font:500 1.3rem Georgia,serif; margin-top:5px; }
.classification p { margin:4px 0 0; font-size:.8rem; line-height:1.45; color:var(--muted); }
.classification button { background:transparent; border:1px solid var(--gold); color:var(--graphite); white-space:nowrap; }
.remove { border:0; background:transparent; color:var(--red); text-align:left; padding:0; cursor:pointer; font-size:.8rem; }
.debt-explainer { margin:-5px 0 16px; padding:11px 13px; background:#f3ede1; border-left:2px solid var(--gold); color:var(--muted); font-size:.76rem; line-height:1.5; }
.asset-mode { display:grid; grid-template-columns:1fr 1fr; border:1px solid var(--line); margin-bottom:20px; }
.asset-mode button { border:0; background:white; padding:13px; color:var(--muted); font-weight:700; cursor:pointer; }
.asset-mode button+button { border-left:1px solid var(--line); }
.asset-mode button.active { background:var(--graphite); color:white; }
.asset-mode span { display:inline-grid; place-items:center; min-width:20px; height:20px; margin-left:5px; border-radius:20px; background:rgba(168,132,69,.15); }
.metric { border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:18px 0; }
.metric small,.metric span { display:block; color:var(--muted); font-size:.75rem; }
.metric strong { display:block; font:500 2rem Georgia,serif; margin:6px 0; }
.shares { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:20px 0; }
.shares div { background:#f4efe5; padding:13px; min-width:0; }
.shares span,.shares small { display:block; color:var(--muted); font-size:.7rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.shares b { display:block; font:500 1rem Georgia,serif; margin:7px 0; }
.balance { background:var(--graphite); color:white; padding:19px; margin:18px 0; }
.balance.balanced { background:var(--green); }
.balance small { opacity:.75; }
.balance strong { display:block; font:500 1.7rem Georgia,serif; margin-top:5px; }
.balance p { font-size:.76rem; line-height:1.5; margin:7px 0 0; opacity:.8; }
.result h3 { font:500 1.05rem Georgia,serif; margin-top:24px; }
.alerts { padding-left:18px; color:var(--muted); font-size:.78rem; line-height:1.55; }
.alerts li { margin-bottom:8px; }
.report { width:100%; margin-top:13px; }
.signature { text-align:center; color:var(--gold); font:italic .85rem Georgia,serif; margin-top:19px; }
.movables-intro { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin:25px 0; }
.movables-intro h3 { font:500 1.25rem Georgia,serif; margin:0 0 6px; }
.movables-intro p { max-width:620px; color:var(--muted); font-size:.8rem; line-height:1.5; margin:0; }
.bulk-add { display:grid; grid-template-columns:minmax(260px,1fr) auto; gap:8px 12px; align-items:end; background:#f4efe5; padding:16px; margin-bottom:18px; }
.bulk-add label { margin:0; }
.bulk-add textarea { min-height:84px; }
.bulk-add button { height:42px; border:1px solid var(--gold); background:white; font-weight:700; padding:0 18px; cursor:pointer; }
.bulk-add small { grid-column:1/-1; color:var(--muted); }
.empty-movables { text-align:center; padding:55px 20px; border:1px dashed var(--line); color:var(--muted); }
.empty-movables p { font-size:.8rem; }
.movable-table-wrap { overflow:auto; }
.movable-table { width:100%; min-width:850px; border-collapse:collapse; }
.movable-table th { text-align:left; padding:8px; color:var(--muted); font-size:.65rem; text-transform:uppercase; letter-spacing:.05em; border-bottom:1px solid var(--line); }
.movable-table td { padding:7px; border-bottom:1px solid var(--line); font-size:.78rem; }
.movable-table input,.movable-table select { margin:0; padding:9px 8px; font-size:.78rem; }
.movable-table td:nth-child(1) { min-width:170px; }
.movable-table td:nth-child(2) { width:65px; }
.movable-table td:nth-child(3),.movable-table td:nth-child(4) { width:115px; }
.movable-table td:nth-child(5) { min-width:130px; }
.movable-table td:nth-child(6) { min-width:155px; }
.percent-input { display:flex; align-items:center; position:relative; }
.percent-input span { position:absolute; right:8px; color:var(--muted); }
.row-remove { border:0; background:transparent; color:var(--red); font-size:1.4rem; cursor:pointer; }
.movable-table tfoot td { background:#f5efe2; font-weight:700; padding:13px 8px; }

.report-screen { min-height:100vh; background:#e9e5dc; padding:24px; }
.report-mode .editor-topbar { display:none; }
.report-actions { max-width:1000px; margin:0 auto 18px; display:flex; justify-content:space-between; gap:12px; }
.report-actions>div { display:flex; gap:9px; }
.report-actions button { border:1px solid var(--line); background:white; padding:11px 15px; cursor:pointer; font-weight:700; }
.report-actions .primary { background:var(--graphite); color:white; }
.report-paper { max-width:1000px; margin:auto; background:white; padding:62px 68px; box-shadow:0 8px 35px rgba(45,42,36,.11); }
.report-brand { display:flex; justify-content:space-between; color:var(--gold); font-size:.7rem; font-weight:700; letter-spacing:.18em; }
.report-paper h1 { font:500 2.25rem Georgia,serif; margin:20px 0 12px; }
.report-intro { color:var(--muted); line-height:1.65; max-width:760px; }
.report-paper h2 { font:500 1.2rem Georgia,serif; margin:34px 0 14px; padding-bottom:9px; border-bottom:1px solid var(--line); }
.report-parties,.report-summary { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
.report-card { border:1px solid var(--line); padding:15px; }
.report-card small,.report-card span { display:block; color:var(--muted); font-size:.72rem; }
.report-card strong { display:block; font:500 1.16rem Georgia,serif; margin:7px 0; }
.report-card.highlight { background:#f5efe2; border-color:#d8c495; }
.table-wrap { overflow:auto; }
.report-paper table { width:100%; border-collapse:collapse; font-size:.78rem; }
.report-paper th,.report-paper td { text-align:left; vertical-align:top; padding:11px 9px; border-bottom:1px solid var(--line); }
.report-paper th { font-size:.66rem; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }
.report-paper td small { display:block; color:var(--muted); font-size:.68rem; line-height:1.45; margin-top:3px; }
.report-conclusion { background:var(--graphite); color:white; padding:20px; margin-top:18px; }
.report-conclusion.equal { background:var(--green); }
.report-conclusion small { opacity:.72; letter-spacing:.08em; }
.report-conclusion strong { display:block; font:500 1.8rem Georgia,serif; margin:6px 0; }
.report-conclusion p { font-size:.77rem; line-height:1.55; margin:5px 0 0; opacity:.82; }
.report-warning { border-left:3px solid var(--gold); padding:11px 14px; background:#f8f4eb; color:var(--muted); font-size:.78rem; line-height:1.5; }
.report-foot { margin-top:35px; color:var(--muted); font-size:.7rem; line-height:1.55; }

@media (max-width:1100px) {
  .workspace { grid-template-columns:1fr 1.5fr; }
  .result { grid-column:1/-1; position:static; min-height:auto; }
  .setup { position:static; }
  .editor-topbar { grid-template-columns:1fr 1fr; }
  .case-title-wrap { grid-column:1/-1; grid-row:2; }
  .editor-controls { grid-column:2; grid-row:1; }
  .case-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width:720px) {
  .site-header { position:static; flex-direction:column; align-items:flex-start; }
  .site-header nav { width:100%; justify-content:space-between; gap:10px; }
  .page-shell { width:min(100% - 28px,1240px); padding-top:38px; }
  .page-heading { align-items:stretch; flex-direction:column; gap:22px; }
  .new-case-form,.form-columns,.two,.account-grid,.admin-grid { grid-template-columns:1fr; }
  .case-grid { grid-template-columns:1fr; }
  .metrics-grid { grid-template-columns:1fr 1fr; }
  .editor-topbar { position:static; grid-template-columns:1fr; padding:14px 20px; }
  .case-title-wrap,.editor-controls { grid-column:auto; grid-row:auto; }
  .case-title-wrap { grid-template-columns:1fr; }
  .editor-controls { justify-content:flex-start; flex-wrap:wrap; }
  .save-status { text-align:left; }
  .workspace { display:block; }
  .panel { padding:24px 20px; border-bottom:1px solid var(--line); }
  .setup { min-height:auto; }
  .form-grid { grid-template-columns:1fr; }
  .wide { grid-column:auto; }
  .classification { align-items:flex-start; flex-direction:column; }
  .classification button { width:100%; }
  .row-title { flex-wrap:wrap; }
  .row-title .primary { margin-left:0; width:100%; }
  .asset-mode { grid-template-columns:1fr; }
  .asset-mode button+button { border-left:0; border-top:1px solid var(--line); }
  .movables-intro { flex-direction:column; }
  .movables-intro .primary { width:100%; }
  .bulk-add { grid-template-columns:1fr; }
  .bulk-add button { width:100%; }
  .report-screen { padding:0; }
  .report-actions { padding:12px; position:sticky; top:0; background:#e9e5dc; z-index:3; flex-direction:column; }
  .report-actions>div { display:grid; grid-template-columns:1fr; }
  .report-paper { padding:34px 20px; box-shadow:none; }
  .report-parties,.report-summary { grid-template-columns:1fr; }
  .report-paper h1 { font-size:1.8rem; }
  .report-brand { gap:10px; }
  .report-paper table { min-width:720px; }
}

@media print {
  .editor-topbar,.report-actions,.site-header,.flash-stack { display:none !important; }
  .workspace { display:none !important; }
  .report-screen { display:block !important; padding:0; background:white; }
  .report-paper { max-width:none; padding:0; box-shadow:none; }
  .report-paper h2 { break-after:avoid; }
  .report-card,.report-warning,.report-conclusion,tr { break-inside:avoid; }
  @page { size:A4; margin:16mm; }
}
