/* =====================================================================
   Livin' Stitchin' design system — shared by the website, customer portal
   and the management suite. Navy (logo) + cream (quilt) + teal / mustard
   (studio wall). Everything reads from these tokens.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --navy: #0e2748;
  --navy-2: #163a6b;
  --navy-3: #21508f;
  --cream: #f6f1e7;
  --cream-2: #efe7d8;
  --paper: #fffdf9;
  --ink: #1d2433;
  --ink-2: #4a5568;
  --ink-3: #7b8494;
  --line: #e2d9c8;
  --teal: #2a9d8f;
  --teal-2: #1f7a70;
  --teal-soft: #d7efec;
  --mustard: #e9b949;
  --mustard-2: #c99a2e;
  --mustard-soft: #fbf0cf;
  --coral: #e76f51;
  --coral-soft: #fbe1d8;
  --green: #2f9e44;
  --green-soft: #d3f2d9;
  --red: #c92a2a;
  --red-soft: #f8d7d7;

  --bg: var(--cream);
  --surface: var(--paper);
  --surface-2: var(--cream-2);
  --text: var(--ink);
  --muted: var(--ink-2);
  --faint: var(--ink-3);
  --border: var(--line);
  --primary: var(--navy);
  --primary-contrast: #ffffff;
  --accent: var(--teal);
  --accent-contrast: #ffffff;
  --highlight: var(--mustard);

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(14, 39, 72, .10);
  --shadow-sm: 0 2px 8px rgba(14, 39, 72, .08);
  --stitch: repeating-linear-gradient(90deg, var(--navy) 0 6px, transparent 6px 11px);
  --maxw: 1140px;
}

/* Dark scheme for the suite when the user's system asks for it. The website stays light. */
:root[data-theme="dark"], :root:not([data-theme="light"]) .allow-dark[data-dark] { color-scheme: dark; }
:root[data-theme="dark"] {
  --bg: #0b1626; --surface: #12203a; --surface-2: #182a49; --text: #eef2f8; --muted: #b7c2d6; --faint: #7f8ca6;
  --border: #253a5f; --primary: #e9b949; --primary-contrast: #0b1626; --accent: #3fc1b0; --highlight: #e9b949;
  --teal-soft: #163f3a; --mustard-soft: #3d3216; --coral-soft: #4a2418; --green-soft: #173b21; --red-soft: #4a1d1d;
  --shadow: 0 10px 30px rgba(0,0,0,.4); --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0 0 .5em; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; font-family: var(--font-body); font-weight: 800; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .74rem; font-weight: 800; color: var(--accent); }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.section { padding: clamp(40px, 7vw, 88px) 0; }
