/* =========================================================
   QuoteForge — Bushido Precision Design System
   Tech Samurai Consulting LLC
   ========================================================= */

:root {
  /* Colors — surface */
  --surface: #f9f9ff;
  --surface-bright: #ffffff;
  --surface-dim: #d3daef;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f1f3ff;
  --surface-container: #e9edff;
  --surface-container-high: #e1e8fd;
  --surface-container-highest: #dce2f7;

  /* Colors — text */
  --on-surface: #141b2b;
  --on-surface-variant: #44474e;
  --inverse-surface: #293040;
  --inverse-on-surface: #edf0ff;

  /* Colors — outline */
  --outline: #75777f;
  --outline-variant: #c5c6cf;

  /* Colors — primary (deep navy) */
  --primary: #031534;
  --primary-soft: #1A2A4A;
  --primary-hover: #0a2148;
  --on-primary: #ffffff;
  --primary-container: #1a2a4a;
  --on-primary-container: #8292b7;
  --primary-fixed: #d8e2ff;
  --primary-fixed-dim: #b7c6ee;

  /* Colors — secondary (samurai red) */
  --secondary: #b02d21;
  --secondary-hover: #8d2419;
  --on-secondary: #ffffff;
  --secondary-soft: #C0392B;
  --secondary-container: #fc6451;
  --on-secondary-container: #650001;

  /* Colors — tertiary (consultant blue) */
  --tertiary: #001825;
  --on-tertiary: #ffffff;
  --tertiary-container: #002e42;
  --on-tertiary-container: #6198b9;
  --consultant-blue: #1F5C7A;

  /* Colors — semantic */
  --success: #2E7D32;
  --success-bg: #E8F5E9;
  --warning: #B26A00;
  --warning-bg: #FFF4E5;
  --error: #ba1a1a;
  --error-bg: #ffdad6;
  --info: #1F5C7A;
  --info-bg: #E1EEF7;

  /* Colors — financial */
  --internal-bg: #FFFBEB;
  --internal-border: #F59E0B;
  --internal-text: #92400e;

  /* Colors — neutrals */
  --bg: #F5F6F8;
  --border: #E5E7EB;
  --row-hover: #F9FAFB;
  --table-stripe: #F8FAFC;

  /* Typography */
  --font-heading: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
  --font-body: 'Work Sans', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Mono', 'Consolas', monospace;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --drawer-width: 480px;
  --content-max-width: 1440px;

  /* Radius */
  --radius-sm: 0.125rem;
  --radius: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-3: 0 12px 24px rgba(15, 23, 42, 0.10);
  --shadow-4: 0 20px 48px rgba(15, 23, 42, 0.18);

  /* Animations */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======================== Reset / base ======================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--consultant-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--on-surface);
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--on-surface);
}

.mono, .ref, .currency-num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* ======================== App shell ======================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface-container-lowest);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-brand-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.sidebar-brand-tagline {
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  color: var(--on-surface-variant);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Tech Samurai logo lockup at the bottom of the sidebar (lift-and-shift from the top). */
.sidebar-footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-6) var(--space-4);
}
.sidebar-footer-logo {
  display: block;
  width: 100%;
  max-width: 168px;
  height: auto;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--on-surface-variant);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  text-decoration: none;
  position: relative;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.sidebar-nav-item:hover {
  background: var(--surface-container-low);
  color: var(--on-surface);
  text-decoration: none;
}
.sidebar-nav-item.active {
  background: #fdecea;
  color: var(--secondary);
  font-weight: 600;
}
.sidebar-nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--secondary);
  border-radius: var(--radius-full);
}
.sidebar-nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-cta {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}
.sidebar-cta .btn { width: 100%; justify-content: center; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface-container-lowest);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  gap: var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
}

.search-wrap {
  flex: 0 1 480px;
  max-width: 560px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-4) 0 36px;
  background: var(--surface-container-low);
  font-size: 13px;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--consultant-blue);
  background: var(--surface-bright);
  box-shadow: 0 0 0 2px rgba(31, 92, 122, 0.14);
}
.search-wrap .icon-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--on-surface-variant);
  pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: var(--space-4); }

.topbar-icon-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--on-surface-variant);
  position: relative;
}
.topbar-icon-btn:hover { background: var(--surface-container-low); color: var(--on-surface); }
.topbar-icon-btn .badge-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--secondary);
  border-radius: var(--radius-full);
  border: 2px solid var(--surface-container-lowest);
}

.topbar-user {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 4px 8px 4px var(--space-4);
  border: none;
  border-left: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: background 120ms var(--ease);
}
.topbar-user:hover { background: var(--surface-container-low); }
.topbar-user-meta { display: flex; flex-direction: column; align-items: flex-end; }
.topbar-user-name { font-weight: 600; font-size: 13px; color: var(--on-surface); }
.topbar-user-role { font-size: 11px; color: var(--on-surface-variant); }
.topbar-user-caret { color: var(--on-surface-variant); }

