/* Maintera AI Quoting — shared design tokens & primitives.
   Used by every prototype surface. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Serif+Pro:wght@600;700&display=swap');

:root {
  /* brand — sampled directly from the Maintera logo */
  --m-ink:        #0f1420;       /* near-black navy (text) */
  --m-deep:       #202636;       /* Maintera navy — frame & wordmark */
  --m-mid:        #276793;       /* Maintera blue — M letterform */
  --m-soft:       #dde9f4;       /* light blue tint, derived from m-mid */
  --m-deep-2:     #2c3550;       /* hover for deep */
  --m-mid-2:      #5b96be;       /* lighter blue for accents/dividers */

  /* neutrals */
  --bg:           #f5f7f9;
  --bg-soft:      #fafbfc;
  --card:         #ffffff;
  --line:         #e2e8f0;
  --line-strong:  #cbd5e1;
  --slate:        #475569;
  --slate-2:      #64748b;
  --slate-3:      #94a3b8;
  --muted:        #f1f5f9;

  /* state hues */
  --state-emergency:    #b91c1c;
  --state-emergency-bg: #fee2e2;
  --state-followup:     #b45309;
  --state-followup-bg:  #fef3c7;
  --state-draft:        #15803d;
  --state-draft-bg:     #dcfce7;
  --state-call:         #1d4ed8;
  --state-call-bg:      #dbeafe;
  --state-vendor:       #6d28d9;
  --state-vendor-bg:    #ede9fe;
  --state-client:       #0e7490;
  --state-client-bg:    #cffafe;
  --state-scheduled:    #0d9488;
  --state-scheduled-bg: #ccfbf1;

  /* radii / shadows */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --shadow-1: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-2: 0 4px 14px rgba(15,23,42,0.08);
  --shadow-3: 0 10px 38px rgba(15,23,42,0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  /* Navy chrome with isometric cube pattern — matches Maintera marketing site.
     Content area floats on a light page-frame in the middle. */
  background: var(--m-deep) url('../assets/cube-pattern.svg') repeat;
  color: var(--m-ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

/* Light content frame in the middle of the navy chrome.
   Wrap workspace pages with <div class="page-frame">. */
.page-frame {
  background: var(--bg);
  max-width: 1320px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 4px 24px rgba(0,0,0,0.18);
}
@media (max-width: 1320px) {
  .page-frame { box-shadow: none; }
}
a { color: var(--m-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--m-mid); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.serif { font-family: 'Source Serif Pro', Georgia, serif; letter-spacing: -0.01em; }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- LAYOUT ---------- */
.shell { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.shell-narrow { max-width: 720px; margin: 0 auto; padding: 0 18px; }
.shell-mobile { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* The header is mounted into <div id="header-mount"></div> by app.js. We mark
   that wrapper as display:contents so its child .app-header behaves as a direct
   child of <body> — required for `position: sticky` to pin to the viewport. */
#header-mount { display: contents; }

.app-header {
  background: var(--m-deep);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  padding: 14px 0 13px;
  position: sticky; top: 0; z-index: 40;
  color: rgba(255,255,255,0.94);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 6px 18px rgba(0,0,0,0.22);
}
.app-header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
@media print {
  .app-header { display: none !important; }
}

.brand {
  display: flex; align-items: center; gap: 14px;
}
.brand-logo-img {
  height: 32px; width: auto; display: block; flex-shrink: 0;
}
.brand-divider {
  width: 1px; height: 26px; background: rgba(255,255,255,0.18);
}
.brand-app-label {
  font-weight: 500; font-size: 13px; letter-spacing: 0.02em;
  color: rgba(255,255,255,0.92); line-height: 1.2;
}
.brand-app-label .accent { color: var(--m-mid-2); font-weight: 600; }
.brand-app-sub {
  font-size: 11px; color: rgba(255,255,255,0.55); margin-top: 1px; letter-spacing: 0.02em;
}

/* Generic brand-mark wrapper — used for inline marks (e.g. equipment hero, mobile banner) */
.brand-mark {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.demo-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(245, 158, 11, 0.18); color: #fbbf24;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: 999px; text-transform: uppercase;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Slim "back to workspace" operator strip — used on equipment/buyer/vendor pages.
   Solid navy (no cube pattern) for legibility; not sticky because each of these
   pages already has its own sticky action bar (PDF, share, etc.). */
.operator-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--m-deep);
  color: rgba(255,255,255,0.94);
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.operator-strip-brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.operator-strip-brand img {
  width: 26px; height: 26px; object-fit: contain;
  background: rgba(255,255,255,0.06); border-radius: 6px; padding: 2px;
}
.operator-strip-label {
  font-weight: 600; letter-spacing: .02em;
}
.operator-strip-back {
  display: inline-flex; align-items: center; gap: 5px;
  color: rgba(255,255,255,0.92);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 12px; font-weight: 500;
  transition: background-color .12s ease, border-color .12s ease;
}
.operator-strip-back:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.32); text-decoration: none; }
@media print {
  .operator-strip { display: none !important; }
}

.user-chip {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  color: rgba(255,255,255,0.92);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--m-mid); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
  border: 1px solid rgba(255,255,255,0.2);
}

/* Header nav links — overrides .btn-ghost when inside the dark header.
   Slightly higher contrast than 0.78 since the cube pattern is gone and the
   solid navy makes white text more legible. */
.app-header .btn-ghost {
  color: rgba(255,255,255,0.88);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.app-header .btn-ghost:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}
.app-header .btn-ghost:focus-visible {
  outline: 2px solid var(--m-mid-2);
  outline-offset: 2px;
}
.app-header .text-slate-2 { color: rgba(255,255,255,0.72) !important; }

/* ---------- TYPE ---------- */
h1.page-title {
  font-family: 'Source Serif Pro', Georgia, serif;
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--m-ink); margin: 0;
}
.page-sub { color: var(--slate-2); font-size: 13px; margin-top: 4px; }

.section-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--slate-2);
}

