/* ============================================================
   app2.css — shared screen components for the redesigned admin
   tools (Dashboard v2 screens). Ported from the handoff app.css.
   Load AFTER /common.css + /appshell.css. Uses common.css tokens.
   ============================================================ */

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-body); font-weight: 600; font-size: 13px; border-radius: 8px; cursor: pointer; transition: background 100ms, box-shadow 100ms, color 100ms; border: none; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; stroke-width: 1.75; }
.btn-primary { background: var(--brand-700); color: var(--paper); padding: 8px 16px; }
.btn-primary:hover { background: var(--brand-800); }
.btn-ghost { background: none; color: var(--ink-500); padding: 7px 12px; border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--white); border-color: var(--ink-200); color: var(--ink-700); }
.btn-sm { font-size: 12px; padding: 5px 10px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }

/* Search pill (toolbar) */
.hd-search { display: flex; align-items: center; gap: 7px; background: var(--white); border: 1.5px solid var(--border); border-radius: 8px; padding: 7px 12px; min-width: 220px; cursor: text; transition: border-color 120ms, box-shadow 120ms; }
.hd-search:focus-within { border-color: var(--brand-700); box-shadow: 0 0 0 3px rgba(61,79,68,0.08); }
.hd-search svg { flex: 0 0 15px; width: 15px; height: 15px; color: var(--ink-300); fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.hd-search input { border: none; background: none; outline: none; font-family: var(--font-body); font-size: 13px; color: var(--ink-700); width: 100%; }
.hd-search input::placeholder { color: var(--ink-300); }
.hd-search kbd { font-family: var(--font-mono); font-size: 10px; color: var(--ink-300); background: var(--paper); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }

/* Top header bar (replaces the old per-page topbar) — matches Dashboard v2 .hd */
.topbar { display: none !important; }
.hd { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--border-soft); background: rgba(246,244,237,0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 40; }
.hd-zone-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.hd-zone-dot--green { background: var(--brand-700); }
.hd-zone-dot--amber { background: var(--accent-amber); }
.hd-zone-dot--sky { background: var(--accent-sky); }
.hd-zone-dot--rust { background: var(--accent-rust); }
.hd-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; color: var(--ink-900); line-height: 1.15; }
.hd-sub { font-size: 12px; color: var(--ink-400); margin-top: 1px; }
.hd-spacer { flex: 1; }
.hd-actions { display: flex; align-items: center; gap: 4px; }
.hd-icon { width: 34px; height: 34px; border-radius: 8px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-400); position: relative; }
.hd-icon:hover { background: var(--ink-100); color: var(--ink-700); }
.hd-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.hd-icon .dot { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; background: var(--accent-rust); border-radius: 50%; border: 2px solid var(--paper); }
.hd-lang { font-family: var(--font-mono); font-size: 11px; color: var(--ink-400); cursor: pointer; border: none; background: none; padding: 4px 6px; border-radius: 4px; white-space: nowrap; }
.hd-lang:hover { color: var(--ink-700); }
.hd-lang b { color: var(--ink-700); }
/* Header CTA buttons (restores per-page actions that lived in the old hidden .topbar) */
.hd-cta { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-body); font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: none; cursor: pointer; background: var(--brand-700); color: var(--paper); white-space: nowrap; transition: background 120ms; text-decoration: none; }
.hd-cta:hover { background: var(--brand-900); }
.hd-cta svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.hd-cta--ghost { background: var(--white); color: var(--ink-700); border: 1.5px solid var(--border); }
.hd-cta--ghost:hover { background: var(--ink-100); }
@media (max-width: 768px) { .hd { padding: 12px 16px; gap: 10px; } .hd-sub, .hd-search kbd { display: none; } .hd-search { min-width: 0; } .hd-cta span { display: none; } .hd-cta { padding: 8px; } }

