/* Admin → Invoices & Billing */
:root, .ab { --ab-blue: #2563eb; --ab-navy: #0a2540; --ab-line: #e2e8f0; --ab-muted: #64748b; --ab-bg: #f8fafc; color: #0f172a; }
.ab .muted { color: var(--ab-muted); } .ab .sm { font-size: 0.8rem; } .ab .r { text-align: right; } .ab .nowrap { white-space: nowrap; }
.ab-loading, .ab-empty { padding: 40px 16px; text-align: center; color: var(--ab-muted); }
.ab-spacer { flex: 1; }
.ab-h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.ab-h4 { margin: 24px 0 8px; font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ab-muted); }

/* tabs */
.ab-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ab-line); margin-bottom: 20px; overflow-x: auto; }
.ab-tab { background: none; border: 0; padding: 12px 16px; font: inherit; font-weight: 600; color: var(--ab-muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.ab-tab:hover { color: #0f172a; } .ab-tab.active { color: var(--ab-blue); border-bottom-color: var(--ab-blue); }

/* buttons */
.ab-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: #0f172a;
  font: inherit; font-weight: 600; font-size: 0.875rem; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
.ab-btn:hover { background: #f1f5f9; } .ab-btn:focus-visible, .ab-iconbtn:focus-visible, .ab-tab:focus-visible, .ab-filter:focus-visible { outline: 3px solid rgba(37,99,235,.35); outline-offset: 2px; }
.ab-btn svg { width: 15px; height: 15px; }
.ab-btn--primary { background: var(--ab-blue); border-color: var(--ab-blue); color: #fff; } .ab-btn--primary:hover { background: #1d4ed8; }
.ab-btn--danger { color: #b91c1c; border-color: #fecaca; } .ab-btn--danger:hover { background: #fef2f2; }
.ab-btn--ghost { border-color: transparent; background: transparent; color: var(--ab-muted); } .ab-btn--ghost:hover { background: #f1f5f9; color: #0f172a; }
.ab-btn--sm { padding: 5px 10px; font-size: 0.8rem; }
.ab-btn:disabled { opacity: .55; cursor: not-allowed; }
.ab-link { background: none; border: 0; padding: 0; color: var(--ab-blue); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.ab-link:hover { text-decoration: underline; } .ab-link svg { width: 14px; height: 14px; }
.ab-iconbtn { background: none; border: 1px solid transparent; border-radius: 8px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--ab-muted); cursor: pointer; }
.ab-iconbtn:hover { background: #f1f5f9; color: #0f172a; border-color: var(--ab-line); } .ab-iconbtn.danger:hover { color: #b91c1c; background: #fef2f2; }
.ab-iconbtn svg { width: 17px; height: 17px; }
.ab-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; color: #334155; cursor: pointer; }

/* summary cards + toolbar */
.ab-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.ab-card-stat { background: #fff; border: 1px solid var(--ab-line); border-radius: 12px; padding: 16px 18px; border-left: 4px solid #cbd5e1; }
.ab-card-stat span { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.7px; color: var(--ab-muted); font-weight: 600; }
.ab-card-stat strong { display: block; font-size: 1.45rem; margin-top: 4px; }
.ab-card-stat.good { border-left-color: #10b981; } .ab-card-stat.good strong { color: #047857; }
.ab-card-stat.bad { border-left-color: #ef4444; } .ab-card-stat.bad strong { color: #b91c1c; }
.ab-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ab-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.ab-filter { background: #fff; border: 1px solid var(--ab-line); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.82rem; font-weight: 600; color: #334155; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.ab-filter em { font-style: normal; background: #f1f5f9; border-radius: 999px; padding: 0 7px; font-size: 0.74rem; color: var(--ab-muted); }
.ab-filter.active { background: var(--ab-navy); border-color: var(--ab-navy); color: #fff; } .ab-filter.active em { background: rgba(255,255,255,.18); color: #fff; }
.ab-search { margin-left: auto; min-width: 220px; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; font-size: 0.875rem; }

/* table */
.ab-tablewrap { background: #fff; border: 1px solid var(--ab-line); border-radius: 12px; overflow: visible; overflow-x: auto; }
.ab-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.ab-table th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.7px; color: var(--ab-muted); font-weight: 700; padding: 12px 14px; background: var(--ab-bg); border-bottom: 1px solid var(--ab-line); white-space: nowrap; }
.ab-table th.r { text-align: right; }
.ab-table td { padding: 13px 14px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.ab-table tr:last-child td { border-bottom: 0; }
.ab-table .amt { font-variant-numeric: tabular-nums; font-weight: 600; } .ab-table .due { font-weight: 700; }
.ab-cust { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* row states: paid = green, void = muted + struck through, draft = dashed/muted, overdue = red */
.ab-row { cursor: pointer; transition: background .12s; } .ab-row:hover { background: #f8fafc; }
.ab-row td:first-child { border-left: 4px solid transparent; }
.ab-row--paid td:first-child { border-left-color: #10b981; } .ab-row--paid { background: #f0fdf4; } .ab-row--paid:hover { background: #e7f8ee; }
.ab-row--paid .due { color: #047857; }
.ab-row--overdue td:first-child { border-left-color: #ef4444; } .ab-row--overdue { background: #fff5f5; } .ab-row--overdue:hover { background: #ffecec; }
.ab-row--overdue .due { color: #b91c1c; }
.ab-row--pending td:first-child { border-left-color: #f59e0b; }
.ab-row--draft { background: repeating-linear-gradient(135deg, #fff, #fff 8px, #f8fafc 8px, #f8fafc 16px); color: #475569; } .ab-row--draft td:first-child { border-left: 4px dashed #94a3b8; }
.ab-row--void { background: #f1f5f9; color: #94a3b8; } .ab-row--void td:first-child { border-left-color: #cbd5e1; }
.ab-row--void .amt, .ab-row--void strong, .ab-row--void .ab-cust { text-decoration: line-through; color: #94a3b8; }
.ab-row--void .due { text-decoration: none; }
.ab-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.ab-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ab-pill--paid { background: #dcfce7; color: #15803d; } .ab-pill--pending { background: #fef3c7; color: #b45309; }
.ab-pill--overdue { background: #fee2e2; color: #b91c1c; } .ab-pill--draft { background: #e2e8f0; color: #475569; } .ab-pill--void { background: #e2e8f0; color: #64748b; text-decoration: line-through; }

/* row menu */
.ab-menu { position: relative; display: inline-block; vertical-align: middle; }
.ab-menu-list { position: absolute; right: 0; top: 100%; z-index: 50; min-width: 170px; background: #fff; border: 1px solid var(--ab-line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.16); padding: 6px; text-align: left; }
.ab-menu-list[hidden] { display: none; }
.ab-menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px; border-radius: 6px; font: inherit; font-size: 0.85rem; cursor: pointer; color: #0f172a; }
.ab-menu-item:hover { background: #f1f5f9; } .ab-menu-item.danger { color: #b91c1c; } .ab-menu-item.danger:hover { background: #fef2f2; }

/* overlays: modal + drawer */
.ab-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: abFade .15s ease-out; }
.ab-overlay--right { justify-content: flex-end; align-items: stretch; padding: 0; }
.ab-modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(15,23,42,.3); animation: abPop .18s ease-out; }
.ab-modal.wide { max-width: 900px; }
.ab-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--ab-line); }
.ab-modal-head h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.ab-x { background: none; border: 0; font-size: 1.7rem; line-height: 1; color: var(--ab-muted); cursor: pointer; padding: 0 4px; } .ab-x:hover { color: #0f172a; }
.ab-modal-body { padding: 20px 22px; overflow-y: auto; }
.ab-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--ab-line); background: var(--ab-bg); border-radius: 0 0 14px 14px; }
.ab-drawer { background: #f1f5f9; width: min(860px, 100%); height: 100%; display: flex; flex-direction: column; animation: abSlide .22s ease-out; box-shadow: -16px 0 48px rgba(15,23,42,.25); }
.ab-drawer .ab-modal-head { background: #fff; } .ab-drawer-body { padding: 20px 22px 40px; overflow-y: auto; }
.ab-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ab-docwrap { margin: 16px 0; } .ab-docwrap .iv-doc { box-shadow: 0 4px 24px rgba(15,23,42,.08); }
.ab-note { border-radius: 10px; padding: 11px 14px; font-size: 0.875rem; margin-bottom: 10px; }
.ab-note.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; } .ab-note.bad { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.ab-timeline { list-style: none; margin: 0; padding: 0; } .ab-timeline li { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.ab-timeline .dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; margin-top: 6px; flex-shrink: 0; }
.ab-timeline .dot.paid { background: #10b981; } .ab-timeline .dot.sent, .ab-timeline .dot.reminder { background: #2563eb; } .ab-timeline .dot.void, .ab-timeline .dot.email_failed { background: #ef4444; }

/* forms */
.ab-field { margin-bottom: 14px; } .ab-field label, .ab-lab { display: block; font-size: 0.8rem; font-weight: 600; color: #334155; margin-bottom: 5px; }
.ab input:not([type=checkbox]), .ab select, .ab textarea, .ab-modal input:not([type=checkbox]), .ab-modal select, .ab-modal textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; font-size: 0.9rem; background: #fff; color: #0f172a; box-sizing: border-box; }
.ab input:focus, .ab select:focus, .ab textarea:focus, .ab-modal input:focus, .ab-modal select:focus, .ab-modal textarea:focus { outline: 0; border-color: var(--ab-blue, #2563eb); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.ab input:disabled { background: #f1f5f9; color: #64748b; }
.ab-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .ab-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ab-formerr { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 8px; padding: 10px 12px; font-size: 0.875rem; margin: 10px 0; } .ab-formerr[hidden] { display: none; }
.ab-formcard { background: #fff; border: 1px solid var(--ab-line); border-radius: 12px; padding: 24px; max-width: 820px; }

/* editor */
.ab-edhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.ab-edhead h2 { margin: 4px 0 0; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.3px; }
.ab-link.back { margin-bottom: 4px; } .ab-link.back svg { width: 16px; height: 16px; }
.ab-edactions { display: flex; gap: 10px; flex-wrap: wrap; }
.ab-bizstrip { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff; border: 1px solid var(--ab-line); border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; font-size: 0.875rem; color: #334155; }
.ab-doc { background: #fff; border: 1px solid var(--ab-line); border-radius: 14px; padding: 28px; box-shadow: 0 4px 24px rgba(15,23,42,.05); }
.ab-top { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; margin-bottom: 28px; }
.ab-clientrow { display: flex; gap: 10px; } .ab-clientrow select { flex: 1; }
.ab-clientcard { margin-top: 12px; padding: 12px 14px; background: var(--ab-bg); border: 1px solid var(--ab-line); border-radius: 10px; font-size: 0.9rem; display: grid; gap: 2px; }
.ab-chip { margin: 6px 0; background: #eff6ff; color: #1d4ed8; border-radius: 8px; padding: 5px 9px; font-size: 0.78rem; font-weight: 600; }
.ab-meta { display: grid; gap: 10px; align-content: start; }
.ab-row2 { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; font-size: 0.85rem; font-weight: 600; color: #334155; } .ab-row2 span { text-align: right; }
.ab-itemshead { display: flex; justify-content: space-between; padding: 12px 14px; background: #eef2f7; border-radius: 10px 10px 0 0; font-size: 0.8rem; font-weight: 700; color: #334155; text-transform: uppercase; letter-spacing: .6px; }
.ab-item { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: start; padding: 14px; border-bottom: 1px solid var(--ab-line); }
.ab-item-main { display: grid; gap: 8px; } .ab-item-main .ab-prod { color: #475569; font-size: 0.82rem; }
.ab-item-nums { display: flex; gap: 10px; align-items: flex-start; }
.ab-mini { display: grid; gap: 4px; width: 100px; } .ab-mini span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .6px; color: var(--ab-muted); font-weight: 700; }
.ab-mini input { text-align: right; } .ab-mini.amount { width: 110px; text-align: right; } .ab-mini.amount strong { padding-top: 9px; font-variant-numeric: tabular-nums; }
.ab-item-tools { display: flex; flex-direction: column; gap: 2px; }
.ab-link.add { margin: 14px; font-size: 0.95rem; }
.ab-bottom { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; padding-top: 20px; border-top: 1px solid var(--ab-line); margin-top: 6px; }
.ab-sums { display: grid; gap: 8px; align-content: start; }
.ab-sumrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.95rem; } .ab-sumrow[hidden] { display: none; }
.ab-sumrow strong { font-variant-numeric: tabular-nums; }
.ab-sumrow.total { border-top: 2px solid #cbd5e1; padding-top: 12px; margin-top: 4px; font-size: 1.15rem; font-weight: 800; }
.ab-inline { display: inline-flex; gap: 8px; align-items: center; } .ab-inline input { width: 90px; } .ab-inline select { width: auto; }
.ab-sumlinks { display: flex; gap: 18px; justify-content: flex-end; font-size: 0.9rem; }

/* toasts */
#abToasts { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: grid; gap: 8px; }
.ab-toast { background: #0a2540; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 12px 32px rgba(15,23,42,.3); font-size: 0.9rem; max-width: 380px; animation: abPop .2s ease-out; transition: opacity .3s, transform .3s; }
.ab-toast.error { background: #991b1b; } .ab-toast.out { opacity: 0; transform: translateY(8px); }

@keyframes abFade { from { opacity: 0; } } @keyframes abPop { from { opacity: 0; transform: translateY(8px) scale(.98); } } @keyframes abSlide { from { transform: translateX(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ab-overlay, .ab-modal, .ab-drawer, .ab-toast { animation: none; } }
@media (max-width: 900px) {
  .ab-cards { grid-template-columns: repeat(2, 1fr); } .ab-top, .ab-bottom { grid-template-columns: 1fr; }
  .ab-item { grid-template-columns: 1fr; } .ab-item-nums { flex-wrap: wrap; } .ab-item-tools { flex-direction: row; }
  .ab-grid2, .ab-grid3 { grid-template-columns: 1fr; } .ab-search { margin-left: 0; width: 100%; } .ab-row2 { grid-template-columns: 120px 1fr; }
}

/* blog editor + moderation cards */
.ab-row--paid-lite td:first-child { border-left: 4px solid #10b981; }
.ab-rte { border: 1px solid #cbd5e1; border-radius: 10px; overflow: hidden; background: #fff; }
.ab-rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--ab-bg); border-bottom: 1px solid var(--ab-line); align-items: center; }
.ab-rte-bar .ab-iconbtn { width: auto; min-width: 34px; padding: 0 9px; font-size: 0.85rem; font-weight: 600; }
.ab-rte-body { min-height: 340px; max-height: 70vh; overflow-y: auto; padding: 18px 20px; font-size: 1rem; line-height: 1.7; outline: 0; }
.ab-rte-body:focus { box-shadow: inset 0 0 0 2px rgba(37,99,235,.25); }
.ab-rte-body h2, .ab-prose h2 { font-size: 1.35rem; margin: 1.2em 0 .4em; color: #0a2540; } .ab-rte-body h3, .ab-prose h3 { font-size: 1.1rem; margin: 1em 0 .3em; color: #0a2540; }
.ab-rte-body ul, .ab-rte-body ol, .ab-prose ul, .ab-prose ol { padding-left: 1.4em; } .ab-rte-body blockquote, .ab-prose blockquote { border-left: 3px solid #cbd5e1; margin: 1em 0; padding-left: 14px; color: #475569; }
.ab-rte-html { width: 100%; min-height: 340px; border: 0 !important; border-radius: 0 !important; font-family: ui-monospace, Menlo, Consolas, monospace !important; font-size: 0.85rem !important; }
.ab-subcard { background: #fff; border: 1px solid var(--ab-line); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; }
.ab-subhead { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ab-subcard details { margin-top: 8px; } .ab-prose { margin-top: 10px; line-height: 1.7; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--ab-line); padding-top: 10px; }
.ab-prevframe { width: 100%; height: 60vh; border: 1px solid var(--ab-line); border-radius: 8px; }

/* layout fixes */
.ab .ab-search { width: auto; flex: 0 1 300px; margin-left: auto; min-width: 180px; }
.ab-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; } .ab-tabs::-webkit-scrollbar { display: none; }
