/* ===== HYBRID GARAGE — CSS v4 (light MomoBill-style theme) ===== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { width: 100%; }
body {
  width: 100%; min-height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: #F7F9FC; color: #0F172A;
  overflow-x: hidden;
}

:root {
  --bg: #F7F9FC; --bg2: #FFFFFF; --bg3: #F1F5F9; --bg4: #E7ECF3;
  --accent: #1A56DB; --accent-light: #E8EFFD;
  --accent2: #DC2626; --accent2-light: #FDECEC;
  --accent3: #16A34A; --accent3-light: #E9F8EF;
  --accent4: #EA580C; --accent4-light: #FDF0E7;
  --text: #0F172A; --text2: #475569; --text3: #94A3B8;
  --border: #E5EAF1; --border2: #D7DEE9;
  --r: 8px; --r2: 14px;
  --font-head: 'Rajdhani', sans-serif;
  --sidebar-w: 230px;
  --topbar-h: 56px;
  --tabbar-h: 66px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow-card: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-float: 0 8px 24px rgba(26,86,219,.25);
}

/* ===== CONNECTION STATUS ===== */
.conn-status { position: fixed; top: 0; left: 0; right: 0; z-index: 9000; text-align: center; padding: 6px; font-size: 12px; font-weight: 500; }
.conn-status.offline { background: var(--accent2); color: #fff; }
.conn-status.syncing { background: var(--accent4); color: #fff; }
.conn-status.synced  { background: var(--accent3); color: #fff; }

/* ===== LOGIN ===== */
#login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #F7F9FC 0%, #EAF0FC 100%); z-index: 1000; padding: 20px; overflow-y: auto; }
.login-card { width: 100%; max-width: 380px; padding: 36px 28px; background: var(--bg2); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-card); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-logo-icon { font-size: 36px; }
.login-logo-img { height: 56px; width: auto; object-fit: contain; }
.login-brand { font-family: var(--font-head); font-size: 24px; font-weight: 700; color: var(--accent); }
.login-tagline { font-size: 12px; color: var(--text3); margin-top: 2px; }
.login-hint { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text3); }
.google-signin-btn { background: #FFFFFF; color: #3C4043; border: 1.5px solid var(--border2); display: flex; align-items: center; justify-content: center; }
.google-signin-btn:hover:not(:disabled) { background: #F7F9FC; box-shadow: 0 1px 4px rgba(15,23,42,.1); }

/* =========================================================
   APP SHELL
   ========================================================= */
#app { min-height: 100vh; min-height: 100dvh; }

/* ---- DESKTOP SIDEBAR (hidden entirely on mobile) ---- */
#sidebar { display: none; }
.brand { font-family: var(--font-head); font-size: 20px; font-weight: 700; color: var(--accent); padding: 18px 16px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.brand-logo-img { height: 30px; width: auto; object-fit: contain; }
.brand-logo-img-sm { height: 24px; width: auto; object-fit: contain; vertical-align: middle; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.user-info { overflow: hidden; }
.u-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-role { font-size: 11px; color: var(--text3); }
.icon-btn { background: none; border: none; color: var(--text3); font-size: 16px; cursor: pointer; padding: 4px; margin-left: auto; }
.icon-btn:hover { color: var(--accent2); }

nav#nav-list { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r); color: var(--text2); font-size: 13.5px; text-decoration: none; cursor: pointer; font-weight: 500; }
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.pill { margin-left: auto; background: var(--accent2); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 700; }
.ai-fab { margin: 12px; }

/* ---- MOBILE TOP BAR ---- */
#topbar-mobile {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.brand-sm { font-family: var(--font-head); font-weight: 700; color: var(--accent); font-size: 16px; }

/* ---- MAIN PAGE CONTENT ---- */
main#page { display: block; width: 100%; min-height: calc(100vh - var(--topbar-h) - var(--tabbar-h)); padding-bottom: 16px; }

/* ---- MOBILE BOTTOM TAB BAR ---- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  height: var(--tabbar-h);
  background: var(--bg2); border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  box-shadow: 0 -2px 8px rgba(15,23,42,.03);
}
.tab-link {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text3); font-size: 11px; text-decoration: none; cursor: pointer; font-weight: 500;
}
.tab-link span { font-size: 19px; }
.tab-link.active { color: var(--accent); }

/* ---- CENTER "+" FAB TAB (MomoBill-style quick invoice) ---- */
#fab-tab { flex: 0 0 64px; position: relative; justify-content: flex-start; }
.fab-icon {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 400; line-height: 1;
  box-shadow: var(--shadow-float);
  border: 4px solid var(--bg2);
}

/* ---- MOBILE "MORE" SHEET ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
  background: var(--bg2); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0; padding: 8px 16px 24px;
  display: flex; flex-direction: column; gap: 4px;
  transform: translateY(100%); transition: transform .25s ease;
  box-shadow: 0 -8px 30px rgba(15,23,42,.12);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; background: var(--border2); border-radius: 4px; margin: 8px auto 12px; }
.sheet-link { padding: 12px 8px; color: var(--text2); text-decoration: none; font-size: 14px; font-weight: 500; border-bottom: 1px solid var(--border); }
.sheet-link:last-of-type { border-bottom: none; }
#sheet-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 290; }

/* =========================================================
   DESKTOP LAYOUT — only kicks in above 900px width
   ========================================================= */
@media (min-width: 900px) {
  #app { display: flex; height: 100vh; }
  #sidebar { display: flex; flex-direction: column; width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100%; background: var(--bg2); border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; }
  #topbar-mobile { display: none; }
  #tabbar { display: none; }
  main#page { flex: 1; min-width: 0; height: 100%; overflow-y: auto; min-height: 0; padding-bottom: 0; }
  .sheet, #sheet-backdrop { display: none !important; }
}

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: var(--r); border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; white-space: nowrap; transition: background .15s, box-shadow .15s; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: #1646B8; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--bg4); }
.btn-danger { background: var(--accent2-light); color: var(--accent2); border: 1px solid #F7C9C9; }
.btn-success { background: var(--accent3-light); color: var(--accent3); border: 1px solid #BCE8CC; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; }
.btn-full { width: 100%; }

/* ===== CONTENT WRAPPER (page padding) ===== */
.page-topbar { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-wrap: wrap; row-gap: 10px; }
.page-title { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--text); }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-content { padding: 16px; }

/* ===== CARDS ===== */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); padding: 18px; box-shadow: var(--shadow-card); }
.card-flush { padding: 0; }

/* ===== STAT GRID ===== */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); padding: 14px; min-width: 0; box-shadow: var(--shadow-card); }
.stat-label { font-size: 10.5px; color: var(--text3); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.stat-value { font-family: var(--font-head); font-size: 24px; font-weight: 700; }
.stat-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }
.stat-amber .stat-value { color: var(--accent4); }
.stat-red .stat-value { color: var(--accent2); }
.stat-green .stat-value { color: var(--accent3); }
.stat-blue .stat-value { color: var(--accent); }

@media (min-width: 700px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
  .stat-value { font-size: 28px; }
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .6px; border-bottom: 1px solid var(--border); white-space: nowrap; font-weight: 700; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text2); vertical-align: middle; }
tr:hover td { background: var(--bg3); }
.td-strong { color: var(--text); font-weight: 600; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-paid { background: var(--accent3-light); color: #15803D; }
.badge-unpaid { background: var(--accent4-light); color: #C2410C; }
.badge-partially.paid, .badge-partially { background: #FEF3C7; color: #92400E; }
.badge-overdue { background: var(--accent2-light); color: #B91C1C; }
.badge-progress { background: var(--accent-light); color: #1D4ED8; }
.badge-done { background: var(--accent3-light); color: #15803D; }
.badge-waiting { background: var(--bg4); color: var(--text2); }
.badge-critical { background: var(--accent2-light); color: #B91C1C; }
.badge-low { background: var(--accent4-light); color: #C2410C; }
.badge-ok { background: var(--accent3-light); color: #15803D; }
.badge-new { background: var(--accent-light); color: #1D4ED8; }

/* ===== ALERTS ===== */
.alert { display: flex; align-items: flex-start; gap: 8px; padding: 11px 14px; border-radius: var(--r); margin-bottom: 10px; font-size: 12.5px; line-height: 1.5; }
.alert-warning { background: var(--accent4-light); border: 1px solid #F7D7BC; color: #9A3412; }
.alert-danger { background: var(--accent2-light); border: 1px solid #F4BFBF; color: #991B1B; }
.alert-info { background: var(--accent-light); border: 1px solid #C7D9FA; color: #1E40AF; }
.alert .btn-xs { margin-left: auto; flex-shrink: 0; }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r); padding: 9px 11px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-group textarea { resize: vertical; min-height: 70px; }
.form-full { grid-column: 1 / -1; }
.form-divider { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 12px; font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }

/* ===== SEARCH (signature 3-way customer search) ===== */
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r); padding: 8px 12px; }
.search-box input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 140px; }
@media (min-width: 600px) { .search-box input { width: 200px; } }

.find-bar { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1.5px solid var(--border2); border-radius: var(--r2); padding: 12px 14px; box-shadow: var(--shadow-card); }
.find-bar input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 14px; }
.find-bar input::placeholder { color: var(--text3); }
.find-bar-icon { font-size: 17px; color: var(--text3); }
.find-modes { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.find-mode-tag { font-size: 11px; color: var(--text3); background: var(--bg3); padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.find-mode-tag.match { background: var(--accent-light); color: var(--accent); }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-item { padding: 9px 16px; color: var(--text2); font-size: 13px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== MISC ===== */
.tag { display: inline-block; padding: 2px 7px; background: var(--bg3); border-radius: 4px; font-size: 11px; color: var(--text2); font-weight: 600; }
.stock-bar { height: 5px; background: var(--bg4); border-radius: 3px; overflow: hidden; margin-top: 4px; width: 70px; }
.stock-fill { height: 100%; border-radius: 3px; }
.action-btn { background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; color: var(--text2); cursor: pointer; padding: 4px 9px; font-size: 11px; font-weight: 600; }
.action-btn:hover { background: var(--bg4); color: var(--text); }
.plate-display { font-family: var(--font-head); font-size: 24px; font-weight: 700; letter-spacing: 3px; background: #FFF7E0; color: #7A5B00; padding: 7px 18px; border-radius: 6px; border: 2px solid #E8C547; display: inline-block; }
.custom-tip { background: var(--accent-light); border: 1px dashed #A9C4F5; border-radius: var(--r); padding: 12px 14px; }
.section-title { font-family: var(--font-head); font-size: 16px; font-weight: 700; color: var(--text); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }
.small-label { font-size: 11px; color: var(--text3); display: block; margin-bottom: 6px; }
.text-hint { color: var(--text3); }
.text-danger { color: var(--accent2); }
.text-success { color: var(--accent3); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; }

/* ===== GENERIC OVERLAY / MODAL / SHEET-CARD ===== */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 500; overflow-y: auto; }
#modal-root { position: fixed; inset: 0; z-index: 501; overflow-y: auto; pointer-events: none; }
#modal-root:empty { display: none; }
#modal-root > * { pointer-events: auto; }
.modal-card, .sheet-card { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); width: calc(100% - 24px); max-width: 560px; margin: 20px auto; max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 20px 60px rgba(15,23,42,.2); }
.sheet-card { max-width: 460px; }
.modal-head, .sheet-card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg2); font-family: var(--font-head); font-size: 18px; font-weight: 700; z-index: 1; }
.modal-body, .sheet-card-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ===== ITEM ROWS (job cards / estimates / invoices) — v2 ===== */
.item-ac-row { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r); padding: 8px; margin-bottom: 8px; }
.item-ac-mainline { display: grid; grid-template-columns: 2fr 90px 60px 80px 32px; gap: 6px; align-items: center; }
@media (max-width: 560px) { .item-ac-mainline { grid-template-columns: 1fr 1fr; } }
.item-ac-mainline select, .item-ac-mainline input { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r); padding: 7px; color: var(--text); font-size: 12px; outline: none; width: 100%; min-width: 0; }
.item-ac-mainline .remove-part { background: var(--accent2-light); border: 1px solid #F4BFBF; border-radius: 6px; color: var(--accent2); cursor: pointer; height: 32px; }

.item-ac-subline { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.item-ac-sublabel { font-size: 10.5px; color: var(--text3); font-weight: 600; }
.item-ac-subline input, .item-ac-subline select { background: var(--bg2); border: 1px solid var(--border2); border-radius: 6px; padding: 5px 6px; color: var(--text2); font-size: 11.5px; outline: none; width: 56px; }
.item-ac-subline select { width: 52px; }

.item-ac-wrap { position: relative; min-width: 0; align-self: start; }
.item-ac-input { width: 100%; }
.item-ac-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(15,23,42,.12); max-height: 220px; overflow-y: auto;
}
.item-ac-option { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 11px; font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--border); }
.item-ac-option:last-child { border-bottom: none; }
.item-ac-option:hover { background: var(--accent-light); }
.item-ac-meta { color: var(--text3); font-size: 11px; flex-shrink: 0; white-space: nowrap; }
.item-ac-empty { padding: 9px 11px; font-size: 12px; color: var(--text3); }


/* ===== LIVE CALC SUMMARY ===== */
.calc-summary { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; margin-top: 10px; }
.calc-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text2); padding: 2px 0; }
.calc-row.total { font-family: var(--font-head); font-size: 18px; color: var(--accent); border-top: 1px solid var(--border2); margin-top: 6px; padding-top: 7px; font-weight: 700; }

/* ===== AI PANEL ===== */
#ai-panel { position: fixed; right: 0; top: 0; bottom: 0; width: 100%; max-width: 380px; background: var(--bg2); border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 700; box-shadow: -8px 0 30px rgba(15,23,42,.1); }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ai-head-left { display: flex; align-items: center; gap: 10px; }
.ai-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-light); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.ai-title { font-weight: 700; font-size: 14px; color: var(--text); }
.ai-sub { font-size: 11px; color: var(--text3); }
#ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; }
.msg-bot .msg-bubble { background: var(--bg3); border: 1px solid var(--border); border-radius: 0 10px 10px 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; color: var(--text2); max-width: 88%; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-bubble { background: var(--accent); border-radius: 10px 0 10px 10px; padding: 10px 12px; font-size: 13px; color: #fff; max-width: 88%; }
.msg-bubble strong { color: var(--text); }
.msg-user .msg-bubble strong { color: #fff; }
.ai-chips { padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chip { background: var(--bg3); border: 1px solid var(--border2); border-radius: 20px; padding: 5px 11px; font-size: 11.5px; cursor: pointer; color: var(--text2); font-weight: 600; }
.ai-input-bar { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.ai-input-bar input { flex: 1; background: var(--bg3); border: 1px solid var(--border2); border-radius: 20px; padding: 9px 15px; color: var(--text); font-size: 13px; outline: none; }

/* ===== TOAST ===== */
#toast { position: fixed; bottom: calc(var(--tabbar-h) + 14px); left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 11px 22px; border-radius: 24px; font-size: 13px; z-index: 9999; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(15,23,42,.25); }
@media (min-width: 900px) { #toast { bottom: 24px; } }

/* ===== A4 DOCUMENT RENDERER (Invoice / Estimate / Job Card) ===== */
.doc-modal-card { max-width: 880px; }
.doc-modal-head { background: var(--bg3); }
.doc-modal-body { padding: 12px; background: var(--bg3); display: flex; justify-content: center; }
@media (min-width: 600px) { .doc-modal-body { padding: 24px; } }

.a4-page {
  background: #FFFFFF; color: #16213A;
  width: 100%; max-width: 720px;
  padding: 20px 16px;
  box-shadow: 0 4px 24px rgba(15,23,42,.12);
  border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  line-height: 1.55;
}
@media (min-width: 600px) { .a4-page { padding: 36px 32px; font-size: 13px; } }

.doc-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #1A56DB; padding-bottom: 14px; margin-bottom: 18px; gap: 10px; flex-wrap: wrap; }
.doc-brand { display: flex; align-items: flex-start; gap: 10px; min-width: 0; flex: 1; }
.doc-brand-info { min-width: 0; flex: 1; }
.doc-brand-name { font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 17px; color: #1A56DB; letter-spacing: .3px; }
@media (min-width: 600px) { .doc-logo { height: 58px; max-width: 110px; } .doc-brand-name { font-size: 21px; } }
.doc-meta { text-align: right; flex-shrink: 0; }
.doc-type { font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 19px; color: #16213A; letter-spacing: 1px; }
.doc-no { font-size: 12px; color: #475569; margin-top: 2px; font-weight: 600; }
.doc-status-wrap { margin-top: 6px; }

.doc-badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.doc-badge-paid { background: #E9F8EF; color: #15803D; }
.doc-badge-unpaid { background: #FDF0E7; color: #C2410C; }
.doc-badge-partially { background: #FEF3C7; color: #92400E; }
.doc-badge-overdue { background: #FDECEC; color: #B91C1C; }
.doc-badge-progress { background: #E8EFFD; color: #1D4ED8; }
.doc-badge-waiting { background: #F1F5F9; color: #475569; }

.doc-logo { height: 44px; width: auto; max-width: 90px; flex-shrink: 0; object-fit: contain; }
.doc-brand-line { font-size: 10px; color: #64748B; margin-top: 2px; word-break: break-word; }
@media (min-width: 600px) { .doc-brand-line { font-size: 11px; } }

.doc-parties { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.doc-party { flex: 1; min-width: 120px; }
.doc-party-right { text-align: right; }
.doc-party-label { font-size: 10px; color: #94A3B8; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-bottom: 3px; }
.doc-party-name { font-size: 15px; font-weight: 700; color: #16213A; }
.doc-party-line { font-size: 12px; color: #475569; }

.doc-services-box { background: #F7F9FC; border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; }
.doc-plate-mini { display: inline-block; margin-top: 4px; font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 1px; background: #FFF7E0; color: #7A5B00; padding: 3px 10px; border-radius: 4px; border: 1.5px solid #E8C547; }

.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.doc-table thead th { background: #F1F5F9; text-align: left; padding: 6px 8px; font-size: 9px; color: #475569; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.doc-table thead th.doc-td-num { text-align: right; }
.doc-table td { padding: 7px 8px; border-bottom: 1px solid #E5EAF1; font-size: 11px; color: #16213A; }
@media (min-width: 600px) { .doc-table thead th { padding: 8px 10px; font-size: 10px; } .doc-table td { padding: 9px 10px; font-size: 12.5px; } }
.doc-td-desc { text-align: left; }
.doc-td-num { text-align: right; white-space: nowrap; }
.doc-td-strong { font-weight: 700; }
.doc-tag-new { font-size: 9px; background: #E8EFFD; color: #1A56DB; padding: 1px 6px; border-radius: 10px; font-weight: 700; vertical-align: middle; }

.doc-totals { margin-top: 14px; margin-left: auto; width: 100%; max-width: 260px; }
.doc-total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12.5px; color: #475569; }
.doc-total-row.doc-total-meta { font-size: 11px; color: #94A3B8; }
.doc-total-grand { border-top: 2px solid #1A56DB; margin-top: 6px; padding-top: 8px; font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 18px; color: #1A56DB; }

.doc-disclaimer { font-size: 10.5px; color: #94A3B8; font-style: italic; margin-top: 16px; padding-top: 10px; border-top: 1px dashed #E5EAF1; }

/* ===== PAID WATERMARK STAMP — large, centered, behind content ===== */
.a4-page { position: relative; }
.doc-paid-stamp {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg);
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 110px; letter-spacing: 10px;
  color: rgba(22,163,74,0.14); border: 8px solid rgba(22,163,74,0.14); border-radius: 16px;
  padding: 4px 32px; z-index: 0; pointer-events: none; white-space: nowrap;
}
.a4-page > *:not(.doc-paid-stamp) { position: relative; z-index: 1; }

/* ===== PER-LINE TAX/DISCOUNT NOTE ===== */
.doc-line-note { font-size: 9.5px; color: #94A3B8; margin-top: 2px; }

/* ===== WARRANTY / TERMS BOX ===== */
.doc-warranty-box { background: #FFFBEA; border: 1px solid #F3E0A3; border-radius: 8px; padding: 12px 14px; margin-top: 18px; }
.doc-warranty-box .doc-party-label { color: #92702A; }
.doc-warranty-box .doc-party-line { font-size: 11.5px; line-height: 1.6; }

.doc-footer { margin-top: 36px; }
.doc-footer-line { border-top: 1px solid #E5EAF1; margin-bottom: 10px; }
.doc-footer-text { font-size: 12px; color: #475569; text-align: center; }
.doc-footer-meta { font-size: 9.5px; color: #B6C0CE; text-align: center; margin-top: 4px; }

/* ===== PRINT — real A4 page sizing when printing / saving as PDF ===== */
@media print {
  /* Hide everything in the app shell completely (not just visually --
     this is what was causing blank prints: visibility:hidden chains
     don't reliably survive through fixed/absolute positioned modals
     in print/PDF rendering on some browsers). */
  #login-screen, #app, #ai-panel, #toast, #conn-status { display: none !important; }

  /* Force the full modal ancestor chain into normal, visible flow */
  #modal-overlay { position: static !important; background: none !important; inset: auto !important; overflow: visible !important; }
  #modal-root { position: static !important; inset: auto !important; pointer-events: auto !important; }
  .doc-modal-card { position: static !important; box-shadow: none !important; border: none !important; max-width: none !important; width: auto !important; margin: 0 !important; max-height: none !important; overflow: visible !important; }
  .doc-modal-body { padding: 0 !important; background: #fff !important; display: block !important; }

  .no-print { display: none !important; }

  .a4-page {
    position: relative !important;
    width: 210mm; min-height: 297mm;
    box-shadow: none !important; border-radius: 0 !important;
    padding: 18mm 16mm;
    margin: 0 auto !important;
  }
  .doc-paid-stamp { position: absolute !important; }
  @page { size: A4; margin: 0; }
}

.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.settings-row:last-child { border-bottom: none; }

/* ===== INVOICE LIST ITEM (MomoBill-style compact row) ===== */
.inv-list-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inv-list-item:hover { background: var(--bg3); }
.inv-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.inv-list-main { flex: 1; min-width: 0; }
.inv-list-name { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-list-sub { font-size: 11.5px; color: var(--text3); margin-top: 1px; }
.inv-list-right { text-align: right; flex-shrink: 0; }
.inv-list-amount { font-family: var(--font-head); font-weight: 700; font-size: 15px; color: var(--text); }