/* User menu popover */
.topbar-user-menu { width: 280px; padding: 0; }
.topbar-user-menu-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-container-low);
}
.topbar-user-menu-items { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.topbar-user-menu-form { margin: 0; padding: 0; }
.topbar-user-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--on-surface);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.topbar-user-menu-item:hover { background: var(--surface-container-low); text-decoration: none; }
.topbar-user-menu-item .icon { color: var(--on-surface-variant); }
.topbar-user-menu-logout { color: var(--error); }
.topbar-user-menu-logout .icon { color: var(--error); }
.avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
}
.avatar.size-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar.size-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.size-xl { width: 56px; height: 56px; font-size: 18px; }

.content {
  padding: var(--space-8);
  flex: 1;
  overflow-x: hidden;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.page-title-row h1 { margin-bottom: 4px; }
.page-subtitle { color: var(--on-surface-variant); font-size: 13px; margin: 0; }

/* ======================== Buttons ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  height: 38px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease), box-shadow 120ms var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: 12px; }
.btn.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: 14px; }

.btn-primary {
  background: var(--secondary-soft);
  color: var(--on-secondary);
}
.btn-primary:hover { background: var(--secondary-hover); text-decoration: none; }

.btn-secondary {
  background: var(--surface-container-lowest);
  border-color: var(--primary-soft);
  color: var(--primary-soft);
}
.btn-secondary:hover { background: var(--primary-soft); color: var(--on-primary); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--primary-soft);
}
.btn-ghost:hover { background: var(--surface-container-low); text-decoration: none; }

.btn-dark {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-dark:hover { background: var(--primary-hover); text-decoration: none; }

.btn-danger {
  background: var(--error);
  color: var(--on-secondary);
}
.btn-danger:hover { background: #921313; text-decoration: none; }

.btn-link {
  background: transparent; border: none; padding: 0;
  color: var(--secondary-soft);
  font-weight: 600; font-size: 13px;
  cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }
.btn-link-danger {
  color: var(--error);
}
.btn-link-danger:hover { color: #921313; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--on-surface-variant);
}
.icon-btn:hover { background: var(--surface-container-low); color: var(--on-surface); }

/* ======================== Cards ======================== */
.card {
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card.flush { padding: 0; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: var(--space-5) var(--space-6); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ======================== Forms ======================== */
.form-row { display: grid; grid-template-columns: 1fr; gap: var(--space-4); }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label, label.form-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}
.form-field input,
.form-field select,
.form-field textarea,
.input, .select, .textarea {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-3);
  background: var(--surface-bright);
  font-size: 14px;
  color: var(--on-surface);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.form-field textarea, .textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.5;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--consultant-blue);
  box-shadow: 0 0 0 2px rgba(31, 92, 122, 0.14);
}

.form-help { font-size: 12px; color: var(--on-surface-variant); }
.form-error { font-size: 12px; color: var(--error); margin-top: 2px; }

.input-icon-wrap { position: relative; }
.input-icon-wrap input { padding-right: 36px; }
.input-icon-wrap .icon-tail {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--on-surface-variant); pointer-events: none;
}

.checkbox-row { display: flex; align-items: center; gap: var(--space-2); }
.checkbox-row input[type="checkbox"] { accent-color: var(--primary-soft); width: 16px; height: 16px; }

/* ======================== Tables ======================== */
.table-wrap {
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  background: var(--surface-bright);
  position: sticky;
  top: 0;
  text-align: left;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
}
.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--on-surface);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .text-right { text-align: right; }
.tbl .text-center { text-align: center; }
.tbl .num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

.table-empty {
  padding: var(--space-10);
  text-align: center;
  color: var(--on-surface-variant);
}