/* Status badges */
.badge { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; display: inline-block; }
.badge--claimed, .badge--confirmed, .badge--paid, .badge--done, .badge--approved { background: var(--brand-100); color: var(--brand-700); }
.badge--unclaimed, .badge--pending, .badge--unpaid, .badge--review, .badge--submitted { background: #FEF5E0; color: #9A7028; }
.badge--na, .badge--draft, .badge--waitlist { background: var(--ink-100); color: var(--ink-400); }
.badge--rejected, .badge--overdue, .badge--lost { background: #FBEBE3; color: var(--accent-rust); }
.badge--preparing, .badge--active { background: #E8F0F6; color: #3D6E8A; }

/* Inputs */
.input-wrap { display: flex; flex-direction: column; gap: 5px; }
.input-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); font-weight: 500; }
.input { font-family: var(--font-body); font-size: 13px; color: var(--ink-700); background: var(--white); border: 1.5px solid var(--border); border-radius: 8px; padding: 8px 12px; outline: none; transition: border-color 120ms, box-shadow 120ms; width: 100%; }
.input:focus { border-color: var(--brand-700); box-shadow: 0 0 0 3px rgba(61,79,68,0.08); }
.input::placeholder { color: var(--ink-300); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='7' viewBox='0 0 12 7' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237C7E70' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

/* Card / Panel */
.card { background: var(--white); border-radius: 14px; box-shadow: var(--shadow-1); overflow: hidden; }
.card-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.card-actions { display: flex; align-items: center; gap: 6px; }

/* ══════════════════════════════════════════════════════════
   DATA TABLE
   ══════════════════════════════════════════════════════════ */
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.table-toolbar .filter-group { display: flex; align-items: center; gap: 6px; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-400); font-weight: 500; text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); background: var(--paper); position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th:hover { color: var(--ink-700); }
.tbl th svg { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-left: 3px; opacity: 0.4; }
.tbl td { padding: 11px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; color: var(--ink-700); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(61,79,68,0.02); }
.tbl .mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.02em; color: var(--ink-500); }
.tbl .cell-primary { font-weight: 600; color: var(--ink-900); }
.tbl .cell-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 100ms; }
.tbl tr:hover .cell-actions { opacity: 1; }
.tbl .cell-actions button { width: 28px; height: 28px; border-radius: 6px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-400); transition: background 100ms, color 100ms; }
.tbl .cell-actions button:hover { background: var(--ink-100); color: var(--ink-700); }
.tbl .cell-actions button svg { width: 14px; height: 14px; stroke-width: 1.75; }

.tbl-footer { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--border-soft); }
.tbl-info { font-family: var(--font-mono); font-size: 11px; color: var(--ink-400); }
.tbl-pages { display: flex; align-items: center; gap: 2px; }
.tbl-page { width: 30px; height: 30px; border-radius: 6px; border: none; background: none; cursor: pointer; font-family: var(--font-mono); font-size: 12px; color: var(--ink-400); display: flex; align-items: center; justify-content: center; transition: background 100ms; }
.tbl-page:hover { background: var(--ink-100); }
.tbl-page.active { background: var(--brand-700); color: var(--paper); font-weight: 600; }

/* ══════════════════════════════════════════════════════════
   UPLOAD / AI-ASSIST
   ══════════════════════════════════════════════════════════ */
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 48px 32px; text-align: center; cursor: pointer; transition: border-color 160ms, background 160ms; background: var(--white); }
.dropzone:hover, .dropzone.active { border-color: var(--brand-700); background: var(--brand-050); }
.dropzone-icon { margin: 0 auto 12px; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-050); color: var(--brand-700); display: flex; align-items: center; justify-content: center; }
.dropzone-icon svg { width: 24px; height: 24px; stroke-width: 1.75; }
.dropzone-label { font-weight: 600; font-size: 15px; color: var(--ink-700); margin-bottom: 4px; }
.dropzone-hint { font-size: 12px; color: var(--ink-400); }
.dropzone-browse { color: var(--brand-700); font-weight: 600; cursor: pointer; border-bottom: 1px solid rgba(61,79,68,0.25); }