.section-tight { padding: 28px 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .72em 1.35em; border-radius: 999px; border: 2px solid transparent;
  font: 700 .95rem var(--font-body); cursor: pointer; text-decoration: none !important;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space: nowrap; line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-accent { background: var(--accent); color: var(--accent-contrast); }
.btn-highlight { background: var(--highlight); color: var(--navy); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
:root[data-theme="dark"] .btn-outline { border-color: var(--text); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: .45em .95em; font-size: .82rem; }
.btn-lg { padding: .9em 1.7em; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---- cards / surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.card-flat { box-shadow: none; }
.card h3 { margin-top: 0; }
.stitched { position: relative; }
.stitched::after {
  content: ''; position: absolute; inset: 8px; border: 2px dashed color-mix(in srgb, var(--primary) 35%, transparent);
  border-radius: calc(var(--radius) - 6px); pointer-events: none;
}
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- forms ---- */
label { display: block; font-weight: 700; font-size: .86rem; margin-bottom: .3em; color: var(--muted); }
.field { margin-bottom: 14px; }
.field .hint { font-size: .78rem; color: var(--faint); margin-top: .3em; }
input:not([type]), input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; padding: .65em .85em; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 500 .95rem var(--font-body); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; margin-right: .4em; }
.check { display: flex; align-items: center; gap: .5em; font-weight: 600; color: var(--text); font-size: .95rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.input-money { position: relative; }
.input-money input { padding-left: 1.6em; }
.input-money::before { content: '$'; position: absolute; left: .8em; top: 50%; transform: translateY(-50%); color: var(--faint); font-weight: 700; }

/* ---- badges / status ---- */
.badge { display: inline-flex; align-items: center; gap: .35em; padding: .22em .7em; border-radius: 999px; font-size: .74rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge-teal { background: var(--teal-soft); color: var(--teal-2); }
.badge-gold { background: var(--mustard-soft); color: #8a6a12; }
.badge-coral { background: var(--coral-soft); color: #a3401f; }
.badge-green { background: var(--green-soft); color: #1f6b30; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-navy { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .badge-gold { color: var(--mustard); }
:root[data-theme="dark"] .badge-teal { color: #7fe0d3; }
:root[data-theme="dark"] .badge-green { color: #8ee0a0; }
:root[data-theme="dark"] .badge-coral { color: #ffb39c; }
:root[data-theme="dark"] .badge-red { color: #ff9c9c; }

/* status → color map used by portal and suite */
.st-intake, .st-requested, .st-draft { background: var(--surface-2); color: var(--muted); }
.st-diagnosing, .st-in_progress, .st-confirmed, .st-sent { background: var(--teal-soft); color: var(--teal-2); }
.st-awaiting_approval, .st-waiting_parts, .st-partial { background: var(--mustard-soft); color: #8a6a12; }
.st-approved, .st-ready, .st-paid, .st-completed { background: var(--green-soft); color: #1f6b30; }
.st-closed, .st-cancelled, .st-void, .st-no_show { background: var(--red-soft); color: var(--red); }
.pr-rush { color: var(--red); font-weight: 800; }
.pr-high { color: var(--coral); font-weight: 800; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); background: var(--surface-2); position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.clickable { cursor: pointer; }

/* ---- alerts / callouts ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: .92rem; margin-bottom: 14px; }
.alert-info { background: var(--teal-soft); border-color: var(--teal); color: var(--text); }
.alert-warn { background: var(--mustard-soft); border-color: var(--mustard); color: var(--text); }
.alert-error { background: var(--red-soft); border-color: var(--red); color: var(--text); }
.alert-ok { background: var(--green-soft); border-color: var(--green); color: var(--text); }
.help { background: var(--surface-2); border-left: 4px solid var(--highlight); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .9rem; color: var(--muted); margin-bottom: 18px; }
.help strong { color: var(--text); }
.help ol, .help ul { margin: .4em 0 0 1.2em; padding: 0; }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(14, 39, 72, .55); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; backdrop-filter: blur(2px); }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(720px, 100%); max-height: 92vh; overflow: auto; padding: 24px; box-shadow: var(--shadow); }
.modal-lg { width: min(980px, 100%); }
.modal h3 { margin-top: 0; }

/* ---- toast ---- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; opacity: 0; transition: .25s; z-index: 2000; pointer-events: none; max-width: 92vw; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

/* ---- avatar ---- */
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border: 2px solid var(--border); flex: none; }
.avatar svg { width: 100%; height: 100%; }
.avatar-lg { width: 96px; height: 96px; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.avatar-pick button { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 8px 4px; cursor: pointer; text-align: center; font: 700 .72rem var(--font-body); color: var(--muted); transition: .15s; }
.avatar-pick button svg { width: 56px; height: 56px; margin: 0 auto 4px; }
.avatar-pick button:hover { border-color: var(--accent); transform: translateY(-2px); }
.avatar-pick button.sel { border-color: var(--accent); background: var(--teal-soft); color: var(--teal-2); }

/* ---- color chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: .4em; padding: .3em .7em .3em .4em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .82rem; font-weight: 700; }
.chip .sw { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.chip button { background: none; border: 0; cursor: pointer; color: var(--faint); font-size: 1rem; line-height: 1; padding: 0 0 0 .2em; }
.tag { display: inline-block; padding: .25em .7em; border-radius: 999px; border: 1.5px solid var(--border); font-size: .8rem; font-weight: 700; cursor: pointer; user-select: none; background: var(--surface); }
.tag.on { background: var(--navy); color: #fff; border-color: var(--navy); }
:root[data-theme="dark"] .tag.on { background: var(--mustard); color: var(--navy); border-color: var(--mustard); }

/* ---- misc ---- */
.stitch-line { height: 4px; background: var(--stitch); opacity: .35; margin: 8px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .v { font: 700 1.9rem var(--font-display); color: var(--text); line-height: 1.1; }
.kpi .l { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 800; }
.empty { text-align: center; padding: 32px 16px; color: var(--faint); }
.empty svg { width: 64px; height: 64px; margin: 0 auto 8px; opacity: .6; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ''; position: absolute; left: -24px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline .when { font-size: .74rem; color: var(--faint); }
.loading { opacity: .5; pointer-events: none; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd { font: 600 .78rem ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
}
