/* Forms: fields, segmented control, item cards, upload tiles, totals panel. */
.stack { display: flex; flex-direction: column; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.span-full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink-muted); }
.req { color: var(--accent-text); }
.field input, .field select, .field textarea, select.sm {
  width: 100%; min-height: 44px; padding: 10px 14px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; font-size: 15px; line-height: 1.4;
  transition: border-color var(--transition-fast);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-muted); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, select.sm:focus-visible { border-color: var(--ink); box-shadow: var(--focus-ring); border-radius: 12px; }
.field input:disabled { background: var(--surface-alt); color: var(--ink-muted); }
.field-hint { font-size: 13px; color: var(--ink-muted); line-height: 1.4; }
.field-error { font-size: 13px; font-weight: 600; color: var(--accent-text); line-height: 1.35; }
.field-error:empty { display: none; }
.field-error:not(:empty)::before { content: "! "; font-weight: 800; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-text); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.checks { display: flex; flex-wrap: wrap; gap: 14px 28px; }

.search-field { flex: 1; min-width: 220px; max-width: 420px; }
.sort-field { width: 200px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }

/* segmented type switch */
.seg { display: inline-flex; padding: 4px; border: 1px solid var(--ink); border-radius: var(--radius-pill); }
.seg-btn { height: 40px; padding: 0 20px; border: 0; border-radius: var(--radius-pill); background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink); }
.seg-btn.on { background: var(--ink); color: var(--surface); }
.seg-btn:not(.on):hover { background: var(--surface-sunken); }

/* editor action bar */
.actionbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; margin-bottom: 8px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; background: var(--surface); }
@media (max-width: 1023px) { .actionbar { position: static; } }

.editor-form .section { margin-bottom: 0; padding: 32px 0; border-bottom: 1px solid var(--line); }
.editor-form .section-head { margin-bottom: 18px; }
.editor-form .page-head { margin-bottom: 20px; }

.company-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.company-card.empty-co { border-color: var(--accent-text); }
.customer-pick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.customer-pick .field { flex: 1; min-width: 200px; }

/* line items */
.item { padding: 18px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.item-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 13px; font-weight: 700; }
select.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; width: auto; max-width: 220px; }
.item-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; margin-top: 14px; align-items: end; }
.item-nums.qty-only { grid-template-columns: minmax(96px, 160px); }
.calc { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.calc-l { font-size: 13px; font-weight: 500; color: var(--ink-muted); }
.calc-v { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }

.apply-vat { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 20px; }
.apply-vat .field { width: 240px; }

.totals-panel { margin-top: 24px; padding: 4px 0; border-top: 1px solid var(--ink); }
.tp-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tp-row.strong { font-weight: 700; color: var(--ink); }
.tp-row.balance { margin-top: 10px; padding: 14px 18px; border: 0; background: var(--ink); color: var(--surface); border-radius: var(--radius-md); font-weight: 700; font-size: 18px; }

/* settings uploads */
.uploads { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.upload { display: flex; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); align-items: center; }
.upload-preview { flex: none; width: 112px; height: 84px; display: flex; align-items: center; justify-content: center; background: var(--surface-alt); border-radius: var(--radius-sm); overflow: hidden; font-size: 12px; text-align: center; padding: 6px; }
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-title { font-weight: 600; color: var(--ink); }
.upload-body .row-gap { margin-top: 10px; }