.file-cards { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.file-card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow-1); overflow: hidden; }
.file-card-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.file-card-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--ink-100); flex: 0 0 40px; }
.file-card-name { font-weight: 600; font-size: 13px; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.file-card-size { font-family: var(--font-mono); font-size: 11px; color: var(--ink-300); }
.file-card-remove { width: 28px; height: 28px; border-radius: 6px; border: none; background: none; cursor: pointer; color: var(--ink-300); display: flex; align-items: center; justify-content: center; transition: background 100ms, color 100ms; }
.file-card-remove:hover { background: #FBEBE3; color: var(--accent-rust); }
.file-card-remove svg { width: 14px; height: 14px; stroke-width: 1.75; }

.file-card-body { padding: 16px 18px; }
.file-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* AI states */
.ai-state { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 8px; font-size: 12px; font-weight: 500; }
.ai-state--analyzing { background: var(--brand-050); color: var(--brand-700); }
.ai-state--done { background: var(--brand-100); color: var(--brand-700); }
.ai-state--error { background: #FBEBE3; color: var(--accent-rust); }
.ai-pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-700); animation: aipulse 1.4s ease-in-out infinite; }
@keyframes aipulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); } }
.ai-field { position: relative; }
.ai-field .input { border-color: var(--brand-300); background: rgba(226,236,227,0.25); }
.ai-field-tag { position: absolute; top: -7px; right: 8px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; background: var(--brand-700); color: var(--paper); padding: 1px 5px; border-radius: 3px; }

/* ══════════════════════════════════════════════════════════
   WIZARD / STEPPER
   ══════════════════════════════════════════════════════════ */
.stepper { display: flex; align-items: center; gap: 0; padding: 20px 28px; border-bottom: 1px solid var(--border-soft); background: var(--white); }
.step { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 14px; border-radius: 8px; transition: background 100ms; }
.step:hover { background: var(--brand-050); }
.step-num { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 12px; font-weight: 600; border: 1.5px solid var(--border); color: var(--ink-400); background: var(--white); transition: all 160ms; }
.step.active .step-num { background: var(--brand-700); color: var(--paper); border-color: var(--brand-700); }
.step.done .step-num { background: var(--brand-100); color: var(--brand-700); border-color: var(--brand-100); }
.step-label { font-size: 13px; font-weight: 500; color: var(--ink-400); transition: color 100ms; white-space: nowrap; }
.step.active .step-label { color: var(--ink-900); font-weight: 600; }
.step.done .step-label { color: var(--brand-700); }
.step-line { flex: 0 0 32px; height: 1px; background: var(--border); margin: 0 4px; }
.step-line.done { background: var(--brand-300); }

/* Wizard body */
.wizard-body { padding: 28px; max-width: 800px; }
.wizard-footer { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-top: 1px solid var(--border-soft); background: var(--white); margin-top: auto; }

/* ══════════════════════════════════════════════════════════
   EMPTY / PLACEHOLDER
   ══════════════════════════════════════════════════════════ */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 32px; text-align: center; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-050); color: var(--brand-700); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.empty-icon svg { width: 28px; height: 28px; stroke-width: 1.5; }
.empty-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink-700); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--ink-400); max-width: 360px; line-height: 1.5; }

/* ══════════════════════════════════════════════════════════
   MODAL / DRAWER
   ══════════════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(22,23,15,0.5); z-index: 800; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--white); border-radius: 16px; box-shadow: 0 24px 60px rgba(22,23,15,0.2); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; width: 100%; }
.modal--sm { max-width: 480px; }
.modal--md { max-width: 640px; }
.modal--lg { max-width: 840px; }
.modal--xl { max-width: 1040px; }
.modal-hd { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); flex: 0 0 auto; }
.modal-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.modal-close { width: 32px; height: 32px; border-radius: 8px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-400); transition: background 100ms; }
.modal-close:hover { background: var(--ink-100); }
.modal-close svg { width: 18px; height: 18px; stroke-width: 1.75; }
.modal-body { flex: 1; overflow-y: auto; padding: 22px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border-soft); flex: 0 0 auto; }

/* ══════════════════════════════════════════════════════════
   SPLIT PANE (form + preview)
   ══════════════════════════════════════════════════════════ */