/* ---------- CARDS ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card-tight { padding: 14px; }
.card-pad-0 { padding: 0; overflow: hidden; }

/* ---------- BADGES / PILLS ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.pill-emergency { background: var(--state-emergency-bg); color: var(--state-emergency); }
.pill-followup  { background: var(--state-followup-bg);  color: var(--state-followup); }
.pill-draft     { background: var(--state-draft-bg);     color: var(--state-draft); }
.pill-call      { background: var(--state-call-bg);      color: var(--state-call); }
.pill-vendor    { background: var(--state-vendor-bg);    color: var(--state-vendor); }
.pill-client    { background: var(--state-client-bg);    color: var(--state-client); }
.pill-scheduled { background: var(--state-scheduled-bg); color: var(--state-scheduled); }

.ai-tag, .pm-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 999px;
}
.ai-tag { background: var(--m-soft); color: var(--m-deep); }
.ai-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--m-mid); }
.pm-tag { background: rgba(15,23,42,0.06); color: #1e293b; }
.pm-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--slate); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--card); color: var(--m-ink);
  padding: 8px 14px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  transition: background .12s ease, border-color .12s ease, transform .04s ease;
}
.btn:hover { background: var(--bg-soft); border-color: var(--slate-3); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--m-deep); color: white; border-color: var(--m-deep);
}
.btn-primary:hover { background: var(--m-deep-2); border-color: var(--m-deep-2); }
.btn-soft { background: var(--m-soft); border-color: transparent; color: var(--m-deep); }
.btn-soft:hover { background: #c8dcec; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--slate); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--m-ink); }
.btn-danger { color: #b91c1c; border-color: #fecaca; background: #fff1f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------- TABLE ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead {
  background: var(--bg-soft);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--slate-2); font-weight: 700;
}
.tbl th, .tbl td { padding: 11px 16px; text-align: left; vertical-align: top; }
.tbl tbody tr { border-top: 1px solid var(--line); }
.tbl tbody tr:hover { background: var(--bg-soft); cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, monospace; }
.tbl-striped tbody tr:nth-child(even) { background: var(--bg-soft); }

/* ---------- STAT TILE ---------- */
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}
.stat-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-2); }
.stat-value { font-family: 'Source Serif Pro', serif; font-size: 28px; font-weight: 700; color: var(--m-ink); margin-top: 2px; line-height: 1.05; }
.stat-delta { font-size: 11.5px; margin-top: 6px; }
.stat-delta-up { color: #15803d; }
.stat-delta-down { color: #b91c1c; }
.stat-foot { font-size: 11px; color: var(--slate-2); margin-top: 6px; }

/* ---------- FILTERS / CHIPS ---------- */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--slate);
  transition: all .12s ease;
}
.chip:hover { border-color: var(--m-mid); color: var(--m-deep); }
.chip.active { background: var(--m-deep); color: #fff; border-color: var(--m-deep); }
.chip .count { font-size: 11px; opacity: .85; margin-left: 3px; }

/* ---------- FORM ELEMENTS ---------- */
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--m-ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--m-mid);
  box-shadow: 0 0 0 3px var(--m-soft);
}
.textarea { line-height: 1.5; resize: vertical; }
.label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-2); margin-bottom: 5px; }