/* ======================== Status badge ======================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-container); color: var(--on-surface-variant); }
.badge-dark { background: var(--primary-soft); color: var(--on-primary); }

.badge-status-Approved, .badge.Approved { background: var(--success-bg); color: var(--success); }
.badge-status-Sent, .badge.Sent { background: var(--info-bg); color: var(--info); }
.badge-status-Generated, .badge.Generated { background: #FEF3C7; color: #92400e; }
.badge-status-Draft, .badge.Draft { background: var(--surface-container); color: var(--on-surface-variant); }
.badge-status-Rejected, .badge.Rejected { background: var(--error-bg); color: var(--error); }
.badge-status-Archived, .badge.Archived { background: var(--surface-container-high); color: var(--on-surface-variant); }
.badge-status-Active, .badge.Active { background: var(--success-bg); color: var(--success); }
.badge-status-Inactive, .badge.Inactive { background: var(--surface-container); color: var(--on-surface-variant); }
.badge-status-Pending, .badge.Pending { background: #FEF3C7; color: #92400e; }

.badge-tier { background: var(--primary-fixed); color: var(--primary); }

/* ======================== Toasts ======================== */
.toast-stack {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toast {
  min-width: 280px;
  max-width: 380px;
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  font-size: 13px;
  color: var(--on-surface);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slide-in 220ms var(--ease);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.info { border-left-color: var(--info); }
.toast.warning { border-left-color: var(--warning); }
.toast .toast-close {
  background: none; border: none; color: var(--on-surface-variant);
  cursor: pointer; padding: 0; margin-left: auto;
}
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ======================== Drawer ======================== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 21, 52, 0.42);
  backdrop-filter: blur(2px);
  z-index: 900;
  display: none;
}
.drawer-overlay.visible { display: block; }
.drawer {
  position: fixed;
  right: calc(-1 * var(--drawer-width));
  top: 0;
  width: var(--drawer-width);
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-bright);
  z-index: 950;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-4);
  transition: right 250ms var(--ease);
  overflow-x: hidden;
}
.drawer.open { right: 0; }
.drawer-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-title { font-family: var(--font-heading); font-size: 18px; font-weight: 700; }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-5) var(--space-6);
}
.drawer-body .form-row.cols-2,
.drawer-body .form-row.cols-3 {
  grid-template-columns: 1fr 1fr;
}
.drawer-body .form-field { min-width: 0; }
.drawer-body input,
.drawer-body select,
.drawer-body textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.drawer-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(3,21,52,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--surface-bright);
  border-radius: var(--radius-lg);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-4);
}
.modal.large { width: min(900px, calc(100vw - 32px)); }
.modal-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); display:flex; justify-content: space-between; align-items: center; }
.modal-body { padding: var(--space-5) var(--space-6); overflow-y: auto; }
.modal-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--space-3); }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
}
.tab-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--on-surface); }
.tab-btn.active { color: var(--secondary); border-bottom-color: var(--secondary); }

/* ======================== Helpers ======================== */
.muted { color: var(--on-surface-variant); }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Dashboard metric cards */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
.metric-card {
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}
.metric-card .metric-icon-wrap {
  width: 40px; height: 40px;
  background: var(--surface-container-low);
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.metric-card .metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  margin-bottom: 4px;
}
.metric-card .metric-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--on-surface);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.metric-card .metric-trend { font-size: 11px; font-weight: 500; }
.metric-card .metric-trend.up { color: var(--success); }
.metric-card .metric-trend.down { color: var(--error); }
.metric-card .metric-trend.flat { color: var(--on-surface-variant); }

/* Filter row */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.filter-bar .form-field { flex: 1; min-width: 140px; }
.filter-bar .filter-actions { display: flex; gap: var(--space-2); align-items: flex-end; }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-bright);
  font-size: 12px;
  color: var(--on-surface-variant);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: var(--surface-bright);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  color: var(--on-surface);
}
.pagination .pages button.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pagination .pages button:hover:not(.active) { background: var(--surface-container-low); }
.pagination .pages button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Section header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}
.section-header h2, .section-header h3 { margin: 0; }

/* Login page */
body.login-bg {
  min-height: 100vh;
  background: #0a1c3a;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(31, 92, 122, 0.18), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(176, 45, 33, 0.10), transparent 50%),
    repeating-linear-gradient(45deg, #0a1c3a 0, #0a1c3a 18px, #0c2147 18px, #0c2147 19px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  color: var(--inverse-on-surface);
  font-family: var(--font-body);
}
.login-card {
  background: var(--surface-bright);
  width: min(380px, calc(100vw - 32px));
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-4);
}
.login-shield {
  width: 96px; height: 96px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.login-shield::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid #b7c6ee;
  border-radius: var(--radius);
}
.login-shield svg { position: relative; z-index: 1; }

.login-title { text-align: center; font-size: 22px; margin-bottom: 24px; color: var(--on-surface); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .field-row { display: flex; justify-content: space-between; align-items: baseline; }
.login-form .forgot { font-size: 11px; color: var(--secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.login-footer {
  margin-top: 30px; text-align: center;
  font-size: 11px; color: rgba(237, 240, 255, 0.55);
  letter-spacing: 0.04em;
  width: 100%;
}
.login-footer a { color: rgba(237, 240, 255, 0.75); text-transform: uppercase; font-size: 10px; letter-spacing: 0.18em; margin: 0 12px; }

/* ===== Quote builder subheader =====
 * Single flex row — left cluster (back · ref · status · % chip) and
 * right cluster (admin actions). The completion bar lives at the bottom
 * edge of the bar as a thin animated line, so it never has to fight the
 * title or buttons for horizontal real estate. */
.builder-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface-bright);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 60px;
}
.builder-bar h1 {
  font-size: 16px;
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  letter-spacing: 0.01em;
}
.builder-bar h1 .builder-bar-sep { color: var(--outline); margin: 0 6px; font-weight: 400; }
.builder-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.builder-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}
/* Bottom-edge progress line — animated, full-width, sits exactly on the
 * border-bottom of the subheader. Cannot collide with anything. */