.split { display: flex; gap: 0; flex: 1; overflow: hidden; }
.split-form { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; border-right: 1px solid var(--border-soft); }
.split-preview { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; background: var(--paper-alt); }
@media (max-width: 900px) { .split { flex-direction: column; } .split-form, .split-preview { border-right: none; } .split-form { border-bottom: 1px solid var(--border-soft); } }

/* ══════════════════════════════════════════════════════════
   EXPANDABLE ROW DETAIL
   ══════════════════════════════════════════════════════════ */
.row-detail { background: var(--paper); border-bottom: 1px solid var(--border-soft); padding: 18px 22px; animation: rowSlide 160ms var(--ease-out); }
@keyframes rowSlide { from { opacity: 0; max-height: 0; padding: 0 22px; } to { opacity: 1; max-height: 400px; } }
.row-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }
.row-detail-field { display: flex; flex-direction: column; gap: 3px; }
.row-detail-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-400); }
.row-detail-value { font-size: 13px; color: var(--ink-700); font-weight: 500; }
.row-detail-value.mono { font-family: var(--font-mono); font-size: 12px; }
.row-detail-actions { display: flex; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border-soft); }

/* ══════════════════════════════════════════════════════════
   LINE ITEM EDITOR
   ══════════════════════════════════════════════════════════ */
.line-items { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.line-items th { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); font-weight: 500; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.line-items td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.line-items .input { padding: 6px 8px; font-size: 13px; border-radius: 6px; }
.line-items .mono-input { font-family: var(--font-mono); }
.line-items .row-total { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--ink-900); text-align: right; white-space: nowrap; }
.line-items-footer { display: flex; justify-content: space-between; align-items: center; }
.line-total-row { display: flex; justify-content: flex-end; gap: 24px; padding: 12px 10px; border-top: 2px solid var(--border); }
.line-total-label { font-size: 14px; font-weight: 600; color: var(--ink-700); }
.line-total-value { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--ink-900); }

/* ══════════════════════════════════════════════════════════
   DOCUMENT PREVIEW (branded)
   ══════════════════════════════════════════════════════════ */
.doc-preview { background: var(--white); border-radius: 8px; box-shadow: var(--shadow-2); padding: 40px 36px; max-width: 580px; margin: 0 auto; font-size: 13px; }
.doc-preview-banner { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 2px solid var(--brand-700); }
.doc-preview-banner img { height: 36px; border-radius: 4px; }
.doc-preview-banner h2 { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--brand-900); letter-spacing: 0.04em; }
.doc-preview-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; font-size: 12px; }
.doc-preview-meta dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); }
.doc-preview-meta dd { color: var(--ink-700); font-weight: 500; margin: 0 0 8px; }
.doc-preview-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.doc-preview-table th { background: var(--paper); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-400); padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.doc-preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); font-size: 12px; color: var(--ink-700); }
.doc-preview-table .mono { font-family: var(--font-mono); }
.doc-preview-stamp { text-align: right; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.doc-preview-stamp span { display: inline-block; border: 2px solid var(--accent-rust); color: var(--accent-rust); font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: 0.06em; padding: 6px 16px; border-radius: 4px; transform: rotate(-6deg); opacity: 0.8; }

/* ══════════════════════════════════════════════════════════
   TABS (inline, for modal sections)
   ══════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; }
.tab-btn { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--ink-400); padding: 10px 16px; border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 100ms, border-color 100ms; }
.tab-btn:hover { color: var(--ink-700); }
.tab-btn.active { color: var(--ink-900); font-weight: 600; border-bottom-color: var(--brand-700); }

/* Overdue emphasis */
.tbl tr.overdue td { background: rgba(184,92,60,0.04); }
.tbl tr.overdue .badge { animation: overduePulse 2s ease-in-out infinite; }
@keyframes overduePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
