/* Invoice Inbox — same look as Quote Manager. Plain CSS, no build step. */
:root {
    --bg: #f4f5f7;
    --surface: #fff;
    --panel: #fbfbfc;
    --ink: #16191d;
    --ink-2: #3a414a;
    --ink-3: #4a525c;
    --muted: #5b636e;
    --faint: #8a929c;
    --line: #e3e5e8;
    --line-soft: #eceef1;
    --field: #d5d9de;
    --field-hover: #b5bcc5;
    --head: #f7f8f9;
    --hover-blue: #f3f6fa;
    --selected: #edf3fb;
    --primary: #2f5f9e;
    --primary-dark: #244c80;
    --success: #1f6b45;
    --danger: #8a2318;
    --disabled: #c3c9d1;
    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-dark); cursor: pointer; }
a:hover { color: var(--ink); }
input, select, textarea, button { font-family: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[x-cloak] { display: none !important; }

/* ---------- Text helpers ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ink-2 { color: var(--ink-2); }
.danger-text { color: var(--danger); }
.warn-text { color: #7a4f06; }
.fs-11 { font-size: 11.5px; }
.fs-12 { font-size: 12px; }
.fs-125 { font-size: 12.5px; }
.fs-13 { font-size: 13px; }
.fw-5 { font-weight: 500; }
.fw-6 { font-weight: 600; }
.lh { line-height: 1.45; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.min0 { min-width: 0; }
.break { word-break: break-word; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pretty { text-wrap: pretty; }
.h1 { font-size: 22px; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; }
.h2 { font-size: 16px; font-weight: 600; }
.h3 { font-size: 14px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.stack { display: flex; flex-direction: column; }
.gap-2 { gap: 2px; } .gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }

/* ---------- Shell ---------- */
.frame { min-height: 100vh; display: flex; justify-content: center; }
.shell { width: 100%; display: flex; min-height: 100vh; }
.sidebar {
    width: 232px; flex: none; height: 100vh; position: sticky; top: 0; z-index: 10; /* its inbox panel opens over the page, under drawers and modals */
    display: flex; flex-direction: column; gap: 2px; padding: 16px 10px;
    border-right: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; }
.brand-mark {
    width: 22px; height: 22px; border-radius: 4px; background: var(--ink); color: #fff; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-size: 11px; font-weight: 500;
}
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.nav-link {
    display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--ink);
    font-size: 13.5px; text-align: left; padding: 7px 10px; border-radius: 6px; text-decoration: none;
}
.nav-link:hover { background: #eef0f3; color: var(--ink); }
.nav-link.is-active { background: #e8ebef; font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; }
.me-name { font-size: 12px; line-height: 1.3; }
.mobile-bar { display: none; }

/* ---------- Avatars & pills ---------- */
.avatar {
    width: 28px; height: 28px; border-radius: 999px; flex: none; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; background: #dfe6ef; color: var(--primary-dark);
}
.avatar-30 { width: 30px; height: 30px; }
.avatar-36 { width: 36px; height: 36px; font-size: 12px; }

.pill { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; white-space: nowrap; }
.pill-sm { font-size: 11.5px; padding: 0 6px; }
.pill-strong { font-weight: 500; }
.tone-warn { background: #fbefd5; color: #7a4f06; }
.tone-ok { background: #e5f2ea; color: #1f5b3a; }
.tone-muted { background: #eef0f2; color: var(--muted); }
.tone-neutral { background: #eef0f2; color: var(--ink-3); }
.tone-slate { background: #eef0f2; color: var(--ink-2); }
.tone-info { background: #ebeefa; color: #34408a; }
.tone-danger { background: #fbe4e1; color: var(--danger); }

/* ---------- Buttons & inputs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--field); background: #fff; color: var(--ink); border-radius: 6px;
    padding: 5px 10px; font-size: 12.5px; white-space: nowrap; text-decoration: none; line-height: 1.4;
}
.btn:hover { border-color: var(--field-hover); color: var(--ink); }
.btn:disabled, .btn:disabled:hover { opacity: .5; border-color: var(--field); }
.btn-lg { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-md { height: 32px; padding: 0 12px; }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-dark { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 600; }
.btn-dark:hover { color: #fff; }
.btn-danger { border-color: var(--danger); background: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { color: #fff; border-color: var(--danger); }
.btn-danger-outline { color: var(--danger); }
.btn-danger-outline:hover { border-color: #c98f87; color: var(--danger); }
.btn-disabled, .btn-disabled:hover { border-color: var(--disabled); background: var(--disabled); color: #fff; font-weight: 600; cursor: not-allowed; }
.btn-text { border: 0; background: transparent; padding: 0; color: var(--primary); font-size: 12.5px; }
.btn-text:hover { color: var(--primary-dark); }
.btn-icon { width: 28px; height: 28px; padding: 0; }
.btn-close { width: 28px; height: 28px; border: 0; background: transparent; border-radius: 6px; font-size: 16px; color: var(--muted); }
.btn-close:hover { background: #eef0f2; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.field-hint { font-weight: 400; color: var(--faint); }
.input, .select, .textarea {
    height: 34px; border: 1px solid var(--field); border-radius: 6px; padding: 0 10px; font-size: 13px;
    color: var(--ink); background: #fff; font-weight: 400; min-width: 0;
}
.select { padding: 0 8px; }
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid rgba(47, 95, 158, .25); outline-offset: 0; border-color: var(--primary); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--head); color: var(--ink-2); }
.input-group { display: flex; height: 34px; border: 1px solid var(--field); border-radius: 6px; overflow: hidden; background: #fff; }
.input-group:focus-within { border-color: var(--primary); }
.input-group > input, .input-group > select { flex: 1; min-width: 0; border: 0; padding: 0 10px; font-size: 13px; outline: none; background: transparent; }
.input-group > select { flex: none; border-left: 1px solid var(--field); background: var(--head); padding: 0 8px; }
.addon { padding: 0 10px; display: flex; align-items: center; background: var(--head); color: var(--ink-2); font-size: 13px; }
.addon:first-child { border-right: 1px solid var(--field); }
.addon:last-child { border-left: 1px solid var(--field); }
.input-sm { height: 32px; }
.input-sm > input { padding: 0 6px; font-size: 12.5px; }
.input-sm .addon { padding: 0 7px; font-size: 12px; }

.switch { width: 34px; height: 20px; border-radius: 999px; border: 0; background: var(--disabled); position: relative; padding: 0; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; transition: left .15s; }
.switch.is-on { background: var(--primary); }
.switch.is-on::after { left: 16px; }

.seg { display: inline-flex; border: 1px solid var(--field); border-radius: 6px; overflow: hidden; align-self: flex-start; }
.seg > button { border: 0; border-right: 1px solid var(--field); background: #fff; color: var(--ink); padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
.seg > button:last-child { border-right: 0; }
.seg > button.is-on { background: var(--ink); color: #fff; }
.seg-sm > button { padding: 5px 10px; font-size: 12px; }
.seg-md > button { padding: 6px 12px; }

/* ---------- Cards & tables ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.card-clip { overflow: hidden; }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 14px 16px; }
.card-dashed { background: #fff; border: 1px dashed var(--disabled); border-radius: 8px; }
.list-row { padding: 11px 16px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, .list-row.is-link:hover { background: var(--head); color: var(--ink); cursor: pointer; }
.scroll-x { overflow: auto; }
.gt { display: grid; grid-template-columns: var(--cols); gap: 12px; }
.gt-head { padding: 8px 16px; background: var(--head); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--muted); align-items: center; }
.gt-row { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); align-items: center; font-size: 13px; color: var(--ink); text-decoration: none; }
.gt-row:last-child { border-bottom: 0; }
.gt-row.top { align-items: start; }
a.gt-row:hover, .gt-row.is-link:hover { background: var(--head); color: var(--ink); cursor: pointer; }

.stat { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--field-hover); color: var(--ink); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 600; font-family: var(--mono); }
.stat-sub { font-size: 12px; color: var(--muted); }

.grid-auto { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-panels { display: grid; gap: 16px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-cats { display: grid; gap: 16px; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.grid-fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.notice { border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.45; }
.notice-warn { background: #fdf6e7; border: 1px solid #f1dfb4; color: #5a3b05; }
.notice-danger { background: #fbe4e1; border: 1px solid #f0c7c1; color: #5e1a12; }
.notice-ok { background: #e5f2ea; border: 1px solid #b9d9c5; color: #15452b; }
.notice-plain { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.flag-box { display: flex; flex-direction: column; gap: 2px; background: #fdf6e7; border: 1px solid #f1dfb4; border-radius: 6px; padding: 8px 10px; font-size: 12.5px; line-height: 1.45; color: #5a3b05; }

/* ---------- Pages ---------- */
.page { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 1280px; }
.page-gap-20 { gap: 20px; }
.page-narrow { max-width: 880px; }
.page-project { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head-end { align-items: flex-end; gap: 10px 16px; }

.project-head {
    padding: 18px 24px 0; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line);
    background: #fff; position: sticky; top: 0; z-index: 4;
}
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: -1px; }
.tab {
    white-space: nowrap; flex: none; border: 0; background: transparent; border-bottom: 2px solid transparent; color: var(--muted);
    font-size: 13.5px; padding: 8px 10px 10px; display: flex; gap: 6px; align-items: center; text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab.is-active { border-bottom-color: var(--ink); color: var(--ink); font-weight: 600; }

/* ---------- Overlays ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(22, 25, 29, .35); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 8px; box-shadow: 0 8px 24px rgba(22, 25, 29, .16); padding: 20px; max-width: 460px; width: 100%; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-wide { max-width: 560px; }
.modal-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(22, 25, 29, .28); z-index: 30; display: flex; justify-content: flex-end; }
.drawer { width: 480px; max-width: 100%; height: 100vh; background: #fff; box-shadow: -8px 0 24px rgba(22, 25, 29, .14); display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
    padding: 10px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(22, 25, 29, .16);
    z-index: 50; max-width: 90vw; display: flex; gap: 14px; align-items: center;
}
.toast button { border: 0; background: transparent; color: #9ec1ee; font-weight: 600; font-size: 13px; padding: 0; }

/* ---------- Auth & onboarding ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth-card.wide { max-width: 460px; }
.auth-title { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.auth-foot { font-size: 12.5px; color: var(--muted); text-align: center; }
.field-error { font-size: 12px; font-weight: 400; color: var(--danger); }
.btn-block { width: 100%; height: 38px; font-size: 13.5px; }
.divider { height: 1px; background: var(--line-soft); }

/* ---------- Menus ---------- */
.menu { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(22, 25, 29, .12); padding: 4px; min-width: 220px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--ink); text-decoration: none; }
.menu-item:hover { background: #eef0f3; color: var(--ink); }
.menu-label { padding: 6px 10px 4px; font-size: 11.5px; color: var(--faint); }
.me-button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px 6px; border-radius: 6px; text-align: left; margin-top: 8px; }
.me-button:hover { background: #eef0f3; }

/* ---------- Icons (Heroicons via blade-ui-kit/blade-heroicons) ---------- */
.icon { width: 16px; height: 16px; flex: none; }
.icon-sm { width: 14px; height: 14px; flex: none; }
.icon-lg { width: 20px; height: 20px; flex: none; }
.icon-xl { width: 32px; height: 32px; flex: none; }
.nav-link .icon { width: 18px; height: 18px; color: var(--muted); }
.nav-link:hover .icon, .nav-link.is-active .icon { color: var(--ink); }
.tab .icon { opacity: .75; }
.tab.is-active .icon { opacity: 1; }
.menu-item .icon { color: var(--muted); }
.stat-label { display: flex; align-items: center; gap: 6px; }
.stat-label .icon { color: var(--faint); }
.check .icon-sm { width: 12px; height: 12px; }
.icon-muted { color: var(--muted); }
.icon-faint { color: var(--faint); }
.inline-icon { display: inline-flex; align-items: center; gap: 4px; }

.search-box { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 4px 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.search-box:focus-within { outline: 2px solid rgba(47, 95, 158, .25); border-color: var(--primary); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; }
.search-box input::-webkit-search-cancel-button { display: none; }

/* ---------- Invoice Inbox ---------- */
#app-main { flex: 1; min-width: 0; min-height: 100vh; }
.th-sort { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 3px; }
.th-sort:hover, .th-sort.is-on { color: var(--ink); }
.amount { font-family: var(--mono); font-size: 12.5px; text-align: right; white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters .select, .filters .input { height: 34px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.spinner { width: 12px; height: 12px; border-radius: 999px; border: 2px solid #c9d6ea; border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 44px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.empty .icon-xl { color: var(--disabled); }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.provider { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.provider button { border: 1px solid var(--field); background: #fff; border-radius: 8px; padding: 10px 12px; text-align: left; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.provider button:hover { border-color: var(--field-hover); }
.provider button.is-on { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: #f6f9fd; font-weight: 600; }
.form-section { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line-soft); }
.form-section:last-child { border-bottom: 0; }
.form-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.inline-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink); font-weight: 400; }
.inline-check input { margin: 2px 0 0; accent-color: var(--primary); }
/* Invoice drawer: the document next to the fields that were read from it. */
.drawer-wide { width: min(1080px, 100%); }
.drawer-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); }
.drawer-split > .drawer-body { border-left: 1px solid var(--line); }
.preview { background: #53585f; min-height: 0; display: flex; }
.preview iframe { flex: 1; border: 0; width: 100%; height: 100%; background: #fff; }
.preview-image { flex: 1; overflow: auto; padding: 12px; }
.preview-image img { display: block; max-width: 100%; margin: 0 auto; background: #fff; }
@media (max-width: 900px) {
    .drawer-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: 45vh minmax(0, 1fr); }
    .drawer-split > .drawer-body { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { display: none; }
    .mobile-bar { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
    .mobile-bar .top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
    .mobile-bar nav { display: flex; gap: 4px; overflow-x: auto; padding: 0 12px 10px; }
    .mobile-bar .nav-link { white-space: nowrap; flex: none; font-size: 13px; padding: 8px 12px; min-height: 36px; }
    .page { padding: 16px; }
    .project-head { padding: 14px 16px 0; position: static; }
}

/* Filter chips (All attachments) and the drawer's "are you sure" bar */
.chip {
    display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--field); background: #fff; color: var(--ink);
    border-radius: 6px; padding: 4px 10px; font-size: 12.5px; white-space: nowrap;
}
.chip:hover { border-color: var(--field-hover); }
.chip .n { opacity: .6; font-family: var(--mono); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.drawer-foot .btn, .drawer-confirm .btn { padding: 7px 12px; font-size: 13px; }
.drawer-confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid #f0c7c1; background: #fbe4e1; font-size: 13px; color: #5e1a12; }
