:root {
  --ink:#202429; --gold:#c39d56; --bg:#f3f4f6; --line:#dfe2e5;
  --muted:#66707a; --green:#166534; --red:#991b1b; --amber:#92400e;
}
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--ink); font-family:Inter,Segoe UI,Arial,sans-serif; font-size:16px; }
.sidebar { position:fixed; inset:0 auto 0 0; width:250px; background:var(--ink); color:#fff; padding:22px 16px; display:flex; flex-direction:column; z-index:10; overflow-y:auto; }
.brand { display:flex; gap:12px; align-items:center; color:inherit; text-decoration:none; font-size:20px; font-weight:750; }
.brand small { display:block; font-size:10px; letter-spacing:2px; color:#d9bd88; margin-top:3px; }
.brand-mark { display:grid; place-items:center; width:42px; height:42px; border:1px solid var(--gold); border-radius:50%; color:var(--gold); font-family:Georgia,serif; }
.sidebar nav { display:grid; gap:3px; margin-top:28px; }
.sidebar nav a,.logout button { padding:10px 13px; border-radius:9px; color:#f8fafc; text-decoration:none; background:none; border:0; font:inherit; text-align:left; cursor:pointer; }
.nav-label { color:#d9bd88; font-size:10px; letter-spacing:1.5px; text-transform:uppercase; padding:14px 13px 4px; }
.sidebar nav a:hover,.sidebar nav a:focus,.logout button:hover { background:#343a40; color:#fff; }
.logout { margin-top:auto; border-top:1px solid #3d4349; padding-top:12px; }
main { margin-left:250px; min-height:100vh; }
.topbar { height:70px; background:#fff; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:flex-end; padding:0 34px; position:sticky; top:0; z-index:5; }
.topbar>div { text-align:right; }
.topbar small { display:block; color:var(--muted); margin-top:2px; }
.tenant-tools { display:flex; align-items:center; justify-content:flex-end; gap:14px; }
.tenant-tools form { margin:0; }
.tenant-tools select { min-height:36px; width:auto; max-width:260px; padding:6px 32px 6px 10px; font-size:14px; }
.menu { display:none; }
.page { padding:34px; max-width:1500px; margin:auto; }
.page-head { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:24px; }
.page-head h1 { font-size:34px; margin:4px 0 7px; }
.page-head p { margin:0; color:var(--muted); }
.eyebrow { font-size:11px; letter-spacing:2px; color:#9a7435; font-weight:750; }
.metrics { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:16px; margin:0 0 22px; }
.metrics.one { grid-template-columns:minmax(280px,420px); }
.metrics article,.panel { background:#fff; border:1px solid var(--line); border-radius:14px; box-shadow:0 4px 16px rgba(20,30,40,.035); }
.metrics article { padding:20px; }
.metrics span { display:block; color:var(--muted); margin-bottom:9px; }
.metrics strong { font-size:24px; }
.panel { padding:22px; margin-bottom:20px; }
.panel h2 { margin:0 0 16px; font-size:20px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:15px; }
.panel-head h2 { margin:0; }
.panel a,td a { color:#765925; font-weight:650; text-decoration:none; }
.grid-2 { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.split-row { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:13px 0; border-bottom:1px solid #eceef0; }
.split-row:last-child { border:0; }
.split-row small,td small { display:block; color:var(--muted); margin-top:3px; }
.table-wrap { overflow:auto; }
table { border-collapse:collapse; width:100%; min-width:700px; }
th,td { text-align:left; padding:13px 12px; border-bottom:1px solid #e7e9eb; vertical-align:middle; }
th { font-size:12px; letter-spacing:.6px; color:var(--muted); text-transform:uppercase; }
td:last-child { text-align:right; }
.button { display:inline-flex; align-items:center; justify-content:center; min-height:43px; padding:10px 16px; border:1px solid #cdd1d5; border-radius:9px; background:#fff; color:var(--ink); font-weight:700; text-decoration:none; cursor:pointer; }
.button.primary { background:var(--gold); border-color:var(--gold); color:#151515; }
.button.danger { border-color:#fecaca; color:var(--red); background:#fff7f7; }
.button.wide { width:100%; }
.actions { display:flex; gap:9px; align-items:center; flex-wrap:wrap; }
.actions form { margin:0; }
.stack-actions { display:grid; gap:9px; margin-top:18px; }
.link-button { border:0; background:none; color:#765925; font:inherit; font-weight:650; padding:0; cursor:pointer; }
.status { display:inline-flex; padding:5px 9px; border-radius:999px; background:#eceff1; font-size:13px; }
.status.active,.status.paid,.status.accepted { background:#dcfce7; color:var(--green); }
.status.past_due,.status.overdue,.status.rejected,.status.cancelled { background:#fee2e2; color:var(--red); }
.status.pending,.status.sent,.status.trial { background:#fef3c7; color:var(--amber); }
.status.ready { background:#dcfce7; color:var(--green); }
.status.duplicate { background:#fef3c7; color:var(--amber); }
.status.error { background:#fee2e2; color:var(--red); }
.notice { padding:13px 16px; border-radius:9px; background:#eef2ff; margin-bottom:16px; }
.notice.success { background:#dcfce7; color:var(--green); }
.notice.error { background:#fee2e2; color:var(--red); }
.search { display:flex; gap:9px; margin-bottom:16px; }
.search input { max-width:420px; }
.filter-panel { display:grid; grid-template-columns:repeat(4,minmax(150px,1fr)) auto; gap:12px; align-items:end; }
.filter-panel label { font-size:13px; font-weight:700; }
.filter-panel input,.filter-panel select { display:block; margin-top:6px; }
.field-control,input,select,textarea { width:100%; min-height:43px; border:1px solid #cfd3d7; border-radius:8px; padding:9px 11px; background:#fff; font:inherit; }
input[type=checkbox] { width:auto; min-height:auto; }
.form-panel { max-width:920px; }
.form-panel p { display:grid; grid-template-columns:210px 1fr; gap:15px; align-items:start; }
.form-panel label { font-weight:650; padding-top:10px; }
.helptext { font-size:12px; color:var(--muted); }
.errorlist { color:var(--red); }
.form-actions,.action-row { display:flex; gap:10px; margin:18px 0; }
.item-table input { min-width:85px; }
.item-table td:nth-child(2) input { min-width:280px; }
.totals { margin-left:auto; max-width:390px; margin-top:20px; }
.totals span { display:flex; justify-content:space-between; padding:8px 0; }
.totals .grand { border-top:2px solid var(--ink); font-size:20px; }
.empty,.hint { color:var(--muted); }
dl { display:grid; grid-template-columns:130px 1fr; gap:10px; margin:0; }
dt { color:var(--muted); }
dd { margin:0; font-weight:600; }
.login-body { min-height:100vh; display:grid; place-items:center; background:linear-gradient(135deg,#171a1d,#2d3237); }
.login-card { width:min(430px,calc(100% - 30px)); background:#fff; border-radius:18px; padding:34px; box-shadow:0 25px 80px rgba(0,0,0,.35); }
.login-brand { color:var(--ink); margin-bottom:30px; }
.login-card h1 { font-size:32px; margin-bottom:8px; }
.login-card p { color:var(--muted); }
.login-card form p { margin:15px 0; }
.login-card label { display:block; font-weight:650; margin-bottom:6px; }
.compact-panel { padding:14px 16px; }
.compact-table th,.compact-table td { padding:8px 9px; font-size:13px; white-space:nowrap; }
.compact-table td:nth-child(2) { white-space:normal; min-width:150px; }
.compact-search { margin:0 0 10px; }
.compact-filter { grid-template-columns:minmax(240px,2fr) minmax(180px,1fr) auto; margin-bottom:12px; }
.status-tabs,.period-tabs { display:flex; gap:6px; flex-wrap:wrap; align-items:center; margin:0 0 14px; }
.status-tabs a,.period-tabs button { padding:8px 11px; border:1px solid var(--line); border-radius:8px; background:#fff; color:var(--ink); text-decoration:none; font:inherit; cursor:pointer; }
.status-tabs a.active,.period-tabs button.active { background:var(--ink); color:#fff; border-color:var(--ink); }
.status-tabs strong { margin-left:5px; font-size:12px; }
.status.ready { background:#dbeafe; color:#1d4ed8; }
.status.partial { background:#ffedd5; color:#9a3412; }
.status.queued { background:#fef3c7; color:var(--amber); }
.status.failed { background:#fee2e2; color:var(--red); }
.status.delivered { background:#dcfce7; color:var(--green); }
.text-danger { color:var(--red); font-weight:700; }
.detail-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(300px,360px); gap:20px; align-items:start; }
.comments textarea { margin-bottom:9px; }
.comment-list article { padding:12px 0; border-top:1px solid var(--line); }
.comment-list article strong,.comment-list article small { display:block; }
.comment-list article p { margin:7px 0 0; }
.timeline { display:grid; gap:8px; border-top:1px solid var(--line); padding-top:14px; margin-top:14px; }
.timeline small { display:block; color:var(--muted); margin-top:3px; }
.qr-small { display:block; width:140px; max-width:100%; margin:0 auto 12px; }
.card-grid,.layout-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr)); gap:16px; }
.mini-card,.layout-card { border:1px solid var(--line); border-radius:12px; padding:16px; display:flex; gap:16px; align-items:center; }
.mini-card h2,.layout-card h2 { margin:0 0 5px; font-size:18px; }
.mini-card p,.layout-card p { margin:4px 0 10px; }
.qr-card { width:110px; height:110px; }
.layout-preview { width:145px; height:190px; flex:none; border:1px solid #ccd2d7; background:#fff; padding:14px; box-shadow:0 5px 15px rgba(0,0,0,.07); }
.layout-preview strong { color:var(--layout-primary); display:block; font-size:13px; }
.layout-preview span { display:block; background:var(--layout-primary); height:13px; margin:38px 0 9px; }
.layout-preview i { display:block; height:5px; background:#dfe4e7; margin-bottom:5px; }
.layout-preview b { display:block; height:24px; background:var(--layout-accent); opacity:.45; margin-top:26px; }
.integration-status { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.editor-toolbar { display:flex; gap:9px; flex-wrap:wrap; margin-bottom:14px; position:sticky; top:80px; z-index:4; background:var(--bg); padding:8px 0; }
.document-editor { display:grid; grid-template-columns:minmax(500px,1fr) 390px; gap:20px; align-items:start; }
.paper-preview { width:min(100%,760px); min-height:980px; background:#fff; border:1px solid #d5d9dc; box-shadow:0 8px 30px rgba(25,35,45,.08); padding:62px 70px; margin:0 auto; position:relative; }
.paper-brand { font-size:28px; font-weight:850; letter-spacing:2px; color:#17324d; text-align:right; }
.paper-address { margin-top:95px; width:48%; min-height:75px; white-space:pre-line; }
.paper-title { margin-top:55px; font-size:18px; font-weight:700; }
.paper-meta { display:flex; gap:28px; color:var(--muted); font-size:13px; margin:12px 0 25px; }
.paper-items { border-top:25px solid #17324d; }
.paper-row { display:grid; grid-template-columns:55px minmax(0,1fr) 75px 95px; gap:8px; border-bottom:1px solid #e2e5e8; padding:9px 7px; font-size:12px; }
.paper-row-head { color:#fff; margin-top:-25px; border:0; height:25px; align-items:center; font-weight:700; padding-top:0; padding-bottom:0; }
.paper-empty { text-align:center; color:#85909a; margin:150px 0; text-transform:uppercase; font-size:13px; line-height:1.5; }
.paper-footer { position:absolute; left:70px; right:70px; bottom:35px; border-top:1px solid #dfe3e6; padding-top:8px; color:#7b858d; font-size:9px; }
.editor-sections { display:grid; gap:10px; position:sticky; top:144px; max-height:calc(100vh - 165px); overflow:auto; padding-right:3px; }
.editor-sections details { background:#fff; border:1px solid var(--line); border-radius:9px; box-shadow:0 4px 13px rgba(20,30,40,.05); }
.editor-sections summary { cursor:pointer; padding:18px; font-size:13px; letter-spacing:.4px; text-transform:uppercase; color:#66717a; font-weight:750; }
.editor-sections details[open] summary { border-bottom:1px solid var(--line); color:var(--ink); }
.editor-fields { padding:16px; display:grid; gap:7px; }
.editor-fields label { font-size:12px; font-weight:700; color:#69737b; margin-top:5px; }
.field-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.field-grid.three { grid-template-columns:70px minmax(0,1fr) 65px; }
.field-grid.three .grow { min-width:0; }
.line-item { border:1px solid var(--line); border-radius:8px; padding:10px; margin-bottom:8px; }
.line-item input,.line-item select { min-width:0; }
.sticky-save { position:sticky; bottom:0; padding:12px; background:rgba(243,244,246,.95); border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:9px; z-index:6; }
.pdf-preview-panel { padding:0; overflow:hidden; height:calc(100vh - 190px); min-height:650px; }
.pdf-preview-panel object { width:100%; height:100%; border:0; }
.period-tabs input { width:auto; min-height:39px; }
.expense-grid { grid-template-columns:minmax(0,2fr) minmax(280px,1fr); }
.receipt-editor { display:grid; grid-template-columns:minmax(440px,1.2fr) minmax(400px,1fr); gap:20px; align-items:start; }
.receipt-preview { min-height:720px; display:grid; place-items:center; padding:12px; }
.receipt-preview img { max-width:100%; max-height:820px; object-fit:contain; }
.receipt-preview object { width:100%; height:800px; border:0; }
.expense-fields { max-height:820px; overflow:auto; }
.upload-drop { max-width:850px; border:2px dashed #c7cdd2; padding:38px; }
.privacy-note { margin-top:20px; background:#f5f7f8; border-radius:9px; padding:14px; color:var(--muted); }
@media(max-width:1000px) {
  .grid-2 { grid-template-columns:1fr; }
  .filter-panel { grid-template-columns:repeat(2,minmax(150px,1fr)); }
  .document-editor { grid-template-columns:1fr; }
  .editor-sections { position:static; max-height:none; order:-1; }
  .paper-preview { min-height:850px; }
  .detail-layout,.receipt-editor,.expense-grid { grid-template-columns:1fr; }
}
@media(max-width:760px) {
  .sidebar { transform:translateX(-100%); transition:.2s; width:280px; }
  .menu-open .sidebar { transform:none; }
  main { margin-left:0; }
  .topbar { justify-content:space-between; padding:0 18px; }
  .menu { display:block; border:0; background:none; font-size:28px; }
  .page { padding:22px 15px; }
  .page-head { align-items:flex-start; flex-direction:column; }
  .page-head h1 { font-size:29px; }
  .metrics,.filter-panel { grid-template-columns:1fr; }
  .form-panel p { display:block; }
  .form-panel label { display:block; }
  .actions { width:100%; }
  .actions .button { flex:1; }
  .panel { padding:16px; }
  .document-head p { max-width:330px; }
  .editor-toolbar { top:70px; overflow-x:auto; flex-wrap:nowrap; }
  .editor-toolbar .button { white-space:nowrap; }
  .paper-preview { width:100%; min-height:620px; padding:35px 28px; }
  .paper-address { margin-top:55px; width:70%; }
  .paper-title { margin-top:32px; font-size:18px; }
  .paper-footer { left:28px; right:28px; }
  .field-grid { grid-template-columns:1fr; }
  .field-grid.three { grid-template-columns:62px minmax(0,1fr) 55px; }
  .status-tabs { flex-wrap:nowrap; overflow-x:auto; padding-bottom:4px; }
  .status-tabs a { white-space:nowrap; }
  .card-grid,.layout-grid { grid-template-columns:1fr; }
  .mini-card,.layout-card { align-items:flex-start; }
  .receipt-preview { min-height:420px; }
  .receipt-preview object { height:560px; }
}

.invoice-number {font-size:.9rem;font-weight:700;white-space:nowrap}.customer-number {display:block;color:#64748b;font-size:.72rem}.delete-row {margin:1rem 0 2rem}

.logo-upload {display:block;margin-top:.7rem;font-weight:650}.logo-upload input {display:block;margin-top:.3rem}.due-date {margin-top:.6rem}.due-date small {display:block;color:#64748b}
