:root {
  --ink: #17201c;
  --muted: #64716b;
  --paper: #f4f1e9;
  --card: #fffefa;
  --line: #dedbd2;
  --green: #08785c;
  --green-bright: #20c997;
  --green-pale: #dff5ec;
  --orange: #e7723c;
  --shadow: 0 18px 50px rgba(31, 40, 35, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar { height: 68px; padding: 0 max(28px, calc((100vw - 1200px) / 2)); background: #101c18; color: white; display: flex; align-items: center; justify-content: space-between; }
.brand { color: white; text-decoration: none; display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 31px; height: 31px; border-radius: 9px 9px 9px 2px; background: var(--green-bright); color: #0f3328; display: grid; place-items: center; font-weight: 900; }
.mode-pill { color: #bfd1ca; font-size: 11px; font-weight: 800; letter-spacing: .12em; display: flex; align-items: center; gap: 8px; }
.top-actions { display: flex; align-items: center; gap: 18px; }
.reset-button { border: 1px solid #40534c; border-radius: 6px; background: transparent; color: #d4dfda; padding: 7px 10px; font-size: 10px; font-weight: 750; }
.reset-button:hover { color: white; border-color: var(--green-bright); }
.pulse { width: 8px; height: 8px; background: var(--green-bright); border-radius: 50%; box-shadow: 0 0 0 4px rgba(32,201,151,.14); }

main { max-width: 1200px; margin: auto; padding: 0 28px 70px; }
.hero { min-height: 300px; display: flex; justify-content: space-between; align-items: center; gap: 50px; padding: 52px 3px 42px; }
.eyebrow, .step { color: var(--green); font-size: 10px; line-height: 1; letter-spacing: .18em; font-weight: 850; }
h1 { margin: 12px 0 16px; font-family: Georgia, serif; font-size: clamp(40px, 5vw, 64px); line-height: .98; letter-spacing: -.045em; font-weight: 500; }
h1 em { color: var(--green); font-weight: 500; }
.lead { color: var(--muted); max-width: 585px; font-size: 17px; }
.flow { min-width: 470px; display: flex; align-items: center; justify-content: flex-end; }
.flow div { display: flex; align-items: center; gap: 10px; }
.flow b { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid #c4c2bb; border-radius: 50%; color: var(--green); font-size: 11px; }
.flow span { font-size: 11px; line-height: 1.25; font-weight: 700; }
.flow i { width: 42px; height: 1px; background: #c8c6be; margin: 0 11px; }

.workspace { display: grid; grid-template-columns: 1.08fr .92fr; gap: 22px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 27px; }
.fsconnect-source { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin: -27px -27px 18px; padding: 16px 20px; color: white; background: #142b23; border-radius: 12px 12px 0 0; }
.fs-logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--green-bright); color: #103128; font-weight: 950; letter-spacing: -.08em; }
.fs-copy { display: flex; flex-direction: column; }
.fs-copy .step { color: #74dfbd; }
.fs-copy strong { margin-top: 4px; font-size: 13px; }
.fs-copy small { color: #9bb5ab; font-size: 9px; }
.sync-button { border: 1px solid #426057; border-radius: 6px; padding: 7px 9px; background: transparent; color: #d8e5df; font-size: 10px; font-weight: 800; }
.sync-button:hover { border-color: var(--green-bright); color: white; }
.fs-course-list { display: grid; gap: 7px; margin-bottom: 22px; }
.fs-course { width: 100%; border: 1px solid #dfddd5; border-radius: 8px; background: #faf9f5; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; text-align: left; color: var(--ink); }
.fs-course:hover, .fs-course.selected { border-color: var(--green); background: #f0f8f4; }
.fs-course strong { font-size: 12px; }
.fs-course small { color: var(--muted); font-size: 9px; }
.fs-course .needs-replacement { grid-row: 1 / 3; grid-column: 2; align-self: center; color: #a45127; background: #ffeadc; padding: 4px 7px; border-radius: 99px; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.source-chip { display: inline-flex; align-items: center; gap: 5px; margin-left: 7px; padding: 3px 6px; border-radius: 4px; background: #e8f5ef; color: var(--green); font: 800 8px/1 sans-serif; vertical-align: 2px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.card-head.compact { margin-bottom: 15px; }
h2 { margin: 6px 0 0; font: 500 25px/1.1 Georgia, serif; letter-spacing: -.02em; }
.shield { background: var(--green-pale); color: var(--green); border-radius: 999px; font-size: 11px; padding: 6px 9px; font-weight: 800; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
label { display: block; color: #53605a; font-size: 11px; font-weight: 800; letter-spacing: .035em; margin: 0 0 15px; }
input, textarea, select { width: 100%; margin-top: 6px; border: 1px solid #d8d6cf; border-radius: 7px; background: #fff; padding: 11px 12px; color: var(--ink); outline: none; font-weight: 550; transition: .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8,120,92,.1); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 8px 0 18px; }
legend { width: 100%; display: flex; justify-content: space-between; font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
legend small { color: var(--green); font-weight: 750; text-transform: none; letter-spacing: 0; }
.trainer-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.trainer { display: grid; grid-template-columns: auto auto 1fr auto; gap: 11px; align-items: center; padding: 11px 13px; border-bottom: 1px solid #e9e6df; margin: 0; cursor: pointer; }
.trainer:last-child { border: 0; }
.trainer:hover { background: #faf9f4; }
.trainer input { width: 16px; height: 16px; accent-color: var(--green); margin: 0; }
.avatar { width: 31px; height: 31px; background: #e9ede7; border-radius: 50%; display: grid; place-items: center; color: var(--green); font-weight: 850; font-size: 11px; }
.trainer-name { font-size: 13px; color: var(--ink); display: block; }
.trainer-phone { color: #87918c; font-size: 9px; font-weight: 500; }
.trainer-groups { color: var(--green); font-size: 8px; font-weight: 750; display: block; }
.test-phone { width: 190px; margin: 0; padding: 8px 10px; border-radius: 5px; font-size: 11px; color: #5d6963; }
.phone-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.phone-wrap small { color: #9a9285; font-size: 8px; }
.window-badge { color: #867f73; font-size: 9px; background: #f1eee7; padding: 4px 7px; border-radius: 99px; }
.window-badge.open { color: var(--green); background: var(--green-pale); }
.policy-note { display: flex; align-items: flex-start; gap: 10px; background: #f3f6f1; border-radius: 8px; padding: 12px; color: #5e6963; margin-bottom: 16px; }
.policy-note > span { color: var(--green); }
.policy-note p { margin: 0; font-size: 10px; }
.policy-note strong { display: block; color: #33423b; font-size: 11px; }
.meta-test-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; border: 1px solid #b8ded0; background: #edfaf5; border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.meta-test-panel[hidden] { display: none; }
.meta-test-panel > div { display: flex; flex-direction: column; }
.meta-test-panel strong { margin-top: 4px; font-size: 12px; }
.meta-test-panel small { color: var(--muted); font-size: 9px; }
.meta-test-panel button { border: 0; border-radius: 6px; background: #142b23; color: white; padding: 9px 11px; font-size: 10px; font-weight: 800; }
.primary { width: 100%; border: 0; border-radius: 7px; padding: 13px 15px; background: var(--green); color: #fff; display: flex; justify-content: space-between; align-items: center; font-weight: 800; box-shadow: 0 8px 20px rgba(8,120,92,.2); }
.primary:hover { background: #056b52; transform: translateY(-1px); }
.primary:disabled { opacity: .55; cursor: wait; transform: none; }
.form-status { min-height: 0; margin: 10px 0 -8px; color: var(--orange); font-size: 11px; }

.right-column { display: grid; gap: 22px; }
.icon-button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--green); }
.empty-state { text-align: center; padding: 30px 15px 34px; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin: 11px 0 4px; font-family: Georgia, serif; font-weight: 500; }
.empty-state p { max-width: 280px; margin: auto; font-size: 12px; }
.empty-icon { margin: auto; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: var(--green); background: var(--green-pale); font-size: 22px; }
.incident { border: 1px solid var(--line); border-radius: 9px; margin-top: 10px; overflow: hidden; }
.incident-top { display: flex; justify-content: space-between; gap: 10px; padding: 14px; background: #f8f7f2; }
.incident h3 { font: 500 17px Georgia, serif; margin: 0 0 4px; }
.incident p { margin: 0; color: var(--muted); font-size: 11px; }
.status { align-self: flex-start; padding: 4px 7px; border-radius: 99px; font-size: 9px; font-weight: 850; text-transform: uppercase; }
.status.open { background: #fff0d8; color: #9f6213; }
.status.assigned { background: var(--green-pale); color: var(--green); }
.incident-body { padding: 12px 14px; }
.candidate-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 11px; border-bottom: 1px solid #ece9e2; }
.candidate-row:last-child { border: 0; }
.candidate-row span:last-child { color: var(--muted); }
.candidate-row.winner { color: var(--green); font-weight: 800; }
.simulate { width: 100%; border: 1px solid var(--green); background: white; color: var(--green); padding: 9px; border-radius: 6px; font-size: 11px; font-weight: 800; margin-top: 10px; }
.connected { color: var(--green); font-size: 9px; font-weight: 850; }
.connected i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green-bright); }
.event-list { max-height: 260px; overflow: auto; }
.event { display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid #ece9e2; }
.event-dot { width: 7px; height: 7px; background: var(--green-bright); border-radius: 50%; margin-top: 5px; }
.event b { display: block; font-size: 11px; }
.event span, .event time { color: var(--muted); font-size: 9px; }
.muted { color: var(--muted); font-size: 11px; }

dialog { width: min(440px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 13px; padding: 0; box-shadow: 0 30px 100px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(9,24,19,.64); backdrop-filter: blur(4px); }
.dialog-content { padding: 28px; position: relative; }
.dialog-content > p { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
.dialog-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; font-size: 24px; color: var(--muted); }
.toast { visibility: hidden; position: fixed; right: 24px; bottom: 24px; background: #101c18; color: #fff; border-radius: 8px; padding: 12px 17px; box-shadow: var(--shadow); font-size: 12px; transform: translateY(10px); opacity: 0; transition: .2s; }
.toast.show { visibility: visible; transform: none; opacity: 1; }

@media (max-width: 900px) {
  .hero { display: block; }
  .flow { min-width: 0; justify-content: flex-start; margin-top: 35px; }
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 0 16px 50px; }
  .topbar { padding: 0 16px; }
  .hero { padding-top: 40px; min-height: 0; }
  .flow { display: none; }
  .grid.two { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 20px; }
  .fsconnect-source { margin: -20px -20px 18px; }
  .sync-button { grid-column: 2 / 4; }
  .window-badge { display: none; }
  .mode-pill { display: none; }
  .trainer { grid-template-columns: auto auto 1fr; }
  .phone-wrap { grid-column: 2 / 4; width: 100%; align-items: stretch; }
  .test-phone { width: 100%; }
  .meta-test-panel { grid-template-columns: 1fr; }
}