.builder-bar-progress {
  position: absolute;
  left: 0; right: 0;
  bottom: -1px;             /* paint over the 1px border-bottom */
  height: 3px;
  background: transparent;
  pointer-events: none;
  overflow: hidden;
}
.builder-bar-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--secondary-soft, var(--secondary)) 100%);
  transition: width 320ms var(--ease);
  border-top-right-radius: 2px;
  border-bottom-right-radius: 2px;
}

/* Compact "57% complete" pill that lives in the left cluster instead of
 * the giant centered progress wrap. Tooltip carries the verbose
 * "Missing: ..." text. */
.completion-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-container-low);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  white-space: nowrap;
  flex-shrink: 0;
}
.completion-chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--secondary);
  box-shadow: 0 0 0 3px rgba(176, 45, 33, 0.18);
}
.completion-chip-pct {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--on-surface);
}
.completion-chip-label { color: var(--on-surface-variant); }

/* Hide the completion chip on very narrow viewports — the bottom-line
 * progress bar carries enough information by itself. */
@media (max-width: 700px) {
  .completion-chip-label { display: none; }
}
@media (max-width: 540px) {
  .completion-chip { display: none; }
}

.builder-grid {
  display: grid;
  /* Form pane gets all flexible space; the preview thumbnail is a fixed
   * narrow rail that always fits, so we never have to compete for width. */
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.builder-pane-left {
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.builder-pane-left::-webkit-scrollbar { display: none; }

/* Right pane is now a sidebar that holds the preview *thumbnail* card.
 * The full preview lives in #preview-modal, opened from the card. */
.builder-pane-right {
  background: var(--surface-container-low);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.builder-pane-right::-webkit-scrollbar { display: none; }

.builder-section { background: var(--surface-bright); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; }
.builder-section h3 { font-size: 16px; margin-bottom: 16px; }

/* Builder shell: full bleed under the topbar (no padding, no max-width)
 * so the sticky footer can span sidebar-edge to right-edge. */
:root {
  --builder-footer-height: 88px;
}
/* Lock the document while the builder is open so only the form pane can scroll. */
body.builder-open,
html:has(.content-builder) {
  overflow: hidden;
  height: 100vh;
}
body.builder-open .app-shell,
html:has(.content-builder) .app-shell {
  height: 100vh;
  min-height: 0;
}
.content.content-builder {
  padding: 0;
  max-width: none;
  margin: 0;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}
.builder-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  /* Reserve space at the bottom so the fixed footer never covers content. */
  padding-bottom: var(--builder-footer-height);
  box-sizing: border-box;
}
/* On narrow screens the right cluster shows icon-only buttons. The
 * <span class="hide-on-narrow"> labels collapse, the SVGs stay. */
.hide-on-narrow { display: inline; }
@media (max-width: 1180px) {
  .hide-on-narrow { display: none; }
  .builder-bar-right .btn-sm { padding: 0 8px; }
}
.builder-footer-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--builder-footer-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface-bright);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 20px -12px rgba(15, 23, 42, 0.22);
  gap: 16px;
  z-index: 60;
}
.builder-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.export-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 6px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  min-width: 180px;
  z-index: 100;
}
.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

/* ===== Preview thumbnail card (sidebar) =====
 * A small "always-visible" preview, modelled on Skydo's invoice builder.
 * Hover reveals the "View Quote" CTA; clicking opens #preview-modal
 * with the full-size, page-paginated quote preview.
 */
.preview-thumb-card {
  position: relative;
  width: 100%;
  max-width: 320px;
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: box-shadow 160ms var(--ease), transform 160ms var(--ease), border-color 160ms var(--ease);
  overflow: hidden;
}
.preview-thumb-card:hover,
.preview-thumb-card:focus-visible {
  box-shadow: var(--shadow-3);
  border-color: var(--primary-fixed-dim);
  transform: translateY(-1px);
  outline: none;
}
.preview-thumb-card:focus-visible {
  border-color: var(--consultant-blue);
}
.preview-thumb-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 8.5 / 11;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}
.preview-thumb-frame #preview-pane,
.preview-thumb-frame .preview-stack {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}
.preview-thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(3, 21, 52, 0.0) 0%, rgba(3, 21, 52, 0.22) 100%);
  opacity: 0;
  transition: opacity 160ms var(--ease);
  border-radius: var(--radius-lg);
  pointer-events: none;
}
.preview-thumb-card:hover .preview-thumb-overlay,
.preview-thumb-card:focus-visible .preview-thumb-overlay {
  opacity: 1;
}
.preview-thumb-cta {
  pointer-events: auto;
  box-shadow: var(--shadow-3);
}
.preview-thumb-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.preview-thumb-meta {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.preview-thumb-meta::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.16);
}

