/* ==================================================================
   ShineMySpace Cost Calculator — professional UI
   Mobile-first, responsive (phone / tablet / laptop).
   Sections:
     1. Tokens   2. Base   3. Buttons/chips   4. Login
     5. Top bar  6. Tabs   7. Layout/cards    8. Rooms & surfaces
     9. Results 10. Total bar 11. Toast 12. Responsive 13. Print
   ================================================================== */

/* 1. Tokens -------------------------------------------------------- */
:root {
  --brand: #2563eb;          /* primary blue            */
  --brand-700: #1d4ed8;
  --navy: #1e3a8a;           /* headers / total bar     */
  --navy-900: #172554;
  --accent: #ea580c;         /* warm highlight (brand)  */
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #dde4ee;
  --card: #ffffff;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --sub-bg: #fff5f5;
  --sub-line: #fecaca;
  --ok: #16a34a;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 46px;
  --maxw: 920px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08);
  --ring: 0 0 0 3px rgba(37, 99, 235, .25);
}

/* 2. Base ---------------------------------------------------------- */
* { box-sizing: border-box; }

/* The hidden attribute must always win (even over display:flex rules). */
[hidden] { display: none !important; }

/* Quotation print container — hidden on screen, shown only when printing. */
#print-area { display: none; }
@media print {
  #login-gate, #app { display: none !important; }
  #print-area { display: block !important; }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0; }

/* 3. Buttons & chips ---------------------------------------------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  min-height: var(--tap);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--brand);
  transition: background-color .15s, box-shadow .15s, transform .04s;
}
.btn:hover { background: var(--brand-700); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
/* Hint shown under the Quote actions when Publish is disabled. */
.publish-hint { margin: 10px 4px 0; font-size: 13px; color: var(--muted); text-align: center; }

.btn--primary   { background: var(--brand); }
.btn--secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--secondary:hover { background: #f8fafc; }
.btn--ghost     { background: #fff; color: var(--brand); border-color: #c7d6f5; }
.btn--ghost:hover { background: #f3f7ff; }
.btn--danger    { background: #dc2626; }
.btn--danger:hover { background: #b91c1c; }
.btn--ok        { background: #fff; color: var(--ok); border-color: #bbf7d0; }
.btn--ok:hover  { background: #f0fdf4; }
/* Soft "add" button — clearly an add affordance, not a loud solid block. */
.btn--add       { background: #eaf1ff; color: var(--brand-700); border: 1px dashed #a9c1f2; }
.btn--add:hover { background: #dfe8ff; border-color: var(--brand); }
.btn--sm    { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn--block { display: block; width: 100%; }
.btn svg { display: inline-block; vertical-align: middle; margin-right: 5px; flex-shrink: 0; }

/* small icon button (remove, delete) */
.icon-btn {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--sub-line);
  border-radius: 9px;
  background: #fff;
  color: var(--danger);
  font-size: 15px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: #fef2f2; border-color: var(--danger); }
.icon-btn__text { font-size: 13px; font-weight: 600; }
/* Delete buttons sit in the top-right corner of their room/surface box. */
.icon-btn--delete { position: absolute; top: 8px; right: 8px; height: 34px; min-width: 34px; padding: 0 8px; }

/* pill "add surface" chips */
.chip {
  appearance: none;
  border: 1px solid #c7d6f5;
  background: #eff4ff;
  color: var(--brand-700);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 38px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s;
}
.chip:hover { background: #e0eaff; }
.chip--minus { border-color: var(--sub-line); background: var(--sub-bg); color: var(--danger-dark); }
.chip--minus:hover { background: #ffecec; }

/* 4. Login --------------------------------------------------------- */
.login-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #2563eb 0%, #1e3a8a 60%, #172554 100%);
  z-index: 1000;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 18px;
  padding: 34px 26px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.login-logo { max-height: 58px; margin-bottom: 14px; }
.login-title { font-size: 21px; color: var(--ink); }
.login-sub { color: var(--muted); font-size: 14px; margin: 6px 0 18px; }
.login-input {
  width: 100%;
  min-height: var(--tap);
  margin-bottom: 14px;
  padding: 0 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.login-input:focus { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.login-error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 12px 0 0; }

/* 5. Top bar ------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-900) 100%);
  color: #fff;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar__logo { height: 30px; width: auto; flex: 0 0 auto; background: #fff; border-radius: 6px; padding: 3px; }
.topbar__title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Backend server status, next to the logo. */
.server-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .75); }
.server-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: #94a3b8; }
.server-status.is-ready { color: rgba(255, 255, 255, .9); }
.server-status.is-ready .server-dot { background: var(--ok); box-shadow: 0 0 0 2px rgba(22, 163, 74, .3); }
.server-status.is-waking { color: #fde68a; }
.server-status.is-waking .server-dot { background: #f59e0b; animation: server-pulse 1s ease-in-out infinite; }
.server-status.is-offline { color: #fecaca; }
.server-status.is-offline .server-dot { background: #ef4444; }
@keyframes server-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.topbar__actions { display: flex; gap: 8px; flex: 0 0 auto; }
.topbar .btn--ghost { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .35); }
.topbar .btn--ghost:hover { background: rgba(255, 255, 255, .22); }
/* Menu (hamburger) — just the three lines, no button box. */
.topbar__menu-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto;
  padding: 0; border: none; background: transparent;
  color: #fff; cursor: pointer; border-radius: 8px;
}
.topbar__menu-btn:hover { background: rgba(255, 255, 255, .12); }
.menu { position: relative; flex: 0 0 auto; }

/* Session status dot: green = active Google session, grey = signed out. */
.auth-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #94a3b8; flex: 0 0 auto;
}
.auth-dot.is-active { background: var(--ok); }
.auth-dot--lg { width: 10px; height: 10px; }

.menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
}
/* Signed-in user header inside the menu. */
.menu__user {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.menu__user-info { display: flex; flex-direction: column; min-width: 0; }
.menu__user-name { font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu__user-email { font-size: 12px; color: #64748b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 10px 12px; border: none; background: transparent;
  border-radius: 8px; font-size: 14px; color: var(--ink); cursor: pointer;
}
.menu__item:hover { background: var(--bg); }

/* 6. Tabs (segmented control) ------------------------------------- */
.tabs {
  /* Mirror .container so the pill's edges line up with the cards below. */
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--bg);
}
/* The track: a recessed pill holding both options, so it clearly reads as
   one switch with a highlighted choice — not two separate buttons. */
.tabs__track {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #c6d0e1;
  border-radius: 12px;
}
.tab {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: #334155;
  min-height: 40px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: color .15s, background .15s, box-shadow .15s;
}
.tab:hover:not(.tab--active) { color: var(--ink); }
/* Active option: raised white "thumb" — the standard mobile toggle look. */
.tab--active {
  color: var(--brand);
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .14), 0 2px 4px rgba(15, 23, 42, .06);
}

/* 7. Layout / cards ----------------------------------------------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px;
  /* Clearance so the fixed total bar never overlaps content. Laptops have no
     safe-area inset (phones do), so the base value must clear the bar alone. */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.view { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card--customer { padding: 14px 16px; }
.card__title { font-size: 16px; color: var(--ink); margin-bottom: 12px; }
.card__subtitle { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 10px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 5px; }
/* Live "= N ft" shown above an inch-mode dimension input. */
.field__conv {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-700, var(--brand));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field--full { width: 100%; }
.field__label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field__input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  /* 16px is the threshold below which mobile browsers auto-zoom on focus —
     keep it here so tapping a field never zooms the page. */
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
.field__input:focus { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.field__input::-webkit-outer-spin-button,
.field__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field__input[type=number] { -moz-appearance: textfield; }
/* Shrink just the placeholder text — the input itself stays 16px so focusing
   a field never triggers the mobile auto-zoom. */
.field__input::placeholder,
.surface__name::placeholder { font-size: 13px; }

/* 8. Rooms & surfaces --------------------------------------------- */
.room {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 24px;   /* clearer gap between rooms when scrolling */
  overflow: hidden;      /* clip the header band to the card's rounded corners */
}
/* Tinted title bar spanning the top of the card — a strong "this room starts
   here" marker so rooms are easy to tell apart while scrolling fast. */
.room__head {
  display: flex; gap: 8px; align-items: center;
  margin: -16px -16px 16px;
  padding: 10px 44px 10px 14px;
  background: #eef1f6;
  border-bottom: 2px solid #c8d3e3;
}
.room__name { color: var(--navy); }
.room__title { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; cursor: text; }
.room__name {
  flex: 0 1 auto;
  width: auto;
  min-width: 50px;
  min-height: 40px;
  padding: 4px 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}
.room__name:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: var(--ring); }

.surfaces { display: flex; flex-direction: column; gap: 12px; }
.surface {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 14px 14px 16px;
}
.surface--subtract { background: var(--sub-bg); border-color: var(--sub-line); }
/* gap spaces the name from the ft/in toggle; padding-right keeps the toggle
   clear of the absolutely-positioned delete button so neither is mis-tapped. */
.surface__top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-right: 54px; }
/* Area | Qty measurement-mode toggle, right-aligned before the delete icon. */
.mode-toggle { display: inline-flex; margin-left: auto; flex: 0 0 auto; background: #eef2f8; border-radius: 8px; padding: 2px; }
.mode-toggle__opt {
  border: none; background: transparent; cursor: pointer;
  padding: 4px 10px; min-height: 28px;
  font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 6px;
}
.mode-toggle__opt.is-active { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
/* Locked toggle: mode is fixed by the selected item — dim the inactive option
   and make it non-interactive, so the choice can't drift from the item. */
.mode-toggle--locked { opacity: .85; }
.mode-toggle__opt:disabled { cursor: default; }
.mode-toggle__opt:disabled:not(.is-active) { opacity: .4; }
/* Editable surface / item name. Tap to rename; the placeholder shows the kind
   (Ceiling / Wall / Deduct). Picking an item from the modal fills this in. */
.surface__title { display: inline-flex; align-items: center; min-width: 0; max-width: 100%; cursor: text; }
.surface__name {
  flex: 0 1 auto;
  width: auto;
  min-width: 50px;
  min-height: 34px;
  padding: 4px 8px;
  /* Displays at 14px, but jumps to 16px on focus (below) so iOS doesn't
     auto-zoom the moment you tap it to edit. */
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}
.surface__name:focus { outline: none; background: #fff; box-shadow: var(--ring); border-color: var(--brand); font-size: 16px; }
/* The linked Zoho item, shown quietly below the measurements: a red ✕ clear
   button then "Item: <name>". */
/* Item area below the measurements. With no item linked it shows a clear
   "Search item" button; once linked it shows the full item name (wrapping,
   never trimmed) with small Change (🔍) and Remove (✕) buttons. */
.surface__item { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.surface__pick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.surface__pick:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.surface__item-text { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.surface__item-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.surface__item-btn:hover { background: var(--bg); color: var(--brand); border-color: var(--brand); }
.surface__item-btn--clear { color: var(--danger); }
.surface__item-btn--clear:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.surface__fields { display: flex; flex-wrap: nowrap; gap: 8px; align-items: end; }
/* Length / Width / Cost/sqft share the row, all equal width. */
.surface__fields .field { flex: 1 1 0; min-width: 0; }

.room__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.primary-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 18px; }
.primary-actions .btn { flex: 1 1 auto; }
/* Publish + Save-as-PDF: always equal width (id beats the wide-screen override). */
#view-summary .primary-actions .btn { flex: 1 1 0; }

.data-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.data-actions > .btn { flex: 1 1 auto; }
.btn-pair { display: flex; gap: 10px; flex: 1 1 auto; }
.btn-pair .btn { flex: 1 1 auto; }

/* saved list */
.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}
.saved-row__info { display: flex; flex-direction: column; min-width: 0; }
.saved-row__name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-row__date { font-size: 12px; color: var(--muted); }
.saved-row__actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* 9. Quote view ---------------------------------------------------- */
/* Summary banner */
.quote-summary {
  background: linear-gradient(125deg, var(--navy) 0%, var(--navy-900) 100%);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.quote-summary__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.quote-summary__who { display: flex; flex-direction: column; min-width: 0; }
.quote-summary__label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #aebfe6; }
.quote-summary__name { font-size: 19px; font-weight: 800; margin-top: 2px; word-break: break-word; }
.quote-summary__date { font-size: 13px; color: #c7d2fe; white-space: nowrap; }
.quote-summary__stats { display: flex; gap: 10px; }
.stat { flex: 1; background: rgba(255, 255, 255, .12); border-radius: 10px; padding: 8px 12px; }
.stat__label { display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #c7d2fe; }
.stat__value { display: block; font-size: 16px; font-weight: 800; margin-top: 3px; }
.stat--cost .stat__value { color: #fde68a; }
/* Measures tile: a small labelled list (Area / Quantity), values right-aligned. */
.stat--measures { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.metric { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.metric__label { flex: 0 0 auto; font-size: 12px; color: #c7d2fe; }
.metric__val { font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; }

/* Per-room card */
.quote-room {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.quote-room__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #eef2f8;
  border-bottom: 1px solid var(--line);
}
.quote-room__name { font-weight: 700; font-size: 15px; color: var(--ink); }
.quote-room__total { font-weight: 800; color: var(--navy); }
.quote-table { width: 100%; border-collapse: collapse; }
.quote-table td { padding: 11px 16px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
.quote-table td.num { text-align: right; white-space: nowrap; font-weight: 700; color: var(--ink); }
.quote-item__name { font-weight: 600; font-size: 14px; color: var(--ink); }
/* Each sub-line gets its own muted shade so the surface reads at a glance
   without any line shouting: item name (soft indigo), dimensions (grey),
   area · rate (soft teal). Item stays un-bold. They are indented so they
   read as details grouped under the surface name. */
.quote-item__item { font-size: 13px; font-weight: 400; color: #6470a8; margin-top: 2px; padding-left: 10px; }
.quote-item__dims { font-size: 12px; color: var(--muted); margin-top: 3px; padding-left: 10px; }
.quote-item__calc { font-size: 12px; color: #4e8078; margin-top: 2px; padding-left: 10px; }
.quote-row--sub .quote-item__name,
.quote-row--sub td.num { color: var(--danger); }
/* A deduction bigger than its item's area in the room — flag the row. */
.quote-row--over td { background: var(--sub-bg); }
.quote-item__warn { margin-top: 4px; padding-left: 10px; font-size: 12px; font-weight: 600; color: var(--danger); }
.quote-table tfoot td { background: #fafbfc; font-weight: 700; color: var(--muted); border-bottom: none; }
.quote-table tfoot td.num { color: var(--navy); }
/* Single footer row: "Room total · <area>" (area not highlighted) on the left,
   the total amount prominent on the right. */
.quote-table tfoot tr.quote-total-row td { color: var(--ink); }
.quote-table tfoot tr.quote-total-row td.num { color: var(--navy); font-weight: 800; }
.quote-foot__area { font-weight: 400; color: var(--muted); font-size: 0.8em; }
/* Per-type subtotal rows (Ceiling / Walls / Deducts) above the room Total:
   lighter than the Total, with a subtle divider before the Total row. */
.quote-table tfoot tr.quote-subtotal-row td { padding-top: 7px; padding-bottom: 7px; font-weight: 600; color: var(--muted); font-size: 13px; }
.quote-table tfoot tr.quote-subtotal-row td.num { color: var(--muted); font-weight: 700; }
.quote-table tfoot tr.quote-subtotal-row + tr.quote-total-row td { border-top: 1px solid #e6ebf2; }
/* Gentle, desaturated tint per type so the eye groups each row without loud
   contrast — cool tones for the additive types, a soft rose for deductions.
   Selectors carry the full tfoot prefix so they beat the muted colour above. */
.quote-table tfoot tr.quote-subtotal-row--ceiling  td:first-child,
.quote-table tfoot tr.quote-subtotal-row--ceiling  td.num  { color: #4471b0; }   /* blue */
.quote-table tfoot tr.quote-subtotal-row--wall     td:first-child,
.quote-table tfoot tr.quote-subtotal-row--wall     td.num  { color: #2f8a7c; }   /* teal */
.quote-table tfoot tr.quote-subtotal-row--subtract td:first-child,
.quote-table tfoot tr.quote-subtotal-row--subtract td.num  { color: #c05468; }   /* rose */

/* 10. Total bar ---------------------------------------------------- */
.totalbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-900) 100%);
  color: #fff;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, .25);
  transition: transform .2s ease;
}
/* On touch devices the on-screen keyboard lifts this fixed bar right over the
   field being edited. Slide it out of the way while a field is focused. */
.totalbar--tucked { transform: translateY(130%); }
.totalbar__area { font-size: 13px; color: #c7d2fe; }
.totalbar__cost { font-size: 18px; font-weight: 800; letter-spacing: .2px; }

/* 10b. Item search modal ------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; overscroll-behavior: contain; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); }
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;          /* fallback for browsers without dvh */
  max-height: 90dvh;         /* dvh follows the visible area, so the sheet
                                stays fully usable when the keyboard is open */
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 28px rgba(15, 23, 42, .25);
}
.modal__head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.modal__search {
  flex: 1;
  min-height: 46px;
  padding: 8px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.modal__search:focus { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.modal__close {
  flex: 0 0 auto;
  width: 46px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
.modal__close:hover { background: var(--bg); }
.modal__results {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;  /* keep touch-scroll inside the list — don't
                                    chain to the modal or the page behind it */
}
.item-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.item-row:hover { background: var(--bg); }
.item-row__name { font-weight: 600; }
.item-row__rate { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.item-row--empty { color: var(--muted); text-align: center; padding: 22px; cursor: default; }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal__panel { border-radius: 16px; }
}
/* While a modal is open, freeze the page underneath so touch-scrolling the
   item list can never move the background form. Toggled from ui.js. */
body.modal-open { overflow: hidden; }

/* Blocking activity overlay (publish, refresh items). Spinner keyframes live in
   the inlined splash styles in index.html so they exist at first paint. */
.busy { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, .45); }
.busy[hidden] { display: none; }
.busy__box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 200px; max-width: 80vw;
  padding: 24px 28px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.busy .spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
.busy__text { font-size: 14px; font-weight: 600; color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .busy .spinner { animation-duration: 1.6s; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Custom confirm/prompt dialog — reuses .modal / .modal__panel (bottom sheet
   on phones, centred card on wider screens). Replaces native alert popups. */
.dialog { padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); gap: 14px; }
.dialog__title { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); }
.dialog__title:empty { display: none; }
.dialog__message { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.dialog__message:empty { display: none; }
.dialog__input { margin-top: 2px; }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.dialog__actions .btn { flex: 1 1 auto; min-width: 120px; padding: 0 14px; }
@media (min-width: 640px) {
  .dialog__actions .btn { flex: 0 0 auto; }
}

/* 11. Toast -------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: #fff;
  padding: 11px 14px 11px 18px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
  max-width: 92vw;
  text-align: left;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; cursor: pointer; }
.toast--error { background: #b91c1c; } /* errors: red, longer on screen */
.toast__msg { flex: 1 1 auto; }
.toast__x {
  flex: 0 0 auto; border: none; background: transparent; cursor: pointer;
  color: rgba(255, 255, 255, .75); font-size: 15px; line-height: 1; padding: 2px 4px;
}
.toast__x:hover { color: #fff; }

/* 12. Responsive --------------------------------------------------- */
/* Phones: a tighter, calmer layout so more of the form is visible — especially
   with the on-screen keyboard up. Tablet/desktop (>=600px) keep their spacing.
   The room band's negative margin tracks the smaller room padding here. */
@media (max-width: 599px) {
  /* Keep the tighter phone padding, but preserve the bottom clearance that
     stops the fixed total bar from covering the last content (e.g. the Publish
     button on the Quote tab). */
  .container { padding: 12px; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .card { padding: 14px; }

  /* Room to scroll the last items of the picker up above the on-screen keyboard
     (the sheet extends behind it), so you can tap them without closing it. */
  .modal__results { padding-bottom: 42vh; }

  .room { padding: 12px; margin-bottom: 16px; }
  .room__head { margin: -12px -12px 12px; padding: 7px 40px 7px 12px; }
  .room__name { font-size: 16px; min-height: 34px; }
  .room__actions { margin-top: 10px; }

  .surfaces { gap: 10px; }
  .surface { padding: 12px; }
  .surface__top { margin-bottom: 12px; }
  .surface__item { margin-top: 8px; }
}

@media (min-width: 600px) {
  /* Wider screens: Length / Width / Cost grow to fill the row (equal width). */
  .surface__fields .field { flex: 1 1 0; }
  .totalbar { justify-content: flex-end; gap: 36px; }
  .primary-actions .btn, .data-actions > .btn, .btn-pair .btn { flex: 0 1 auto; }
}
@media (min-width: 1024px) {
  .container { padding: 24px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .tabs { padding-left: 24px; padding-right: 24px; }
}

/* ==================================================================
   13. Printed / shareable quotation (rendered into #print-area)
   White A4 document: navy text + thin rules, no filled backgrounds.
   ================================================================== */
#print-area { color: #111; font-family: Arial, Helvetica, sans-serif; }
.q { width: 100%; }

.q-head { display: flex; align-items: center; gap: 18px; padding-bottom: 12px; border-bottom: 2px solid var(--navy); }
.q-logo { height: 48px; width: auto; }
.q-co__name { font-size: 18px; font-weight: 800; color: var(--navy); }
.q-co__line { font-size: 11px; color: #555; line-height: 1.6; }

.q-titlerow { display: flex; justify-content: space-between; align-items: flex-end; margin: 16px 0 10px; }
.q-title { margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: #94a3b8; }
.q-meta { font-size: 12px; color: #444; }
.q-meta__label { color: #999; font-weight: 600; }

.q-to { border-left: 3px solid var(--navy); padding: 8px 12px; margin-bottom: 16px; }
.q-to__label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: #888; }
.q-to__name { font-size: 16px; font-weight: 700; color: #111; }

/* Tables — summary and detail breakdown. */
.q-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.q-table thead { display: table-header-group; }
.q-table th { background: #c8d8ef; color: var(--navy); text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 700; letter-spacing: .04em; border-bottom: 2px solid var(--navy); }
.q-table td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; }
.q-table th.num, .q-table td.num { text-align: right; white-space: nowrap; }
.q-table tfoot td { font-weight: 700; color: var(--navy); border-top: 2px solid var(--navy); border-bottom: none; background: #fff; }

/* Summary (at-a-glance). */
.q-summary { margin-bottom: 4px; }
.q-summary td { padding: 10px; font-size: 13px; }
.q-summary tfoot td { font-size: 15px; }

/* Detail breakdown. */
.q-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; margin: 20px 0 8px; }
.q-roomdetail { margin-bottom: 14px; page-break-inside: avoid; }
.q-roomtitle { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 4px; background: #f8fafc; padding: 4px 8px; border-radius: 3px; }
.q-detail { font-size: 12px; }
.q-detail td:nth-child(2) { font-size: 10px; color: #94a3b8; }
.q-row--sub td { color: #b91c1c; }

.q-foot { margin-top: 24px; padding-top: 10px; border-top: 1px solid #e2e8f0; font-size: 11px; color: #888; text-align: center; }

/* In-app sign-in dialog (reuses .modal / .modal__panel bottom-sheet). */
#signin-modal .modal__panel { padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); align-items: center; gap: 16px; }
.signin-modal__text { margin: 0; font-size: 15px; color: var(--ink); text-align: center; }
.signin-modal__btn { display: flex; justify-content: center; min-height: 44px; }

/* All-items reference list (menu → View items). */
.items-list__filters { display: flex; gap: 6px; padding: 8px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.chip-filter { border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.chip-filter.is-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.items-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.items-list__row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); }
.items-list__row--warn { background: #fffbeb; }
.items-list__row--bad { background: #fef2f2; }
.items-list__main { display: flex; flex-direction: column; min-width: 0; }
.items-list__name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items-list__meta { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; }
.badge--ok { background: #dcfce7; color: #166534; }
.badge--warn { background: #fef3c7; color: #92400e; }
.badge--bad { background: #fee2e2; color: #991b1b; }

@page { size: A4; margin: 0; }

@media print {
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; background: #fff; }
  #print-area { padding: 1mm 1mm; }
}
