/* ITBAALI Factures — interface */
:root {
  --brand: #f95e06;
  --brand-600: #e05200;
  --brand-50: #fff4ec;
  --brand-100: #ffe4d1;
  --ink: #1b1b19;
  --ink-2: #3d3d3a;
  --muted: #6e6c68;
  --line: #e8e5e1;
  --line-2: #f1eeea;
  --bg: #f6f5f3;
  --card: #ffffff;
  --paid: #15803d;
  --paid-bg: #e6f6ec;
  --partial: #a35a00;
  --partial-bg: #fff2d6;
  --unpaid: #b42318;
  --unpaid-bg: #fdecea;
  --c-billed: #f95e06;
  --c-paid: #2f6bd8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 27, 25, .06), 0 1px 3px rgba(27, 27, 25, .04);
  --shadow-lg: 0 12px 32px rgba(27, 27, 25, .16);
  --sidebar: 236px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 21px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
mark { background: var(--brand-100); color: inherit; border-radius: 2px; padding: 0 1px; }
.ico { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--card); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; gap: 14px;
  z-index: 30;
}
.brand { display: flex; justify-content: center; padding: 4px 0 6px; text-decoration: none; color: var(--ink); }
.brand img { height: 62px; max-width: 100%; object-fit: contain; }
.btn-new { justify-content: center; padding: 11px 14px; font-size: 14px; }
.btn-new .plus { font-size: 18px; line-height: 1; margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--ink-2); font-weight: 500; position: relative;
}
.nav-item .ico { color: var(--muted); }
.nav-item:hover { background: var(--line-2); }
.nav-item.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.nav-item.active .ico { color: var(--brand); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.sidebar-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); padding: 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(246, 245, 243, .92); backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 14px; padding: 16px 28px; border-bottom: 1px solid transparent;
  min-height: 68px;
}
.topbar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .menu-btn { display: none; }
.content { padding: 4px 28px 40px; max-width: 1320px; width: 100%; outline: none; }
.loading { padding: 40px; color: var(--muted); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 8px; padding: 8px 13px; font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1.2; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--line-2); }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-danger { background: var(--unpaid); border-color: var(--unpaid); color: #fff; }
.btn-danger:hover { background: #8f1c13; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--line-2); }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.btn-lg { padding: 11px 18px; font-size: 15px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; text-decoration: none;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--unpaid-bg); color: var(--unpaid); }
.actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ------------------------------------------------------------ cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.card-body { padding: 18px 20px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
a.kpi:hover { border-color: var(--brand-100); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi-label .ico { color: var(--brand); }
.kpi-value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi.accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: #c9c6c1; }

.quick { display: flex; gap: 10px; flex-wrap: wrap; }
.quick .btn { padding: 10px 16px; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfaf9; white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th .sort { color: var(--brand); margin-left: 3px; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: #fcfaf8; }
.table .num, .table th.num { text-align: right; }
.table td.strong, .strong { font-weight: 600; }
.inv-no { white-space: nowrap; font-weight: 650; color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }
.inv-no:hover { color: var(--brand-600); }
.table-foot { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); background: #fbfaf9; font-size: 13px; border-radius: 0 0 var(--radius) var(--radius); }
.table-foot b { font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-payee { background: var(--paid-bg); color: var(--paid); }
.badge-partielle { background: var(--partial-bg); color: var(--partial); }
.badge-non_payee { background: var(--unpaid-bg); color: var(--unpaid); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--line-2); font-size: 12px; color: var(--ink-2); }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; }

/* ------------------------------------------------------------ forms */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
label.field .hint { font-weight: 400; color: var(--muted); }
.input, input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #dcd8d3; border-radius: 8px; padding: 8px 11px;
  width: 100%; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(249, 94, 6, .15); }
input.invalid { border-color: var(--unpaid); box-shadow: 0 0 0 3px rgba(180, 35, 24, .12); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.search-box { position: relative; flex: 1; min-width: 240px; }
.search-box .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 38px; height: 42px; font-size: 14.5px; }
.search-box kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label.field { font-size: 11.5px; }
.filters select, .filters input { height: 36px; padding-top: 6px; padding-bottom: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }

/* ------------------------------------------------------------ invoice form */
.inv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.inv-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 18px; }
.meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.client-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.client-grid .wide { grid-column: 1 / -1; }
.client-state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.client-state.known { background: var(--paid-bg); color: var(--paid); }
.client-state.new { background: var(--brand-50); color: var(--brand-600); }

table.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: #fff; background: var(--brand); padding: 9px 8px; text-align: left; font-weight: 700; }
.items th:first-child { border-radius: 7px 0 0 7px; padding-left: 12px; }
.items th:last-child { border-radius: 0 7px 7px 0; }
.items td { padding: 6px 4px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.items td.idx { width: 30px; color: var(--muted); font-size: 12px; text-align: center; }
.items td.c-qty { width: 92px; }
.items td.c-price { width: 130px; }
.items td.c-total { width: 130px; text-align: right; font-weight: 650; padding-right: 10px; font-variant-numeric: tabular-nums; }
.items td.c-del { width: 40px; text-align: center; }
.items input { border-color: transparent; background: transparent; padding: 7px 8px; }
.items input:hover { border-color: var(--line); background: #fff; }
.items input:focus { background: #fff; }
.items input.qty, .items input.price { text-align: right; font-variant-numeric: tabular-nums; }
.items-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0 0; flex-wrap: wrap; }
.kbd-hint { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

.totals { display: flex; flex-direction: column; gap: 10px; }
.totals .line { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.totals .line > span:first-child { color: var(--muted); }
.totals .line b { font-variant-numeric: tabular-nums; }
.totals .inline-input { display: flex; gap: 6px; align-items: center; }
.totals .inline-input input { width: 90px; text-align: right; padding: 6px 8px; }
.totals .inline-input select { width: auto; padding: 6px 8px; }
.grand { display: flex; justify-content: space-between; align-items: center; background: var(--brand); color: #fff; border-radius: 8px; padding: 12px 14px; margin: 4px 0; }
.grand span { font-weight: 700; letter-spacing: .03em; font-size: 13px; }
.grand b { font-size: 20px; font-variant-numeric: tabular-nums; }
.divider { border: 0; border-top: 1px dashed var(--line); margin: 4px 0; }

.payments { display: flex; flex-direction: column; gap: 8px; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr 32px; grid-template-areas: "amount amount del" "date method ."; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--line-2); border-radius: 8px; background: #fcfbfa; }
.pay-row [data-f=amount] { grid-area: amount; font-weight: 600; }
.pay-row [data-f=date] { grid-area: date; }
.pay-row [data-f=method] { grid-area: method; }
.pay-row [data-del-pay] { grid-area: del; }
.pay-row input, .pay-row select { padding: 6px 8px; font-size: 13px; }
.pay-row input.amount { text-align: right; }

.save-bar {
  position: sticky; bottom: 0; z-index: 15; margin: 18px -28px -40px; padding: 12px 28px; background: rgba(255, 255, 255, .95);
  border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; backdrop-filter: blur(6px);
}

/* ------------------------------------------------------------ invoice view */
.view-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.pdf-frame { width: 100%; height: calc(100vh - 140px); min-height: 620px; border: 0; border-radius: var(--radius); background: #525659; display: block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.pay-list li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 7px; background: var(--line-2); }

/* ------------------------------------------------------------ autocomplete */
.ac-list {
  position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-lg);
  max-height: 320px; overflow-y: auto; padding: 5px; max-width: 520px;
}
.ac-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.ac-item.active { background: var(--brand-50); }
.ac-item .ac-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ac-item .ac-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-create { color: var(--brand-600); font-weight: 600; border-top: 1px solid var(--line-2); margin-top: 3px; justify-content: flex-start; gap: 8px; }
.ac-plus { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; }

/* ------------------------------------------------------------ modal / toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 20, 18, .45); display: flex; align-items: flex-start; justify-content: center; padding: 9vh 16px 16px; z-index: 900; animation: fade .12s ease-out; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); max-height: 84vh; display: flex; flex-direction: column; }
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 6px; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 12px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.confirm-text { margin: 0; line-height: 1.55; color: var(--ink-2); }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px 11px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-weight: 550; font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; display: flex; gap: 9px; align-items: center; max-width: 420px; }
.toast::before { content: "✓"; display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; background: var(--paid); font-size: 12px; flex: none; }
.toast-error::before { content: "!"; background: var(--unpaid); }
.toast-info::before { content: "i"; background: var(--brand); }
.toast.show { opacity: 1; transform: none; }

/* ------------------------------------------------------------ stats */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; align-items: end; height: 240px; padding: 10px 4px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent 54px, var(--line-2) 54px, var(--line-2) 55px); }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; position: relative; }
.bar-pair { display: flex; gap: 2px; align-items: flex-end; height: calc(100% - 22px); width: 100%; justify-content: center; }
.bar { width: 42%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 1px; }
.bar.billed { background: var(--c-billed); }
.bar.paid { background: var(--c-paid); }
.bar-col:hover .bar, .bar-col:focus .bar { filter: brightness(.92); }
.bar-col:focus { outline: none; }
.bar-col:focus .bar-tip { display: block; }
.bar-label { font-size: 11.5px; color: var(--muted); }
.bar-col:hover .bar-tip { display: block; }
.bar-tip { display: none; position: absolute; bottom: 60%; line-height: 1.5; background: var(--ink); color: #fff; font-size: 11.5px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.rank .meter { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.rank .meter span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* ------------------------------------------------------------ settings */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.logo-preview { display: flex; align-items: center; justify-content: center; height: 120px; border: 1px dashed var(--line); border-radius: 10px; background: #fff; padding: 12px; }
.logo-preview img { max-height: 100%; max-width: 100%; object-fit: contain; }
.preview-num { font-weight: 700; color: var(--brand-600); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ sign-in */
.login-gate { position: fixed; inset: 0; z-index: 800; isolation: isolate; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; }
.login-gate::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 38%; background: var(--brand); clip-path: polygon(0 0, 100% 0, 100% 62%, 0 100%); z-index: -1; }
.login-card { width: 100%; max-width: 460px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 34px 26px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.login-logo { height: 74px; margin-bottom: 4px; }
.login-card h1 { font-size: 21px; }
.login-text { margin: 0; color: var(--muted); line-height: 1.55; font-size: 14px; }
.login-card .btn-lg { width: 100%; justify-content: center; padding: 12px 18px; }
.login-error { width: 100%; background: var(--unpaid-bg); color: var(--unpaid); border-radius: 8px; padding: 9px 12px; font-size: 13px; text-align: left; }


/* ------------------------------------------------------------ SaaS: account, subscription */
body.auth-mode .app { display: none; }
.auth-wrap { width: 100%; max-width: 900px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.auth-card { max-width: 440px; }
.auth-tabs { width: 100%; }
.auth-tabs button { flex: 1; padding: 9px 12px; font-size: 13.5px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; width: 100%; text-align: left; }
.trial-pill { background: var(--paid-bg); color: var(--paid); font-weight: 600; font-size: 12.5px; border-radius: 8px; padding: 8px 10px; text-align: center; }
.auth-plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; }
.auth-plan { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.auth-plan.rec { border: 2px solid var(--brand); }
.auth-price { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.rec-tag { position: absolute; top: -10px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; }

.brand-name { font-weight: 800; font-size: 18px; text-align: center; line-height: 1.2; padding: 10px 4px; word-break: break-word; }
.nav-item.locked { opacity: .55; }
.nav-item .lock { margin-left: auto; font-size: 11px; }
.acct { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: 9px; background: var(--line-2); min-width: 0; }
.acct-company { font-weight: 700; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-email { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-plan { margin-top: 5px; align-self: flex-start; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; text-decoration: none; background: var(--brand-50); color: var(--brand-600); }
.acct-plan.st-active { background: var(--paid-bg); color: var(--paid); }
.acct-plan.st-lifetime { background: #ede9fe; color: #5b21b6; }
.acct-plan.st-trial_expired, .acct-plan.st-expired { background: var(--unpaid-bg); color: var(--unpaid); }
.acct-plan.st-suspended { background: #e7e5e4; color: #44403c; }
.acct-logout { justify-content: flex-start; margin-top: 4px; color: var(--muted); }
.account-chip { display: flex; flex-direction: column; }

.sub-banner { margin: 0 28px 14px; padding: 10px 14px; border-radius: 10px; background: var(--brand-50); border: 1px solid var(--brand-100); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }

.badge-st-trial { background: var(--brand-50); color: var(--brand-600); }
.badge-st-active { background: var(--paid-bg); color: var(--paid); }
.badge-st-lifetime { background: #ede9fe; color: #5b21b6; }
.badge-st-trial_expired, .badge-st-expired { background: var(--unpaid-bg); color: var(--unpaid); }
.badge-st-suspended { background: #e7e5e4; color: #44403c; }

.sub-card-main { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sub-card-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.sub-line { font-size: 13.5px; margin-top: 4px; }
.sub-big { font-size: 16px; margin: 0 0 10px; }
.meter-bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin: 8px 0; max-width: 520px; }
.meter-bar span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; margin-top: 10px; }
.alert .ico { margin-top: 2px; }
.alert-err { background: var(--unpaid-bg); color: #7a1a12; }
.alert-err .ico { color: var(--unpaid); }
.alert-info { background: var(--partial-bg); color: #6b3d00; }

.section-title { margin: 6px 0 14px; }
.section-title p { margin: 4px 0 0; font-size: 13px; }
.pricing { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.plan-card { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px 18px 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.plan-card h3 { font-size: 16px; }
.plan-card .btn { justify-content: center; margin-top: auto; }
.plan-card.recommended { border: 2px solid var(--brand); box-shadow: 0 10px 28px rgba(249, 94, 6, .16); transform: translateY(-6px); }
.plan-card.current { outline: 2px solid var(--paid); outline-offset: -2px; }
.plan-ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; padding: 3px 12px; border-radius: 999px; white-space: nowrap; }
.plan-desc { margin: 0; font-size: 12.5px; color: var(--muted); min-height: 34px; }
.plan-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.plan-price span { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.plan-price small { color: var(--muted); font-size: 12.5px; }
.price-note { font-size: 12px; color: var(--muted); min-height: 18px; }
.price-note b { color: var(--paid); }
.plan-features { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 18px; font-size: 13px; color: var(--ink-2); }
.plan-features li::before { content: "✓"; color: var(--paid); font-weight: 700; margin-right: 8px; }

.pay-box { background: #fcfbfa; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.pay-box h3 { margin-bottom: 8px; }
.pay-info-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.pay-info-row:last-of-type { border-bottom: 0; }
.pay-info-row span { color: var(--muted); width: 90px; flex: none; }
.pay-info-row b { flex: 1; word-break: break-all; font-variant-numeric: tabular-nums; }
.temp-pw { font: 600 20px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2); padding: 12px; border-radius: 8px; text-align: center; letter-spacing: .05em; user-select: all; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--brand-600); border-bottom-color: var(--brand); }
.kpi.warn { border-color: var(--partial); background: var(--partial-bg); }


.btn-google { justify-content: center; gap: 10px; background: #fff; border-color: #dadce0; color: #3c4043; font-weight: 600; width: 100%; }
.btn-google:hover { background: #f8f9fa; border-color: #c6c9cc; }
.auth-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 6px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
/* ------------------------------------------------------------ responsive */
/* ------------------------------------------------------------ invoice templates */
.tpl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.tpl-options { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: flex-end; }
.tpl-opt-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.tpl-opt-save { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tpl-selects { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; flex: 1 1 100%; }
.tpl-checks { display: flex; gap: 18px; flex-wrap: wrap; }
.tpl-thumb { position: relative; }
.tpl-fail { display: none; position: absolute; inset: 40% 18px auto; text-align: center; font-size: 12px; color: var(--unpaid); background: #fff; padding: 8px; border-radius: 6px; }
.tpl-thumb.failed .tpl-fail { display: block; }
.inv-tpl .form-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.inv-tpl input[type=color] { width: 100%; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: var(--sw); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; position: relative; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.swatch-custom { background: conic-gradient(#f43, #fc3, #3c6, #3cf, #63f, #f3c, #f43); overflow: hidden; display: inline-block; }
.swatch-custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
#color-code { font-size: 12px; color: var(--muted); margin-left: 4px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.tpl-card.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-100); }
.tpl-thumb { display: block; border: 0; padding: 12px; background: #eceae6; cursor: zoom-in; }
.tpl-thumb img { display: block; width: 100%; aspect-ratio: 210 / 297; object-fit: cover; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); border-radius: 2px; transition: opacity .2s; }
.tpl-thumb img.wait { opacity: .35; }
.tpl-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tpl-info h3 { font-size: 15px; margin: 0; }
.tpl-info p { margin: 0; flex: 1; }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tpl-actions .btn { flex: 1; justify-content: center; }
.badge-current { background: var(--brand-50); color: var(--brand-600); }
.mark-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mark-preview { height: 96px; }
.sig-pad { width: 100%; aspect-ratio: 1200 / 440; border: 1px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.modal.modal-pdf { max-width: 920px; max-height: 92vh; }
.modal-pdf .modal-body { padding: 8px 20px; }
.pdf-modal-body { height: 74vh; }
.pdf-modal-frame { width: 100%; height: 100%; border: 0; border-radius: 8px; background: #525659; display: block; }
.tpl-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.tpl-badge b { color: var(--ink-2); }

@media (max-width: 1250px) {
  .pricing { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .plan-card.recommended { transform: none; }
}
@media (max-width: 1100px) {
  .tpl-layout { grid-template-columns: 1fr; }
  .inv-layout, .view-layout, .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .inv-side { position: static; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .pricing, .auth-plans, .plan-features { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
  .sub-banner { margin: 0 16px 12px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 4px 16px 32px; }
  .save-bar { margin: 18px -16px -32px; padding: 12px 16px; }
  .grid-2, .grid-3, .form-grid, .client-grid, .meta-row, .grid { grid-template-columns: minmax(0, 1fr) !important; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  table.items { min-width: 560px; }
  .save-bar { flex-wrap: wrap; }
  .save-bar .spacer { display: none; }
  .save-bar .btn-lg { padding: 9px 12px; font-size: 13.5px; flex: 1 1 auto; justify-content: center; }
  .bars { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
  .bar-label { font-size: 9.5px; overflow: hidden; max-width: 100%; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .items td.c-price, .items td.c-total { width: 96px; }
  .pdf-frame { height: 70vh; min-height: 420px; }
}
.swatch-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--sw); vertical-align: -1px; box-shadow: 0 0 0 1px var(--line); }