/* Below 1100px the right column gets demoted to a "preview pill" floating
 * in the form scroll area instead of taking a full grid column. */
@media (max-width: 1100px) {
  .builder-grid { grid-template-columns: minmax(0, 1fr) 280px; }
  .preview-thumb-card { max-width: 260px; padding: 10px; }
  .preview-thumb-footer { margin-top: 8px; }
}

/* ===== Preview viewer — Skydo-style minimal full-screen viewer =====
 * No header. No footer. No chrome. Just the page sheet centred in the
 * viewport with two floating dark "bubble" buttons in the top-right
 * (download menu + close) and a small pager pill at the bottom.
 */
.preview-viewer {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: none;
  align-items: center;
  justify-content: center;
}
.preview-viewer.visible { display: flex; }

.preview-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: zoom-out;
  animation: pv-fade 160ms var(--ease);
}
@keyframes pv-fade { from { opacity: 0; } to { opacity: 1; } }

/* Stage takes the full viewport with minimal margin, so the page sheet
 * grows as large as its 8.5x11 aspect ratio allows. The pager pill is
 * positioned to OVERLAP the bottom edge of the page (half on, half off)
 * which means we don't need to reserve clearance space below the sheet. */
.preview-viewer-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: pv-pop 220ms var(--ease);
}
@keyframes pv-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* The sheet wrapper carries the aspect ratio + max sizing; the inner
 * page-frame just fills it. The wrapper is `position: relative` so the
 * pager (its sibling) can absolutely-position relative to its bottom
 * edge without being clipped by the frame's overflow:hidden. */
.preview-viewer-sheet {
  position: relative;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  aspect-ratio: 8.5 / 11;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}
.preview-viewer-sheet .preview-page-frame {
  width: 100%;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  aspect-ratio: auto;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45),
              0 12px 24px -12px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
}

/* Floating action bubbles (top-right). Two dark circles with white
 * glyphs — exactly like the inspiration screenshot. */
.preview-viewer-bubbles {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
}
.preview-viewer-bubble-wrap { position: relative; }
.preview-viewer-bubble {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1a1f2e;
  color: #ffffff;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.45),
              0 2px 6px rgba(0, 0, 0, 0.25);
  transition: background 150ms var(--ease), transform 150ms var(--ease);
}
.preview-viewer-bubble:hover { background: #2a3142; transform: translateY(-1px); }
.preview-viewer-bubble:focus-visible {
  outline: 2px solid var(--consultant-blue);
  outline-offset: 2px;
}

/* Download menu — small popup that drops out of the download bubble. */
.preview-download-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: #1a1f2e;
  color: white;
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
  z-index: 3;
}
.preview-download-menu[hidden] { display: none; }
.preview-download-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 120ms var(--ease);
}
.preview-download-item:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.preview-download-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 26px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Pager pill — tiny, dark, centered. Sits OVER the bottom edge of the
 * page sheet (half on, half hanging off). Wrapped in a stretch row so
 * it can use the same width as the page-frame for true centering. */
.preview-viewer-pager {
  position: absolute;
  bottom: 0;                          /* sits flush with stage padding */
  left: 50%;
  transform: translate(-50%, 50%);    /* hang half off the page bottom */
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #1a1f2e;
  color: white;
  border-radius: var(--radius-full);
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.55),
              0 0 0 4px rgba(15, 23, 42, 0.6);
}
.preview-viewer-pager[hidden] { display: none; }
.preview-viewer-pager-label {
  min-width: 50px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 0 4px;
}
.preview-viewer-pager-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: background 120ms var(--ease);
}
.preview-viewer-pager-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.preview-viewer-pager-btn:disabled { opacity: 0.3; cursor: default; }

