:root {
  --bg: #ffffff;
  --bg-2: #f8fafc;
  --bg-3: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --brand: #6366f1;
  --brand-2: #4f46e5;
  --brand-soft: #eef2ff;
  --accent: #f59e0b;
  --good: #10b981;
  --bad: #ef4444;
  --warn: #f59e0b;
  --line: #e2e8f0;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --grad: linear-gradient(135deg, #6366f1 0%, #f59e0b 100%);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -12px rgba(15,23,42,.12);
  --shadow-lift: 0 2px 4px rgba(15,23,42,.06), 0 16px 40px -16px rgba(15,23,42,.18);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* ============ AUTH GATE (demo, client-side) ============ */
.auth-gate {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(900px 500px at 50% -10%, #1e293b 0%, #0f172a 55%);
}
body.gating .auth-gate { display: flex; }
body.gating .shell { display: none; }
body:not(.authed):not(.gating) .shell { visibility: hidden; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg); border-radius: var(--radius-lg);
  box-shadow: 0 30px 70px -24px rgba(0,0,0,.6);
  padding: 36px 34px 26px; text-align: center;
}
.auth-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 18px;
  background: #fff; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--line), 0 4px 14px -6px rgba(15,23,42,.25);
}
.auth-logo img { width: 40px; height: 40px; object-fit: contain; }
.auth-kicker { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.auth-title { font-size: 23px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 8px; }
.auth-sub { font-size: 14px; color: var(--ink-3); line-height: 1.55; margin-bottom: 22px; }
.auth-field { text-align: left; margin-bottom: 14px; }
.auth-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.auth-field input {
  width: 100%; font: inherit; font-size: 15px; padding: 11px 13px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
}
.auth-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
.auth-err { min-height: 18px; font-size: 12.5px; color: var(--bad); text-align: left; margin-bottom: 6px; }
.auth-btn { width: 100%; }
.auth-note { margin-top: 18px; font-size: 11.5px; line-height: 1.5; color: var(--ink-4); }

/* ============ RAIL ============ */
.rail {
  background: #0f172a;
  color: #e2e8f0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.rail-brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px; }
.rail-logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 2px 8px -2px rgba(0,0,0,.5);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.rail-logo img { width: 30px; height: 30px; object-fit: contain; display: block; }
.rail-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; color: #f8fafc; }
.rail-sub { font-size: 12px; color: #94a3b8; }
.rail-steps { flex: 1; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.rail-step {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  cursor: pointer; border: none; background: none; text-align: left;
  color: #94a3b8; font: inherit; font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  width: 100%;
}
.rail-step:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.rail-step.active { background: rgba(99,102,241,.18); color: #fff; }
.rail-step .dot {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
  border: 1.5px solid #334155; color: #64748b;
  font-family: var(--mono);
  transition: all .15s;
}
.rail-step.active .dot { border-color: var(--brand); background: var(--brand); color: #fff; }
.rail-step.done .dot { border-color: var(--good); background: var(--good); color: #fff; }
.rail-step .lbl { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-step .cnt { font-size: 10.5px; font-family: var(--mono); color: #475569; }
.rail-step.done .cnt { color: var(--good); }
.rail-foot { padding: 16px 20px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.rail-progress-label { font-size: 12px; font-weight: 600; color: #cbd5e1; margin-bottom: 6px; }
.rail-progress-label span { font-family: var(--mono); color: var(--accent); }
.rail-progress-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; }
.rail-progress-fill { height: 100%; border-radius: 3px; background: var(--brand); width: 0%; transition: width .4s ease; }
.rail-note { margin-top: 12px; font-size: 11.5px; color: #64748b; line-height: 1.45; }
.rail-reset {
  margin-top: 10px; font: inherit; font-size: 11.5px; font-weight: 600;
  color: #64748b; background: none; border: none; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; padding: 0;
}
.rail-reset:hover { color: #ef4444; }

/* ============ MAIN ============ */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 36px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.rail-toggle { display: none; }
.topbar-kicker { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.topbar-heading { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.topbar-save {
  margin-left: auto; display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  padding: 6px 12px; border-radius: 999px; background: var(--bg-3);
}
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.topbar-save.saving .save-dot { background: var(--warn); }

.content { flex: 1; padding: 32px 36px 24px; max-width: 880px; width: 100%; margin: 0 auto; }

.section-intro { margin-bottom: 26px; }
.section-intro h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 6px; }
.section-intro p { color: var(--ink-3); max-width: 620px; font-size: 14.5px; }

.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 26px 28px; margin-bottom: 18px;
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-lift); }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 18px; }
.card-title + .fields, .card-title + .grid { margin-top: 16px; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.f label .req { color: var(--accent); margin-left: 2px; }
.f .hint { font-size: 11.5px; color: var(--ink-4); margin-top: -2px; }
.c12 { grid-column: span 12; } .c11 { grid-column: span 11; } .c10 { grid-column: span 10; }
.c9 { grid-column: span 9; } .c8 { grid-column: span 8; } .c7 { grid-column: span 7; }
.c6 { grid-column: span 6; } .c5 { grid-column: span 5; } .c4 { grid-column: span 4; }
.c3 { grid-column: span 3; } .c2 { grid-column: span 2; }

input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99,102,241,.14);
}
input.mono, .mono input { font-family: var(--mono); font-size: 13.5px; }
textarea { min-height: 88px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink-2);
  cursor: pointer; transition: all .13s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(99,102,241,.35); }
.chips.days .chip { padding: 7px 0; width: 46px; text-align: center; font-family: var(--mono); font-size: 12px; }

/* toggle yes/no */
.yn { display: flex; gap: 8px; }
.yn .chip { min-width: 64px; text-align: center; }
.yn .chip.on.no { background: var(--ink-3); border-color: var(--ink-3); box-shadow: none; }
.reveal { grid-column: span 12; display: grid; grid-template-columns: repeat(12,1fr); gap: 14px 16px; padding: 16px; background: var(--bg-2); border-radius: var(--radius); border: 1px dashed var(--line); }

/* repeater */
.rep-list { display: flex; flex-direction: column; gap: 12px; }
.rep-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 14px; background: var(--bg-2);
  position: relative;
}
.rep-item .grid { gap: 10px 12px; }
.rep-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rep-idx { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; }
.rep-del {
  border: none; background: none; cursor: pointer; color: var(--ink-4);
  font-size: 16px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.rep-del:hover { color: var(--bad); background: #fef2f2; }
.rep-add {
  margin-top: 12px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--brand); background: var(--brand-soft);
  border: 1.5px dashed rgba(99,102,241,.4);
  border-radius: var(--radius-sm); padding: 11px;
  width: 100%; cursor: pointer; transition: all .15s;
}
.rep-add:hover { background: #e0e7ff; border-color: var(--brand); }

/* service grid */
.svc-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.svc-table th {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-4); text-align: left; padding: 0 6px 8px 6px; white-space: nowrap;
}
.svc-table td { padding: 3px 3px; vertical-align: middle; }
.svc-table td:first-child { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding-right: 8px; max-width: 140px; }
.svc-table input { padding: 7px 8px; font-size: 13px; }
.svc-wrap { overflow-x: auto; margin: 0 -8px; }
.svc-check { display: grid; place-items: center; }
.svc-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

/* file drop */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 26px; text-align: center; cursor: pointer;
  transition: all .15s; background: var(--bg-2);
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop.uploading { opacity: .6; pointer-events: none; border-color: var(--brand); }
.filepill.error { border-color: #fecaca; background: #fef2f2; }
.drop .ico { font-size: 26px; margin-bottom: 6px; }
.drop .t1 { font-size: 14px; font-weight: 600; }
.drop .t1 span { color: var(--brand); }
.drop .t2 { font-size: 12px; color: var(--ink-4); margin-top: 3px; }
.drop input { display: none; }
.filelist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.filepill {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px;
}
.filepill .fname { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filepill .fsize { font-family: var(--mono); font-size: 11.5px; color: var(--ink-4); }
.filepill .fdel { border: none; background: none; cursor: pointer; color: var(--ink-4); font-size: 14px; }
.filepill .fdel:hover { color: var(--bad); }

/* pager */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 36px 28px; max-width: 880px; width: 100%; margin: 0 auto;
}
.pager-mid { font-size: 12.5px; color: var(--ink-4); font-family: var(--mono); }
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  border-radius: var(--radius-sm); padding: 11px 22px;
  cursor: pointer; transition: all .15s; border: 1.5px solid transparent;
}
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px -4px rgba(99,102,241,.5); }
.btn.primary:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn.ghost { background: var(--bg); border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--ink-4); }
.btn.ghost:disabled { opacity: .4; cursor: default; }
.btn.big { padding: 14px 30px; font-size: 15px; }
.btn.grad { background: var(--brand-2); color: #fff; box-shadow: 0 6px 20px -6px rgba(79,70,229,.5); }
.btn.grad:hover { background: #4338ca; transform: translateY(-1px); box-shadow: 0 10px 26px -6px rgba(79,70,229,.55); }

/* welcome hero */
.hero {
  background: var(--ink); border-radius: var(--radius-lg);
  padding: 40px 42px; color: #e2e8f0; margin-bottom: 22px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px 300px at 90% -20%, rgba(99,102,241,.35), transparent 60%),
              radial-gradient(400px 240px at -5% 110%, rgba(245,158,11,.22), transparent 60%);
  pointer-events: none;
}
.hero .kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: 10px; }
.hero h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; color: #fff; max-width: 560px; line-height: 1.2; margin-bottom: 12px; }
.hero p { max-width: 560px; font-size: 14.5px; color: #94a3b8; }
.hero-stats { display: flex; gap: 28px; margin-top: 26px; position: relative; }
.hstat .n { font-family: var(--mono); font-size: 22px; font-weight: 700; color: #fff; }
.hstat .l { font-size: 12px; color: #64748b; margin-top: 2px; }

/* review */
.rev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.rev-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; transition: all .15s;
}
.rev-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.rev-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.rev-name { font-size: 13.5px; font-weight: 700; }
.rev-pct { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.rev-pct.full { color: var(--good); }
.rev-pct.part { color: var(--warn); }
.rev-pct.none { color: var(--ink-4); }
.rev-track { height: 5px; border-radius: 3px; background: var(--bg-3); overflow: hidden; }
.rev-fill { height: 100%; border-radius: 3px; background: var(--brand); transition: width .3s; }
.rev-fill.full { background: var(--good); }
.rev-missing { font-size: 11.5px; color: var(--ink-4); margin-top: 8px; line-height: 1.4; }
.rev-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius);
  padding: 14px 16px; font-size: 13px; color: #92400e; margin-bottom: 18px;
}
.banner.indigo { background: var(--brand-soft); border-color: #c7d2fe; color: #3730a3; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 50; width: 264px; transform: translateX(-100%); transition: transform .25s; }
  .rail.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .rail-toggle { display: block; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: 15px; cursor: pointer; }
  .content, .pager { padding-left: 20px; padding-right: 20px; }
  .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11 { grid-column: span 12; }
  .rev-grid { grid-template-columns: 1fr; }
  .hero { padding: 28px 24px; }
}
