:root {
  --navy: #18324a;
  --navy-2: #23455f;
  --forest: #567a62;
  --sage: #88a58c;
  --cream: #f4efe2;
  --canvas: #f3f5f2;
  --card: #ffffff;
  --text: #20313b;
  --muted: #6b7a82;
  --border: #dce3de;
  --danger: #b4473a;
  --warning: #b67928;
  --success: #3f704d;
  --shadow: 0 12px 35px rgba(24, 50, 74, .08);
  --radius: 18px;
  --sidebar: 246px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--canvas);
  font-family: "DM Sans", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--forest);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
h1, h2, h3, h4 { font-family: "Manrope", "Segoe UI", sans-serif; }
h1, h2, h3, h4, p { margin-top: 0; }

.button, .icon-button, .language-toggle, .text-button, .nav-item {
  border: 0;
  transition: .18s ease;
}
.button {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 11px;
  font-weight: 700;
}
.primary-button { color: white; background: var(--forest); box-shadow: 0 8px 18px rgba(86,122,98,.22); }
.primary-button:hover { background: #476b53; transform: translateY(-1px); }
.secondary-button { color: var(--navy); background: #edf1ee; border: 1px solid var(--border); }
.secondary-button:hover { background: #e5ebe7; }
.danger-button { color: white; background: var(--danger); }
.ghost-button { color: var(--navy); background: transparent; border: 1px solid var(--border); }
.small-button { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--navy);
  background: white;
  border: 1px solid var(--border);
}
.text-button { padding: 5px 0; color: #c8d4db; background: transparent; text-align: left; }
.text-button:hover { color: white; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  background: var(--navy);
}
.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 7vw, 110px);
  color: white;
  background:
    linear-gradient(135deg, rgba(24,50,74,.97), rgba(24,50,74,.78)),
    radial-gradient(circle at 80% 20%, #6b9277 0, transparent 45%);
}
.login-brand::after {
  content: "";
  position: absolute;
  right: -140px;
  bottom: -190px;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  box-shadow: 0 0 0 80px rgba(255,255,255,.025), 0 0 0 160px rgba(255,255,255,.02);
}
.login-brand > * { position: relative; z-index: 1; }
.login-brand h1 { max-width: 700px; margin: 24px 0 18px; font-size: clamp(42px, 6vw, 78px); line-height: 1.02; letter-spacing: -.04em; }
.login-copy { max-width: 620px; color: #d5e0e5; font-size: 18px; line-height: 1.65; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--navy);
  background: var(--cream);
  font-family: "Manrope", sans-serif;
  font-size: 22px;
  font-weight: 800;
}
.brand-mark.large { width: 64px; height: 64px; border-radius: 18px; font-size: 34px; }
.login-features { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 36px; }
.login-features span { padding: 9px 13px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: #dce6ea; font-size: 13px; }
.login-card {
  align-self: center;
  width: min(440px, calc(100% - 50px));
  margin: auto;
  padding: 38px;
  border-radius: 24px;
  background: white;
  box-shadow: 0 24px 70px rgba(0,0,0,.24);
}
.login-card h2 { margin-bottom: 10px; color: var(--navy); font-size: 30px; }
.login-card > p:not(.eyebrow):not(.privacy-note) { color: var(--muted); line-height: 1.55; }
.google-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 11px; margin: 22px 0 10px; color: #273641; background: white; border: 1px solid #cfd7dc; }
.google-button:hover { border-color: #9eabb3; box-shadow: 0 7px 18px rgba(32,49,59,.09); }
.google-g { display: grid; place-items: center; width: 23px; height: 23px; color: #4285f4; font-size: 18px; font-weight: 800; }
.login-card .secondary-button { width: 100%; margin-bottom: 10px; }
.allowed-account { display: flex; align-items: flex-start; gap: 9px; margin-top: 18px; padding: 12px; border-radius: 10px; color: var(--muted); background: #f3f6f4; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.status-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #6fa47d; box-shadow: 0 0 0 4px rgba(111,164,125,.12); }
.privacy-note { margin: 18px 0 0; color: #89949a; font-size: 11px; text-align: center; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: white;
  background: var(--navy);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-family: "Manrope"; font-size: 15px; }
.sidebar-brand span { margin-top: 2px; color: #9eb1bc; font-size: 11px; }
.main-nav { display: grid; gap: 5px; margin-top: 20px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border-radius: 10px; color: #b9c9d1; background: transparent; text-align: left; }
.nav-item span { width: 24px; font-size: 19px; text-align: center; }
.nav-item b { font-size: 13px; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: var(--forest); box-shadow: 0 8px 22px rgba(0,0,0,.15); }
.sidebar-footer { margin-top: auto; padding: 15px 9px 0; border-top: 1px solid rgba(255,255,255,.09); }
.sync-state { display: flex; gap: 9px; align-items: center; margin-bottom: 10px; color: #b9c9d1; font-size: 11px; }
.sync-state .status-dot { margin: 0; }

.main-content { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 14px 28px;
  background: rgba(243,245,242,.91);
  border-bottom: 1px solid rgba(220,227,222,.8);
  backdrop-filter: blur(14px);
}
.topbar h1 { margin: 0; color: var(--navy); font-size: 25px; letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.language-toggle { min-height: 38px; padding: 8px 11px; border-radius: 9px; color: var(--navy); background: white; border: 1px solid var(--border); font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 190px; padding-left: 8px; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; color: white; background: var(--navy); font-size: 12px; font-weight: 800; }
.user-chip strong, .user-chip span { display: block; }
.user-chip strong { font-size: 12px; }
.user-chip span { max-width: 155px; margin-top: 1px; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }

.view { width: min(1540px, 100%); margin: 0 auto; padding: 24px 28px 52px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.section-heading h2, .section-heading h3 { margin-bottom: 2px; color: var(--navy); }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 4px 16px rgba(24,50,74,.035);
}
.card.no-padding { padding: 0; overflow: hidden; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { position: relative; overflow: hidden; min-height: 142px; }
.stat-card::after { content: ""; position: absolute; right: -22px; bottom: -30px; width: 95px; height: 95px; border-radius: 50%; background: rgba(86,122,98,.07); }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.stat-value { margin: 14px 0 6px; color: var(--navy); font-family: "Manrope"; font-size: 29px; font-weight: 700; }
.stat-note { color: var(--muted); font-size: 11px; }
.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }
.warning { color: var(--warning) !important; }
.dashboard-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 16px; }
.activity-list, .project-list { display: grid; gap: 0; }
.activity-row, .project-row, .customer-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid #edf0ee;
}
.activity-row { grid-template-columns: 40px 1fr auto; }
.activity-row:last-child, .project-row:last-child, .customer-row:last-child { border-bottom: 0; }
.activity-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--navy); background: #edf2ef; font-weight: 800; }
.activity-row strong, .activity-row span { display: block; }
.activity-row strong { font-size: 13px; }
.activity-row span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.activity-row time { color: var(--muted); font-size: 10px; }
.progress-track { height: 8px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #edf1ee; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--forest); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; }
.search-box input { padding-left: 38px; }
.search-box::before { content: "⌕"; position: absolute; left: 13px; top: 9px; color: var(--muted); font-size: 18px; }
.field, .field-grid { min-width: 0; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--text);
  background: white;
  border: 1px solid #cfd8d2;
  border-radius: 9px;
  outline: none;
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(86,122,98,.12); }
.filter-select { width: auto; min-width: 145px; }

.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 11px 13px; color: var(--muted); background: #f6f8f6; font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 13px; border-top: 1px solid #edf0ee; font-size: 12px; vertical-align: middle; }
.data-table tbody tr { transition: .15s ease; }
.data-table tbody tr:hover { background: #fafcfb; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { margin-top: 3px; color: var(--muted); }
.align-right { text-align: right !important; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.table-action { padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; color: var(--navy); background: white; font-size: 11px; font-weight: 700; }
.table-action:hover { background: #edf2ef; }
.table-action.danger-action { color: var(--danger); }
.table-action.danger-action:hover { background: #f8eae8; }
.source-reference { display: block; margin-top: 4px; color: #496c89 !important; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.draft, .badge.unpaid { color: #777f83; background: #eef0f1; }
.badge.sent, .badge.active { color: #496c89; background: #eaf1f6; }
.badge.approved, .badge.paid, .badge.completed { color: #3f704d; background: #e9f2eb; }
.badge.rejected, .badge.void { color: #a44439; background: #f6e9e7; }
.badge.partially-paid, .badge.on-hold { color: #9b6a26; background: #f7efe1; }

.split-layout { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.6fr); gap: 14px; }
.customer-list { max-height: calc(100vh - 220px); overflow: auto; }
.customer-row { grid-template-columns: 42px 1fr auto; padding: 12px; border-radius: 11px; cursor: pointer; }
.customer-row:hover, .customer-row.selected { background: #eef3ef; }
.customer-initial { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: white; background: var(--navy-2); font-size: 12px; font-weight: 800; }
.customer-row strong, .customer-row span { display: block; }
.customer-row strong { font-size: 13px; }
.customer-row span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.count-pill { min-width: 26px; padding: 4px 7px; border-radius: 999px; color: var(--forest); background: white; font-size: 10px; font-weight: 800; text-align: center; }
.customer-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.customer-detail-header h2 { margin-bottom: 6px; color: var(--navy); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.project-row { grid-template-columns: 1.2fr 1.5fr auto auto; }
.project-row > div { min-width: 0; }
.project-row strong, .project-row span, .project-row small { display: block; }
.project-row .badge { display: inline-flex; }
.project-row small { margin-top: 4px; color: var(--muted); }
.customer-folder { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.customer-file-list { display: grid; gap: 8px; }
.customer-file-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 11px; border: 1px solid var(--border); border-radius: 12px; background: #f8faf8; }
.file-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: white; background: var(--navy-2); font-size: 9px; font-weight: 800; }
.file-copy strong, .file-copy span, .file-copy small { display: block; overflow: hidden; text-overflow: ellipsis; }
.file-copy strong { color: var(--navy); font-size: 12px; white-space: nowrap; }
.file-copy span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.file-copy small { margin-top: 4px; color: #64747c; font-size: 10px; }
.file-link { display: inline-flex; align-items: center; text-decoration: none; }
.folder-empty { padding: 20px; border: 1px dashed #cbd5cf; border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }

.empty-state { padding: 50px 25px; color: var(--muted); text-align: center; }
.empty-state .empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; color: var(--forest); background: #eaf1eb; font-size: 24px; }
.empty-state h3 { margin-bottom: 7px; color: var(--navy); }
.empty-state p { max-width: 420px; margin: 0 auto 18px; font-size: 13px; line-height: 1.55; }

.finance-summary { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 9px; margin-bottom: 14px; }
.finance-card { padding: 13px; border-radius: 14px; background: white; border: 1px solid var(--border); }
.finance-card span, .finance-card strong { display: block; }
.finance-card span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.finance-card strong { margin-top: 7px; color: var(--navy); font-family: "Manrope"; font-size: 17px; }
.finance-card.profit { background: var(--navy); border-color: var(--navy); }
.finance-card.profit span { color: #b7c7cf; }
.finance-card.profit strong { color: white; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(10,25,36,.58); backdrop-filter: blur(5px); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 20px; background: white; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.modal.wide { width: min(1040px, 100%); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: white; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; color: var(--navy); font-size: 20px; }
.modal-body { padding: 20px; }
.modal-footer { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: white; border-top: 1px solid var(--border); }
.unsaved-confirm-backdrop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; background: rgba(10,25,36,.68); }
.unsaved-confirm { width: min(520px, 100%); padding: 24px; border-radius: 18px; background: white; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.unsaved-confirm h3 { margin: 0 0 8px; color: var(--navy); font-size: 20px; }
.unsaved-confirm p { margin: 0; color: var(--muted); line-height: 1.55; }
.unsaved-confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.form-section { margin-bottom: 20px; }
.form-section h3 { margin-bottom: 10px; color: var(--navy); font-size: 14px; }
.line-items { display: grid; gap: 9px; }
.line-item { display: grid; grid-template-columns: minmax(170px,2fr) .65fr .65fr .8fr .9fr auto; gap: 7px; align-items: end; padding: 10px; border-radius: 12px; background: #f5f7f5; }
.line-item .catalog-picker { grid-column: 1 / -1; }
.line-item .description-field { grid-column: 1 / -2; }
.line-amount { min-height: 55px; display: flex; flex-direction: column; justify-content: center; padding: 7px 10px; border-radius: 9px; background: var(--navy); color: white; text-align: right; }
.line-amount span { color: #b9cbd4; font-size: 9px; text-transform: uppercase; }
.line-amount strong { margin-top: 4px; font-size: 14px; white-space: nowrap; }
.remove-line { width: 34px; height: 34px; align-self: end; border: 0; border-radius: 8px; color: var(--danger); background: #f8eae8; font-size: 18px; }
.section-editor { margin-bottom: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 14px; }
.section-editor-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.section-editor-head input { font-weight: 700; }
.totals-panel { width: min(360px,100%); margin: 17px 0 0 auto; padding: 14px; border-radius: 13px; background: var(--navy); color: white; }
.total-row { display: flex; justify-content: space-between; gap: 15px; padding: 5px 0; color: #c5d2d9; font-size: 12px; }
.total-row.grand { margin-top: 6px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,.16); color: white; font-size: 16px; font-weight: 800; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #f4f7f5; color: var(--navy); font-size: 13px; font-weight: 700; }
.check-row input { width: 20px; height: 20px; min-height: 0; accent-color: var(--green); }
.catalog-list, #estimate-payments { display: grid; gap: 9px; }
.catalog-row { display: grid; grid-template-columns: 1.1fr 1.6fr .55fr .65fr 34px; gap: 8px; align-items: end; }
.payment-editor-row { display: grid; grid-template-columns: 1fr .45fr .7fr 1.25fr 34px; gap: 8px; align-items: end; padding: 10px; border-radius: 12px; background: #f5f7f5; }
.payment-calculated { min-height: 55px; display: flex; flex-direction: column; justify-content: center; padding: 7px 10px; border-radius: 9px; background: var(--navy); color: white; text-align: right; }
.payment-calculated span { color: #b9cbd4; font-size: 9px; text-transform: uppercase; }
.payment-calculated strong { margin-top: 4px; font-size: 14px; }
.payment-editor-row input[readonly] { color: var(--navy); background: #e8eeea; font-weight: 700; }
.payment-milestone-field textarea { min-height: 55px; resize: none; line-height: 1.35; }
.payment-check { display: flex; justify-content: flex-end; gap: 13px; margin-top: 10px; font-size: 12px; }
.payment-check.valid strong { color: var(--green); }
.payment-check.invalid strong { color: var(--danger); }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 200; max-width: min(390px, calc(100% - 40px)); padding: 12px 16px; border-radius: 12px; color: white; background: var(--navy); box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.print-root { display: none; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .finance-summary { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .user-chip { display: none; }
}

@media (max-width: 900px) {
  :root { --sidebar: 228px; }
  .mobile-only { display: inline-grid; place-items: center; }
  .sidebar { transform: translateX(-105%); box-shadow: 18px 0 45px rgba(0,0,0,.2); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { min-height: 45vh; padding: 50px 30px; }
  .login-brand h1 { font-size: 45px; }
  .login-card { margin: 35px auto; }
  .dashboard-grid, .split-layout { grid-template-columns: 1fr; }
  .customer-list { max-height: 360px; }
  .field-grid.three { grid-template-columns: 1fr 1fr; }
  .project-row { grid-template-columns: 1fr auto; }
  .project-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .project-row > :nth-child(3) { grid-column: 2; grid-row: 1; }
  .project-row > :nth-child(4) { display: flex; grid-column: 1 / -1; grid-row: 3; align-items: center; justify-content: space-between; gap: 12px; }
  .customer-file-row { grid-template-columns: 42px minmax(0,1fr); }
  .customer-file-row > .row-actions { grid-column: 2; justify-content: flex-start; }
  .line-item { grid-template-columns: 1fr 1fr; }
  .line-item .description-field { grid-column: 1 / -1; }
  .catalog-row { grid-template-columns: 1fr 1fr .6fr .7fr 34px; }
  .payment-editor-row { grid-template-columns: 1fr .55fr .75fr; }
  .payment-editor-row > :nth-child(4) { grid-column: 1 / -2; }
  .table-wrap table, .data-table-wrap table { min-width: 1040px; }
  .table-wrap th, .table-wrap td, .data-table-wrap th, .data-table-wrap td { white-space: nowrap; }
  .table-wrap td:nth-child(2), .data-table-wrap td:nth-child(2) { white-space: normal; min-width: 150px; }
  .table-wrap .row-actions, .data-table-wrap .row-actions { min-width: 300px; flex-wrap: wrap; }
  .table-action { white-space: nowrap; }
}

@media (max-width: 720px) {
  .topbar { min-height: 76px; padding: 11px 15px; }
  .topbar > div:nth-child(2) { flex: 1; margin-left: 10px; }
  .topbar h1 { font-size: 19px; }
  .topbar .eyebrow { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .primary-button { width: 40px; min-height: 40px; padding: 0; overflow: hidden; color: transparent; }
  .topbar-actions .primary-button::after { content: "+"; display: grid; place-items: center; color: white; font-size: 22px; }
  .language-toggle { min-height: 40px; padding: 7px 9px; }
  .view { padding: 17px 14px 38px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { min-height: 122px; padding: 14px; }
  .stat-value { font-size: 23px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-select { width: 100%; }
  .field-grid, .field-grid.three { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .modal-body { padding: 16px; }
  .line-item { grid-template-columns: 1fr; }
  .line-item .description-field { grid-column: auto; }
  .line-item .catalog-picker { grid-column: auto; }
  .catalog-row, .payment-editor-row { grid-template-columns: 1fr; padding: 10px; border-radius: 12px; background: #f5f7f5; }
  .project-row { grid-template-columns: 1fr; }
  .project-row > :nth-child(1), .project-row > :nth-child(2), .project-row > :nth-child(3), .project-row > :nth-child(4) { grid-column: 1; grid-row: auto; text-align: left !important; }
  .project-row > :nth-child(4) { align-items: flex-start; flex-direction: column; }
  .project-row .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .customer-file-row { grid-template-columns: 1fr; }
  .customer-file-row > .row-actions { grid-column: auto; }
  .file-icon { display: none; }
  .catalog-row .remove-line, .payment-editor-row .remove-line { justify-self: end; }
  .payment-editor-row > :nth-child(4) { grid-column: auto; }
  .login-brand { min-height: 38vh; padding: 36px 24px; }
  .login-brand h1 { margin-top: 17px; font-size: 37px; }
  .login-copy { font-size: 14px; }
  .login-features { margin-top: 18px; }
  .login-card { width: calc(100% - 28px); margin: 14px auto; padding: 26px 21px; }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: 1fr; }
  .finance-summary { grid-template-columns: 1fr 1fr; }
  .login-features span:nth-child(2) { display: none; }
}

@media print {
  @page { size: Letter; margin: .55in; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; color: #1d2d36; background: white; }
  .print-document { position: relative; width: 100%; }
  .print-watermark { position: fixed; z-index: 0; top: 42%; left: 9%; width: 82%; transform: rotate(-32deg); color: var(--pdf-color); font-size: 58px; font-weight: 800; letter-spacing: 4px; text-align: center; opacity: .075; }
  .print-watermark-secondary { top: 68%; font-size: 34px; opacity: .045; }
  .print-status-watermark { position: fixed; z-index: 0; top: 40%; left: 7%; width: 86%; transform: rotate(-30deg); font-size: 76px; font-weight: 900; letter-spacing: 8px; text-align: center; opacity: .07; }
  .print-status-paid { color: #2d7a52; }
  .print-status-unpaid { color: #b24b45; }
  .print-status-partially-paid { color: #b07928; font-size: 52px; letter-spacing: 4px; }
  .print-status-void { color: #6f7478; }
  .print-document > *:not(.print-watermark):not(.print-status-watermark) { position: relative; z-index: 1; }
  .print-header { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 18px; border-bottom: 4px solid var(--pdf-color); }
  .print-company h1 { margin: 0 0 5px; color: var(--pdf-color); font-size: 24px; }
  .print-company p, .print-meta p { margin: 2px 0; color: #596a72; font-size: 9px; }
  .print-title { margin: 26px 0 18px; text-align: right; }
  .print-title h2 { margin: 0; color: var(--pdf-color); font-size: 25px; text-transform: uppercase; }
  .print-title strong { color: #567a62; font-size: 11px; }
  .print-title .source-reference { margin-top: 5px; color: var(--pdf-color) !important; font-size: 9px; }
  .print-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-bottom: 20px; }
  .print-box { padding: 11px; border: 1px solid #d9dfdb; }
  .print-box span { display: block; margin-bottom: 4px; color: #6a777e; font-size: 8px; font-weight: bold; text-transform: uppercase; }
  .print-box strong, .print-box p { margin: 2px 0; font-size: 10px; }
  .print-section-block { width: 100%; }
  .print-section-title { margin: 15px 0 5px; padding: 7px 9px; color: white; background: var(--pdf-color); font-size: 10px; text-transform: uppercase; break-after: avoid; page-break-after: avoid; }
  .print-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
  .print-table col:nth-child(1) { width: 45%; }
  .print-table col:nth-child(2) { width: 11%; }
  .print-table col:nth-child(3) { width: 9%; }
  .print-table col:nth-child(4) { width: 17%; }
  .print-table col:nth-child(5) { width: 18%; }
  .print-table th:nth-child(1), .print-table td:nth-child(1) { width: 45%; }
  .print-table th:nth-child(2), .print-table td:nth-child(2) { width: 11%; }
  .print-table th:nth-child(3), .print-table td:nth-child(3) { width: 9%; }
  .print-table th:nth-child(4), .print-table td:nth-child(4) { width: 17%; }
  .print-table th:nth-child(5), .print-table td:nth-child(5) { width: 18%; }
  .print-table th { padding: 7px; color: #56666d; background: #edf1ee; font-size: 8px; text-align: left; text-transform: uppercase; }
  .print-table td { padding: 8px 7px; border-bottom: 1px solid #e2e6e3; font-size: 9px; vertical-align: top; }
  .print-table th:not(:first-child), .print-table td:not(:first-child) { white-space: nowrap; }
  .print-table td:first-child { overflow-wrap: anywhere; }
  .print-table thead { display: table-header-group; }
  .print-table tr { break-inside: avoid; page-break-inside: avoid; }
  .print-table td small { display: block; margin-top: 3px; color: #6f7c82; }
  .print-totals { width: 275px; margin: 15px 0 0 auto; }
  .print-total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 9px; }
  .print-total-row.grand { margin-top: 5px; padding-top: 8px; border-top: 2px solid var(--pdf-color); color: var(--pdf-color); font-size: 13px; font-weight: bold; }
  .print-notes { margin-top: 20px; padding: 11px; border-left: 4px solid var(--pdf-color); background: #f5f7f5; font-size: 9px; line-height: 1.45; }
  .print-payment-block { margin-top: 20px; page-break-inside: avoid; }
  .print-payment-block > strong { color: var(--pdf-color); font-size: 11px; text-transform: uppercase; }
  .print-payment-table { width: 100%; margin-top: 7px; border-collapse: collapse; }
  .print-payment-table th { padding: 7px; color: white; background: var(--pdf-color); font-size: 8px; text-align: left; }
  .print-payment-table td { padding: 7px; border-bottom: 1px solid #e2e6e3; font-size: 8px; }
  .print-approval { margin: 24px 0 38px; padding: 14px 15px 16px; border: 1px solid #d5dfda; border-top: 4px solid var(--pdf-color); page-break-inside: avoid; break-inside: avoid; }
  .print-approval h3 { margin: 0 0 7px; color: var(--pdf-color); font-size: 11px; text-transform: uppercase; }
  .print-approval p { margin: 0; color: #4f6068; font-size: 8.5px; line-height: 1.45; }
  .print-signature-grid { display: grid; grid-template-columns: 1.65fr 1fr .65fr; gap: 18px; margin-top: 24px; }
  .print-signature-grid span { color: #6b777d; font-size: 7.5px; font-weight: bold; text-transform: uppercase; }
  .print-signature-line { height: 20px; border-bottom: 1px solid #53646c; }
  .print-layout-modern .print-box { border: 0; border-radius: 10px; background: #f1f5f2; }
  .print-layout-modern .print-section-title { border-radius: 7px; }
  .print-layout-compact { font-size: 9px; }
  .print-layout-compact .print-title { margin: 16px 0 12px; }
  .print-layout-compact .print-table td { padding: 5px 6px; }
  .print-footer { position: fixed; bottom: 0; left: 0; right: 0; padding-top: 7px; border-top: 1px solid #dce2de; color: #78858b; font-size: 8px; text-align: center; }
}