@media (max-width: 720px) {
  .preview-viewer-bubbles { top: 16px; right: 16px; gap: 8px; }
  .preview-viewer-bubble { width: 42px; height: 42px; }
  .preview-viewer-pager { bottom: 16px; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* ===== Footer "Quote Snapshot" chip + popover =====
 * Replaces the old multi-card .financials-summary so the footer stays
 * one row tall on every screen size. The chip shows a single headline
 * value + label; clicking it opens a popover with the full breakdown.
 */
.financials-chip-wrap {
  position: relative;
  flex: 0 0 auto;
}
.financials-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--internal-bg);
  border: 1px solid var(--internal-border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  color: var(--internal-text);
  cursor: pointer;
  transition: background 120ms var(--ease), box-shadow 120ms var(--ease);
}
.financials-chip:hover { background: #fff5dc; box-shadow: var(--shadow-1); }
.financials-chip[aria-expanded="true"] { background: #fff5dc; box-shadow: var(--shadow-2); }
.financials-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--internal-border);
  flex-shrink: 0;
}
.financials-chip-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.financials-chip-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--on-surface);
}
.financials-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-left: 3px solid var(--internal-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  padding: 12px 16px;
  z-index: 70;
  display: grid;
  gap: 12px;
}
.financials-popover[hidden] { display: none; }
.financials-popover .financials-row { line-height: 1.2; }
.financials-popover .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--internal-text);
  margin-bottom: 2px;
}
.financials-popover .value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--on-surface);
}
.financials-popover .secondary {
  font-size: 11px;
  color: var(--internal-text);
  margin-top: 2px;
}


.line-items-table th { background: var(--surface-container-low); }
.line-items-table input.inline-input,
.line-items-table input.inline-num {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--border);
  padding: 5px 6px;
  border-radius: var(--radius);
  background: var(--surface-bright);
  font-family: var(--font-mono);
  font-size: 13px;
  -moz-appearance: textfield;
}
.line-items-table input.inline-num::-webkit-outer-spin-button,
.line-items-table input.inline-num::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.line-items-table input.inline-input:hover,
.line-items-table input.inline-num:hover {
  border-color: var(--outline);
}
.line-items-table input.inline-input:focus,
.line-items-table input.inline-num:focus {
  border-color: var(--consultant-blue);
  background: var(--surface-bright);
  outline: none;
  box-shadow: 0 0 0 2px rgba(31, 92, 122, 0.14);
}
.line-items-table input.inline-input { font-family: var(--font-body); }
.line-items-table .cost-cell { color: var(--internal-text); background: rgba(245, 158, 11, 0.06); }
.line-items-table .profit-cell { font-weight: 600; }
.line-items-table tr.product-type-row td { background: var(--surface-container-low); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--on-surface-variant); padding: 8px 12px; }

/* ===== Live preview — WYSIWYG mirror of DOCX/PDF export =====
 *
 * The .pp-page elements are rendered at FIXED design dimensions
 * (PP_DESIGN_WIDTH × PP_DESIGN_HEIGHT, US-Letter @ 96dpi) so their
 * paddings, font sizes, line heights etc. stay in sensible proportion to
 * the "sheet of paper". The .preview-page-frame paints the actual visible
 * sheet and CLIPS the pages inside it; quote_builder.js measures the
 * frame's rendered width and sets `--pp-scale` so the .pp-page is scaled
 * to fit. Result: the preview always reads as a properly proportioned
 * thumbnail of an 8.5×11 sheet, no matter how narrow the right pane is.
 */
:root {
  --pp-design-width: 816px;   /* 8.5in @ 96dpi */
  --pp-design-height: 1056px; /* 11in  @ 96dpi */
  --pp-scale: 1;
}
.preview-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-page-frame {
  position: relative;
  /* The sheet fills the available vertical space, then computes its width
   * from the 8.5/11 aspect ratio. We also cap it at the available width
   * so it never overflows the right pane horizontally. */
  height: min(100%, calc(var(--pp-design-height) * 0.9));
  aspect-ratio: 8.5 / 11;
  max-width: 100%;
  background: white;
  border-radius: 2px;
  overflow: hidden; /* clip the scaled .pp-page to the sheet */
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14), 0 1px 2px rgba(0,0,0,0.06);
  font-family: 'Calibri', 'Segoe UI', sans-serif;
  color: #111;
}
.preview-page-frame #preview-pane,
.preview-page-frame .preview-stack {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.preview-stack { counter-reset: pp-page; }
.pp-page {
  counter-increment: pp-page;
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pp-design-width);
  height: var(--pp-design-height);
  transform-origin: top left;
  transform: scale(var(--pp-scale, 1));
  display: none;
  padding: 36px 38px 38px;
  box-sizing: border-box;
  font-size: 11px;
  line-height: 1.45;
  background: white;
  border-radius: 2px;
  overflow: hidden; /* per-page hard-clip — content sized for an 8.5x11 sheet */
}
.pp-page.active {
  display: block;
  animation: pp-page-fade 160ms var(--ease);
}
@keyframes pp-page-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* page header (logo bar) */
.pp-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1.5px solid #1F5C7A;
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.pp-header-left img { height: 32px; display: block; }
.pp-header-right {
  font-size: 9px;
  color: #6B7280;
  text-align: right;
  max-width: 60%;
}

