body { background: var(--bg); }

.admin-header { background: var(--blue-200); color: var(--blue-800); }
.admin-header-inner { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.tabs-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.admin-header .wordmark { font-family: var(--font-heading); font-weight: 600; letter-spacing: -0.025em; font-size: 20px; margin-right: 14px; color: var(--text); }
.tabs { display: flex; gap: 6px; }
.tab-btn { cursor: pointer; border: 0; padding: 8px 14px; border-radius: var(--radius-control); font-size: 14px; font-weight: 600; display: flex; gap: 6px; align-items: center; background: transparent; color: var(--blue-800); font: inherit; }
.tab-btn.active { background: var(--bg); }
.tab-badge { font-size: 11px; padding: 1px 7px; border-radius: var(--radius-control); background: var(--accent); color: #fff; }
.header-actions { display: flex; gap: 14px; font-size: 13px; font-weight: 600; }
.header-actions a { color: var(--text); text-decoration: none; cursor: pointer; }

.admin-main { max-width: 1200px; margin: 0 auto; padding: 32px 24px 60px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 34px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-chip { cursor: pointer; padding: 6px 12px; border-radius: var(--radius-control); font-size: 13px; font-weight: 600; background: var(--neutral-100); color: var(--neutral-700); border: 0; font: inherit; }
.filter-chip.active { background: var(--accent); color: #fff; }

table.data { width: 100%; min-width: 720px; font-size: 14px; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--neutral-600); padding: 8px 10px; border-bottom: 1px solid var(--neutral-200); }
table.data td { padding: 10px; border-bottom: 1px solid var(--neutral-200); vertical-align: middle; }
table.data .table-wrap { overflow-x: auto; }
.link-cell { cursor: pointer; font-weight: 600; background: none; border: 0; font: inherit; color: var(--text); padding: 0; text-align: left; }
.link-cell:hover { color: var(--accent-700); }

.status-pill { display: inline-flex; padding: 3px 9px; border-radius: var(--radius-control); font-size: 11px; font-weight: 600; }
.status-draft { background: var(--neutral-200); color: var(--neutral-700); }
.status-live { background: var(--accent-100); color: var(--accent-700); }
.status-unpublished { background: var(--neutral-200); color: var(--neutral-600); }
.status-issued { background: var(--blue-200); color: var(--blue-800); }
.status-paid { background: var(--accent-100); color: var(--accent-700); }
.status-overdue { background: var(--overdue-bg); color: var(--overdue-text); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 24px; align-items: start; }
.list-col { display: flex; flex-direction: column; gap: 10px; }
.list-item-btn { text-align: left; cursor: pointer; padding: 14px 16px; border-radius: var(--radius-panel); border: 1px solid var(--neutral-200); background: var(--bg); display: flex; flex-direction: column; gap: 4px; color: var(--text); font: inherit; }
.list-item-btn.selected { border-color: var(--accent); background: var(--accent-100); }
.list-item-row-top { display: flex; justify-content: space-between; gap: 8px; }
.list-item-name { font-weight: 600; font-size: 15px; }
.list-item-meta { font-size: 12px; color: var(--neutral-600); }

.detail-panel { border: 1px solid var(--neutral-200); border-radius: var(--radius-panel); padding: 24px; display: flex; flex-direction: column; gap: 16px; background: var(--bg); box-shadow: var(--shadow-md); min-width: 0; }

.toggle-row { cursor: pointer; padding: 12px 14px; border-radius: var(--radius-panel); border: 1px solid var(--neutral-300); display: flex; flex-direction: column; gap: 2px; background: none; text-align: left; font: inherit; color: var(--text); }
.toggle-row .main { font-weight: 600; font-size: 14px; }
.toggle-row .sub { font-size: 12px; color: var(--neutral-600); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { cursor: pointer; padding: 5px 11px; border-radius: var(--radius-control); font-size: 12px; font-weight: 600; background: var(--neutral-100); color: var(--neutral-700); border: 0; font: inherit; }
.chip.on { background: var(--accent); color: #fff; }

.checklist-row { cursor: pointer; display: flex; justify-content: space-between; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--neutral-200); font-size: 14px; background: none; border-left: none; border-right: none; border-top: none; width: 100%; text-align: left; font: inherit; color: var(--text); }
.checklist-row .meta { color: var(--neutral-500); font-size: 12px; }
.checklist-row .reason { font-size: 12px; white-space: nowrap; }
.reason-all { color: var(--accent-700); }
.reason-added { color: var(--accent-700); }
.reason-tag { color: var(--blue-700); }
.reason-removed { color: var(--error); }
.reason-none { color: var(--neutral-500); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; }

.quote-box { padding: 14px 16px; border-radius: var(--radius-panel); background: var(--surface); font-size: 14px; line-height: 1.5; }
.info-box { padding: 14px 16px; border-radius: var(--radius-panel); background: var(--blue-100); color: var(--blue-800); font-size: 14px; }
.warn-box { padding: 10px 12px; border-radius: var(--radius-panel); background: var(--neutral-200); font-size: 13px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.warn-box a { cursor: pointer; color: var(--accent-700); font-weight: 600; text-decoration: none; }

.back-link { cursor: pointer; font-size: 13px; color: var(--accent-700); font-weight: 600; text-decoration: none; display: inline-block; margin-bottom: 4px; }

.editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 28px; align-items: start; }
.editor-form { display: flex; flex-direction: column; gap: 14px; }
.when-box { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--neutral-200); border-radius: var(--radius-panel); }
.seg { display: flex; gap: 6px; }
.seg-opt { cursor: pointer; padding: 5px 11px; border-radius: var(--radius-control); font-size: 12px; font-weight: 600; background: var(--neutral-100); color: var(--neutral-700); border: 0; font: inherit; }
.seg-opt.on { background: var(--accent); color: #fff; }
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-thumb { position: relative; width: 72px; height: 72px; border-radius: var(--radius-control); background: var(--surface); overflow: hidden; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove { cursor: pointer; position: absolute; top: 2px; right: 2px; border: 0; background: var(--bg); border-radius: var(--radius-control); font-size: 11px; width: 20px; height: 20px; }
.photo-add { cursor: pointer; width: 72px; height: 72px; border-radius: var(--radius-control); border: 1px dashed var(--neutral-400); background: none; font-size: 22px; color: var(--neutral-600); }

.preview-pane { position: sticky; top: 20px; background: var(--surface); border-radius: var(--radius-panel); padding: 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.preview-card { background: var(--bg); border-radius: var(--radius-panel); padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm); }
.preview-photo { aspect-ratio: 3/2; border-radius: var(--radius-panel); background: var(--surface); display: grid; place-items: center; font-size: 13px; color: var(--neutral-500); overflow: hidden; }
.preview-photo img { width: 100%; height: 100%; object-fit: cover; }

.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px 100px 104px 28px; gap: 6px; align-items: center; }
.item-head { display: grid; grid-template-columns: minmax(0, 1fr) 56px 100px 104px 28px; gap: 6px; font-size: 12px; font-weight: 600; color: var(--neutral-600); }
.remove-line { cursor: pointer; border: 0; background: none; font-size: 13px; color: var(--neutral-600); height: 32px; }
.remove-line:disabled { opacity: 0.3; cursor: default; }
.add-line { cursor: pointer; align-self: flex-start; font-size: 14px; color: var(--accent-700); font-weight: 600; background: none; border: 0; font: inherit; padding: 0; }

.invoice-doc { background: #fff; box-shadow: var(--shadow-md); padding: 40px 36px; display: flex; flex-direction: column; gap: 26px; font-size: 12px; line-height: 1.5; color: var(--text); }
.invoice-doc .doc-header { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.invoice-doc .biz-name { font-family: var(--font-heading); font-weight: 600; letter-spacing: -0.025em; font-size: 24px; line-height: 1.1; margin-bottom: 2px; }
.invoice-doc .biz-tagline { color: var(--accent-700); margin-bottom: 6px; display: block; }
.invoice-doc .doc-title { font-family: var(--font-heading); font-weight: 600; letter-spacing: -0.025em; font-size: 42px; line-height: 1; color: var(--accent); }
.invoice-doc .meta-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; padding: 16px 0; border-top: 1px solid var(--neutral-300); border-bottom: 1px solid var(--neutral-300); }
.invoice-doc .meta-label { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--neutral-600); margin-bottom: 4px; display: block; }
.invoice-doc table { width: 100%; border-collapse: collapse; font-size: 12px; }
.invoice-doc th { padding: 0 0 8px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--neutral-600); border-bottom: 1px solid var(--text); text-align: left; }
.invoice-doc th.r, .invoice-doc td.r { text-align: right; padding-left: 12px; }
.invoice-doc td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--neutral-200); vertical-align: top; }
.invoice-doc .totals-wrap { display: flex; justify-content: flex-end; }
.invoice-doc .totals { width: min(100%, 260px); display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.invoice-doc .totals .row { display: flex; justify-content: space-between; gap: 12px; }
.invoice-doc .totals .total { padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--text); font-size: 16px; font-weight: 700; }
.invoice-doc .totals .total span:last-child { color: var(--accent-700); }
.invoice-doc .footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; padding-top: 16px; border-top: 1px solid var(--neutral-300); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--accent-800); color: #fff; padding: 10px 20px; border-radius: var(--radius-control); font-size: 14px; z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.show { opacity: 1; }