.range {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  height: 4px; border-radius: 999px; background: var(--line);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--m-mid); border: 2px solid white; box-shadow: var(--shadow-1);
}

/* ---------- CONVERSATION ---------- */
.convo { display: flex; flex-direction: column; gap: 10px; }
.convo-evt {
  display: grid; grid-template-columns: 100px 1fr; gap: 14px;
  font-size: 12.5px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.convo-evt:last-child { border-bottom: none; }
.convo-time { color: var(--slate-2); font-family: ui-monospace, monospace; font-size: 11.5px; padding-top: 1px; }
.convo-actor-ai     { color: var(--m-deep); font-weight: 600; }
.convo-actor-vendor { color: #1e3a8a; font-weight: 600; }
.convo-actor-pm     { color: #1e293b; font-weight: 600; }
.convo-actor-client { color: #831843; font-weight: 600; }
.convo-text { color: var(--m-ink); }

/* ---------- TOAST ---------- */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  background: var(--m-ink); color: white;
  padding: 12px 18px; border-radius: var(--r-md);
  font-size: 13px; box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: slide-in .25s ease;
}
.toast-success { background: var(--m-deep); }
.toast-info { background: #1e293b; }
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ---------- MOBILE PROPOSAL CONTAINER ---------- */
.mobile-page {
  background: var(--bg);
  min-height: 100vh;
  padding: 0 0 80px 0;
}
.mobile-card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}
.mobile-cta-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 8px;
  box-shadow: 0 -8px 22px rgba(15,23,42,0.06);
  z-index: 20;
}
.mobile-cta-bar .btn { flex: 1; }
@media (min-width: 600px) {
  .mobile-cta-bar { max-width: 480px; left: 50%; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; }
}

/* ---------- HELPERS ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 6px; } .gap-3 { gap: 10px; } .gap-4 { gap: 14px; } .gap-5 { gap: 18px; } .gap-6 { gap: 24px; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1 1 0; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-side { grid-template-columns: 1fr 360px; }

.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 28px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-md { font-size: 15px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }
.text-slate { color: var(--slate); }
.text-slate-2 { color: var(--slate-2); }
.text-slate-3 { color: var(--slate-3); }
.text-deep { color: var(--m-deep); }
.text-emergency { color: var(--state-emergency); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.bg-soft { background: var(--bg-soft); }
.bg-muted { background: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.spacer { flex: 1 1 0; }
.hide { display: none !important; }
.responsive-hide-sm { }
@media (max-width: 700px) {
  .responsive-hide-sm { display: none !important; }
  .grid-side { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1.page-title { font-size: 22px; }
}