/* Title (quote title) */
.pp-title {
  font-family: 'Calibri', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #1F5C7A;
  margin: 0 0 14px 0;
  line-height: 1.15;
}

/* Section heading with blue rule */
.pp-section {
  font-family: 'Calibri', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #1F5C7A;
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #0070C0;
}
.pp-prose { font-size: 11px; line-height: 1.5; margin-bottom: 8px; white-space: pre-line; }

/* Prepared-for header table */
.pp-prepared-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
}
.pp-prepared-table td {
  border: 1px solid #BFBFBF;
  padding: 6px 9px;
  vertical-align: top;
  font-size: 10px;
}
.pp-prepared-banner {
  background: #1F5C7A;
  color: white;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.04em;
  border-color: #1F5C7A !important;
}
.pp-meta-label {
  background: #F2F2F2;
  font-weight: 700;
  width: 18%;
}
.pp-meta-value { width: 26%; }
.pp-client-cell { width: 56%; padding: 10px 12px !important; }
.pp-client-name { font-weight: 700; font-size: 12.5px; margin-bottom: 4px; color: #111; }
.pp-client-line { font-size: 10px; line-height: 1.45; color: #111; }

/* Product table */
.pp-product-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
}
.pp-product-table th {
  background: #1F5C7A;
  color: white;
  font-weight: 700;
  font-size: 10px;
  padding: 7px 8px;
  text-align: left;
  border: 1px solid #1F5C7A;
}
.pp-product-table th.text-right { text-align: right; }
.pp-product-table th.text-center { text-align: center; }
.pp-product-table td {
  padding: 6px 8px;
  border: 1px solid #BFBFBF;
  font-size: 10px;
  vertical-align: middle;
}
.pp-product-table td.text-right { text-align: right; }
.pp-product-table td.text-center { text-align: center; }
.pp-product-table tbody tr:nth-child(even) td { background: #F2F2F2; }
.pp-product-table tr.pp-type-row td {
  background: #E1EEF7 !important;
  color: #1F5C7A;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 6px 8px;
}
.pp-product-table tr.pp-subtotal-row td {
  background: white !important;
  font-weight: 700;
  font-size: 10.5px;
}
.pp-item-desc { font-weight: 600; color: #111; }
.pp-item-meta { font-size: 9px; color: #6B7280; font-style: italic; margin-top: 1px; }

/* Project total */
.pp-project-total {
  text-align: right;
  margin-top: 10px;
  font-size: 12px;
}
.pp-project-total .pp-subtle { color: #6B7280; font-size: 10px; }
.pp-project-total .pp-amount { color: #1F5C7A; font-weight: 700; }

/* Approval / authorization */
.pp-auth-heading {
  font-family: 'Calibri', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1F5C7A;
  text-align: center;
  margin: 6px 0 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid #0070C0;
}
.pp-approval-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.pp-approval-table td { border: 1px solid #BFBFBF; padding: 8px 10px; font-size: 11px; vertical-align: middle; }
.pp-approval-table .pp-approval-label { background: #F2F2F2; font-weight: 700; width: 25%; }
.pp-approval-table .pp-approval-total { font-weight: 700; color: #1F5C7A; font-size: 12px; }

.pp-auth-clause { font-size: 10.5px; margin: 14px 0 18px; }

/* T&C blocks */
.pp-tnc-block { margin-top: 8px; }
.pp-tnc-title { font-weight: 700; font-size: 11px; margin: 4px 0 2px; }

/* Signature blocks */
.pp-sig-row { display: grid; grid-template-columns: 1fr 28px 1fr; gap: 0; margin-top: 16px; }
.pp-sig-block { padding: 0 4px; }
.pp-sig-heading {
  font-weight: 700;
  font-size: 10px;
  color: #1F5C7A;
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}
.pp-sig-line {
  border-bottom: 1px solid #111;
  height: 16px;
  margin-bottom: 2px;
}
.pp-sig-label {
  font-size: 9px;
  color: #6B7280;
  margin-bottom: 16px;
}

/* Specifications */
.pp-spec-group {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6B7280;
  margin: 12px 0 4px;
}
.pp-spec-name {
  font-weight: 700;
  font-size: 11.5px;
  color: #1F5C7A;
  margin: 4px 0 1px;
}
.pp-spec-meta {
  font-size: 9px;
  font-style: italic;
  color: #6B7280;
  margin-bottom: 3px;
}
.pp-spec-body { margin-bottom: 12px; }

.pp-empty { text-align: center; padding: 24px 12px; color: #6B7280; font-style: italic; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ===== Quick Actions block ===== */
.quick-action-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface-bright);
  text-decoration: none;
  color: var(--on-surface);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: var(--space-2);
}
.quick-action-card:hover { background: var(--surface-container-low); text-decoration: none; }
.quick-action-card.dark { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.quick-action-card.dark:hover { background: var(--primary-hover); }

/* ===== Activity feed ===== */
.activity-list { display: flex; flex-direction: column; gap: var(--space-4); }
.activity-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; padding-bottom: 0; }
.activity-item .activity-text { flex: 1; }
.activity-item .activity-text .who { font-weight: 600; }
.activity-item .activity-time { font-size: 11px; color: var(--on-surface-variant); margin-top: 2px; }

/* ====== Profile ====== */
.profile-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-6); }
.commission-card { background: var(--primary); color: var(--on-primary); border-radius: var(--radius-lg); padding: var(--space-6); }
.commission-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.7; }
.commission-card .total { font-family: var(--font-heading); font-size: 32px; font-weight: 700; margin: 6px 0 var(--space-4); }
.commission-card .breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.commission-card .breakdown div { padding: 8px 10px; background: rgba(255,255,255,0.06); border-radius: var(--radius); }

/* RBAC switch list */
.permission-list { display: flex; flex-direction: column; gap: 10px; }
.permission-list .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface-container-low); border-radius: var(--radius);
}
.toggle {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-container-high);
  border-radius: var(--radius-full);
  transition: 200ms var(--ease);
}
.toggle .slider::before {
  content: ""; position: absolute;
  height: 16px; width: 16px;
  left: 2px; top: 2px;
  background: white;
  border-radius: var(--radius-full);
  transition: 200ms var(--ease);
}
.toggle input:checked + .slider { background: var(--secondary); }
.toggle input:checked + .slider::before { transform: translateX(16px); }

/* Slabs editor */
.slab-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.slab-row input { height: 34px; }

/* Spinner */
.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--surface-container-highest);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Search dropdown / typeahead */
.typeahead { position: relative; }
.typeahead-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
}
.typeahead-item {
  padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.typeahead-item:last-child { border-bottom: none; }
.typeahead-item:hover, .typeahead-item.highlighted { background: var(--surface-container-low); }
.typeahead-item .meta { font-size: 11px; color: var(--on-surface-variant); display: block; margin-top: 2px; }

/* error pages */
.error-page { display: flex; align-items: center; justify-content: center; height: calc(100vh - var(--topbar-height)); flex-direction: column; gap: 16px; }
.error-page .code { font-family: var(--font-heading); font-size: 96px; font-weight: 700; color: var(--primary); margin: 0; }
.error-page h2 { margin: 0; font-size: 24px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-grid { grid-template-columns: 1fr; }
}

/* Builder collapses to a single column only on very narrow viewports.
 * The thumbnail moves above the form so it stays accessible. */
@media (max-width: 820px) {
  .builder-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 0;
  }
  .builder-pane-left, .builder-pane-right { height: auto; max-height: none; }
  .builder-pane-right { order: -1; padding: 16px; border-bottom: 1px solid var(--border); }
  .preview-thumb-card { max-width: 220px; margin: 0 auto; }
  .builder-footer-bar { left: 0; height: auto; flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 16px; }
  :root { --builder-footer-height: 168px; }
}

