/* ═══════════════════════════════════════════════════════════════════════
   Koadi Design System — web stylesheet (single source of truth for all
   server-rendered templates). Mobile twin: constants/theme.ts.

   Identity: Space Grotesk display type + Inter body, deep-navy surfaces,
   pill geometry, blueprint grid accents. Blue is the brand, orange is the
   action (CTAs only), neutrals carry 90% of every page.
   ═══════════════════════════════════════════════════════════════════════ */

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  /* Brand blue scale */
  --blue-50: #EBF4FB; --blue-100: #D2E7F6; --blue-200: #A6CEED;
  --blue-300: #74B1E1; --blue-400: #4293D2; --blue-500: #1B75BC;
  --blue-600: #16619C; --blue-700: #124E7E; --blue-800: #0D3A5E;
  --blue-900: #092841;

  /* Action orange scale */
  --orange-50: #FEF3E4; --orange-100: #FDE3C2; --orange-200: #FBC98A;
  --orange-300: #F9AE51; --orange-400: #F7941D; --orange-500: #E07F0A;
  --orange-600: #B96808; --orange-700: #8F5106;

  /* Warm-gray neutrals */
  --gray-25: #FCFCFD; --gray-50: #F8F9FB; --gray-100: #F1F3F6;
  --gray-200: #E4E7EC; --gray-300: #D0D5DD; --gray-400: #98A2B3;
  --gray-500: #667085; --gray-600: #475467; --gray-700: #344054;
  --gray-800: #1D2939; --gray-900: #101828;

  /* Semantic */
  --green-50: #ECFDF3; --green-500: #12B76A; --green-700: #027A48;
  --red-50: #FEF3F2; --red-500: #F04438; --red-700: #B42318;
  --amber-50: #FFFAEB; --amber-500: #F79009; --amber-700: #B54708;
  --indigo-50: #EEF4FF; --indigo-500: #6172F3; --indigo-700: #3538CD;

  /* Paper & Ink identity tokens */
  --paper: #FAF7F2;
  --paper-2: #F3EEE5;
  --ink: #10253A;
  --ink-2: #4A5A6A;
  --ink-3: #8492A0;
  --ink-line: #E4DCCE;

  /* Aliases (theme-switchable) — Paper & Ink values */
  --brand: var(--blue-700);
  --brand-strong: var(--blue-800);
  --brand-soft: #E7F0F8;
  --action: var(--orange-400);
  --action-pressed: var(--orange-500);
  --action-soft: var(--orange-50);
  --bg: var(--paper);
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --surface-sunken: var(--paper-2);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: var(--ink-3);
  --link: var(--blue-700);
  --border: var(--ink-line);
  --border-strong: #C9BFAC;
  --divider: var(--paper-2);
  --shadow-card: 4px 4px 0 rgba(16,37,58,.09);
  --shadow-raised: 7px 7px 0 rgba(16,37,58,.14);
  --ink-shadow: 5px 5px 0 var(--ink);
  --radius-sm: 10px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: var(--blue-300);
    --brand-strong: var(--blue-200);
    --brand-soft: rgba(116,177,225,.14);
    --action-soft: rgba(247,148,29,.14);
    --bg: #0B1520;
    --surface: #12202F;
    --surface-raised: #18293B;
    --surface-sunken: #0B1520;
    --text: #F2EFE9;
    --text-2: #9AA8B5;
    --text-3: #64768A;
    --ink: #F2EFE9;
    --ink-2: #9AA8B5;
    --ink-3: #64768A;
    --ink-line: #24384C;
    --link: var(--blue-300);
    --border: #24384C;
    --border-strong: #35506B;
    --divider: #18293B;
    --shadow-card: 4px 4px 0 rgba(0,0,0,.35);
    --shadow-raised: 7px 7px 0 rgba(0,0,0,.45);
    --ink-shadow: 5px 5px 0 rgba(0,0,0,.55);
  }
}

/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.18; color: var(--text); font-family: var(--font-display); }
h1 { font-size: clamp(32px, 5.2vw, 52px); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: clamp(24px, 3.8vw, 34px); font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 1em; }
.text-2 { color: var(--text-2); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 13px; }