/* Sidebar logout: keep button styled like a nav item without form chrome */
.sidebar-logout-form { margin: 0; padding: 0; }
.sidebar-logout-btn {
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
}
.sidebar-logout-btn:hover { background: rgba(0, 0, 0, 0.04); }

/* ============================================================
   Topbar enhancements (search results, notifications popover)
   ============================================================ */
.topbar-popover-wrap { position: relative; }
.topbar-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 460px;
  overflow-y: auto;
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  z-index: 200;
}
.topbar-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-container-low);
}
.topbar-popover-body { padding: 4px 0; }
.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.notif-item:last-child { border-bottom: none; }
.notif-text { flex: 1; min-width: 0; }
.notif-text > div:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Global search dropdown */
.global-search-results {
  padding: 4px 0;
}
.global-search-results .typeahead-section {
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  background: var(--surface-container-low);
  font-weight: 600;
}
.global-search-results .typeahead-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--on-surface);
}
.global-search-results .typeahead-item .ts-main {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.builder-bar .danger-btn,
.btn.btn-danger {
  background: var(--error);
  color: white;
  border: 1px solid var(--error);
}
.btn.btn-danger:hover { background: #9b1212; border-color: #9b1212; }
.btn.btn-ghost.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: transparent;
}
.btn.btn-ghost.btn-danger:hover {
  background: var(--error-bg);
  color: var(--error);
}