.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px/1 var(--font); border-radius: 999px;
  padding: 13px 26px; border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important; white-space: nowrap;
}
.btn-primary { box-shadow: 0 6px 20px -6px rgba(247,148,29,.55); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-pressed); }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--brand); background: var(--brand-soft); }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-sunken); }
.btn-danger { background: var(--red-500); color: #fff; }
.btn-lg { padding: 16px 32px; font-size: 16px; border-radius: 999px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  padding: 24px;
}
.card-hover { transition: box-shadow .15s, border-color .15s; }
.card-hover:hover { box-shadow: var(--shadow-raised); border-color: var(--border-strong); }
.card-sunken { background: var(--surface-sunken); border: 1px solid var(--divider); box-shadow: none; }

/* ── Status badges (job lifecycle) ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 12px/1 var(--font); padding: 5px 10px;
  border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-open { background: var(--blue-50); color: var(--blue-700); }
.badge-payment_pending { background: var(--amber-50); color: var(--amber-700); }
.badge-assigned { background: var(--indigo-50); color: var(--indigo-700); }
.badge-in_progress { background: var(--orange-50); color: var(--orange-700); }
.badge-awaiting_approval { background: var(--amber-50); color: var(--amber-700); }
.badge-completed { background: var(--green-50); color: var(--green-700); }
.badge-cancelled { background: var(--gray-100); color: var(--gray-600); }
.badge-verified { background: var(--blue-50); color: var(--blue-700); }
.badge-member { background: var(--orange-50); color: var(--orange-700); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-open { background: rgba(66,147,210,.16); color: var(--blue-300); }
  :root:not([data-theme="light"]) .badge-payment_pending,
  :root:not([data-theme="light"]) .badge-awaiting_approval { background: rgba(247,144,9,.16); color: #FDB022; }
  :root:not([data-theme="light"]) .badge-assigned { background: rgba(97,114,243,.16); color: #A4BCFD; }
  :root:not([data-theme="light"]) .badge-in_progress { background: rgba(247,148,29,.16); color: var(--orange-300); }
  :root:not([data-theme="light"]) .badge-completed { background: rgba(18,183,106,.16); color: #6CE9A6; }
  :root:not([data-theme="light"]) .badge-cancelled { background: rgba(152,162,179,.16); color: var(--gray-400); }
  :root:not([data-theme="light"]) .badge-verified { background: rgba(66,147,210,.16); color: var(--blue-300); }
  :root:not([data-theme="light"]) .badge-member { background: rgba(247,148,29,.16); color: var(--orange-300); }
}

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block; font: 600 13px/1.2 var(--font); color: var(--gray-700);
  margin-bottom: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .field label { color: var(--text-2); }
}
.input, .select, .textarea {
  width: 100%; font: 400 15px/1.4 var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 11px 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { min-height: 110px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.field .error-text { font-size: 12px; color: var(--red-500); margin-top: 5px; }

/* ── Alerts / flash ───────────────────────────────────────────────────── */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-md); padding: 13px 16px;
  font-size: 14px; margin-bottom: 16px; border: 1px solid;
}
.alert-info { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-800); }
.alert-success { background: var(--green-50); border-color: #A6F4C5; color: var(--green-700); }
.alert-error { background: var(--red-50); border-color: #FECDCA; color: var(--red-700); }
.alert-warning { background: var(--amber-50); border-color: #FEDF89; color: var(--amber-700); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .alert-info { background: rgba(66,147,210,.12); border-color: rgba(66,147,210,.3); color: var(--blue-200); }
  :root:not([data-theme="light"]) .alert-success { background: rgba(18,183,106,.12); border-color: rgba(18,183,106,.3); color: #6CE9A6; }
  :root:not([data-theme="light"]) .alert-error { background: rgba(240,68,56,.12); border-color: rgba(240,68,56,.3); color: #FDA29B; }
  :root:not([data-theme="light"]) .alert-warning { background: rgba(247,144,9,.12); border-color: rgba(247,144,9,.3); color: #FDB022; }
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table.ds { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
table.ds th {
  text-align: left; font: 600 12px/1.2 var(--font); text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-2); background: var(--surface-sunken);
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
table.ds td { padding: 13px 16px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
table.ds tr:last-child td { border-bottom: none; }
table.ds tr:hover td { background: var(--surface-sunken); }

/* ── Nav / header ─────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1140px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 28px; height: 64px;
}
.site-header .logo { display: flex; align-items: center; gap: 10px; font: 700 18px/1 var(--font); color: var(--text); }
.site-header .logo img { height: 34px; width: auto; }
.site-header nav { display: flex; gap: 22px; align-items: center; margin-left: auto; }
.site-header nav a { font: 500 14px/1 var(--font); color: var(--text-2); }
.site-header nav a:hover { color: var(--text); text-decoration: none; }
.site-header nav a.active { color: var(--brand); }

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--gray-900); color: var(--gray-400);
  padding: 56px 0 32px; margin-top: 80px; font-size: 14px;
}
.site-footer a { color: var(--gray-300); }
.site-footer a:hover { color: #fff; }
.site-footer h4 { color: #fff; font-size: 14px; margin-bottom: 14px; }
.site-footer .cols {
  max-width: 1140px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px;
}
.site-footer .legal {
  max-width: 1140px; margin: 40px auto 0; padding: 24px 20px 0;
  border-top: 1px solid var(--gray-800);
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between;
  font-size: 13px; color: var(--gray-500);
}
@media (max-width: 800px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }

/* ── Hero & sections ──────────────────────────────────────────────────── */
.hero { padding: 72px 0 56px; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 13px/1 var(--font); color: var(--brand);
  background: var(--brand-soft); border-radius: 999px; padding: 7px 14px;
  margin-bottom: 20px;
}
.hero p.lead { font-size: clamp(16px, 2.2vw, 19px); color: var(--text-2); max-width: 640px; }
.section { padding: 56px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Stat tiles (live trust proof) ────────────────────────────────────── */
.stat-tile { text-align: center; padding: 20px 12px; }
.stat-tile .num { font: 700 30px/1.1 var(--font); color: var(--text); letter-spacing: -0.02em; }
.stat-tile .num .unit { font-size: 18px; color: var(--text-2); font-weight: 600; }
.stat-tile .label { font-size: 13px; color: var(--text-2); margin-top: 6px; }

/* ── Job lifecycle timeline ───────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 22px 30px; }
.timeline li::before {
  content: ""; position: absolute; left: 7px; top: 20px; bottom: -2px;
  width: 2px; background: var(--border);
}
.timeline li:last-child::before { display: none; }
.timeline li .dot {
  position: absolute; left: 0; top: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline li.done .dot { background: var(--green-500); border-color: var(--green-500); }
.timeline li.current .dot { background: var(--surface); border-color: var(--action); box-shadow: 0 0 0 4px var(--action-soft); }
.timeline li .t-title { font: 600 14px/1.3 var(--font); color: var(--text); }
.timeline li .t-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.timeline li.pending .t-title { color: var(--text-3); }

/* ── Chat ─────────────────────────────────────────────────────────────── */
.chat-scroll { display: flex; flex-direction: column; gap: 10px; padding: 16px; overflow-y: auto; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; }
.msg-mine { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg-theirs { align-self: flex-start; background: var(--surface-sunken); color: var(--text); border-bottom-left-radius: 4px; }
.msg .msg-time { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; }

/* ── Skeletons & empty states ─────────────────────────────────────────── */
@keyframes ds-shimmer { 0% { opacity: .55; } 50% { opacity: 1; } 100% { opacity: .55; } }
.skeleton { background: var(--surface-sunken); border-radius: var(--radius-sm); animation: ds-shimmer 1.4s ease-in-out infinite; }
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-2); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { color: var(--text); }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--divider); margin: 24px 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font: 500 13px/1 var(--font); color: var(--text-2);
  background: var(--surface-sunken); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.pill.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: inline-flex; align-items: center; justify-content: center;
  font: 600 15px/1 var(--font); flex-shrink: 0; overflow: hidden;
}
.rating-stars { color: var(--amber-500); letter-spacing: 1px; font-size: 14px; }
.breadcrumbs { font-size: 13px; color: var(--text-3); margin-bottom: 18px; }
.breadcrumbs a { color: var(--text-2); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
