  :root {
    --accent: #ED7044;
    --accent-soft: #FDEEE7;
    --accent-dark: #C9552C;
    --text: #1A1D24;
    --muted: #5E6470;
    --line: #E6E7EB;
    --bg: #F7F6F3;
    --card: #FFFFFF;
    --yes: #23835A; --yes-bg: #E2F3EA;
    --maybe: #9A6A12; --maybe-bg: #FBF0D5;
    --no: #7A808B; --no-bg: #EFF0F2;
    --radius: 14px;
  }
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    padding-bottom: 96px;
  }
  h1, h2, h3 { font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
  h1 { font-size: clamp(26px, 5vw, 34px); line-height: 1.15; }
  h2 { font-size: 20px; }
  h3 { font-size: 17px; }
  .wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
  .topbar { background: #fff; border-bottom: 1px solid var(--line); }
  .topbar .wrap { display: flex; align-items: center; gap: 10px; height: 56px; font-family: "Plus Jakarta Sans", Inter, sans-serif; font-weight: 700; font-size: 15px; }
  .topbar img { display: block; border-radius: 6px; }
  header { padding: 36px 0 24px; }
  .sub { color: var(--muted); margin-top: 6px; font-size: 16px; }
  input:-webkit-autofill { -webkit-box-shadow: 0 0 0 40px #fff inset; -webkit-text-fill-color: var(--text); }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
  .admin-banner { background: var(--text); color: #fff; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
  .section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
  .section-title h2 { font-size: 22px; }

  /* Name step */
  .name-row { display: flex; gap: 10px; margin-top: 12px; }
  input[type=text] {
    flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text);
    padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  }
  input[type=text]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  button { font: inherit; cursor: pointer; }
  .btn {
    background: var(--accent); color: #fff; border: 0; border-radius: 10px;
    padding: 12px 18px; font-weight: 600; white-space: nowrap;
  }
  .btn:hover { background: var(--accent-dark); }
  .btn:disabled { opacity: .5; cursor: default; }
  .btn-ghost { background: transparent; color: var(--accent-dark); border: 0; padding: 4px 6px; font-weight: 600; font-size: 13px; }
  .hint { color: var(--muted); font-size: 13px; margin-top: 10px; min-height: 1.5em; }
  .hint.ok { color: var(--yes); }

  /* Quarter form */
  #form.locked { opacity: .45; pointer-events: none; filter: grayscale(.3); }
  .q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); margin-left: 8px; vertical-align: 2px; }
  .q-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
  .note { margin-top: 10px; background: #FFF8F4; border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 14px; }
  .bulk { font-size: 13px; color: var(--muted); }
  .dates { margin-top: 14px; border-top: 1px solid var(--line); }
  .date-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .date-row:last-child { border-bottom: 0; }
  .date-label { font-weight: 600; }
  .date-label small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
  .seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
  .seg button {
    border: 0; background: #fff; color: var(--muted); padding: 9px 12px; font-size: 14px; font-weight: 500;
    min-width: 54px; border-right: 1.5px solid var(--line);
  }
  .seg button:last-child { border-right: 0; }
  .seg button[aria-pressed=true][data-v=y] { background: var(--yes-bg); color: var(--yes); font-weight: 600; }
  .seg button[aria-pressed=true][data-v=m] { background: var(--maybe-bg); color: var(--maybe); font-weight: 600; }
  .seg button[aria-pressed=true][data-v=n] { background: var(--no-bg); color: var(--text); font-weight: 600; }

  /* Save bar */
  .savebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  }
  .savebar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .progress { font-size: 14px; color: var(--muted); }
  .progress b { color: var(--text); }

  /* Results grid */
  .grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 14px -20px -20px; padding: 0 0 4px; }
  table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
  .grid th, .grid td { text-align: center; padding: 6px 4px; border-bottom: 1px solid var(--line); min-width: 52px; }
  .grid th.name, .grid td.name {
    position: sticky; left: 0; background: #fff; text-align: left; min-width: 130px; max-width: 180px;
    padding-left: 20px; z-index: 1; border-right: 1px solid var(--line); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .grid thead th { font-weight: 500; color: var(--muted); line-height: 1.2; vertical-align: bottom; padding-top: 10px; }
  .grid thead th .d { display: block; font-family: "Plus Jakarta Sans", Inter, sans-serif; font-weight: 700; font-size: 17px; color: var(--text); }
  .grid thead th .m { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
  .cell { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 28px; border-radius: 7px; font-weight: 700; }
  .cell.y { background: var(--yes-bg); color: var(--yes); }
  .cell.m { background: var(--maybe-bg); color: var(--maybe); }
  .cell.n { background: var(--no-bg); color: var(--no); font-weight: 500; }
  .cell.x { color: #C3C6CC; font-weight: 400; }
  .grid tr.me td.name { color: var(--accent-dark); font-weight: 600; }
  .grid tfoot td { border-bottom: 0; padding-top: 8px; padding-bottom: 12px; vertical-align: top; }
  .grid tfoot td.name { font-weight: 600; }
  .count { font-family: "Plus Jakarta Sans", Inter, sans-serif; font-weight: 700; font-size: 17px; line-height: 1.1; }
  .count small { display: block; font-family: Inter, sans-serif; font-weight: 500; font-size: 11px; color: var(--maybe); }
  .grid .best { background: var(--accent-soft); }
  .grid thead th.best { border-top: 3px solid var(--accent); border-radius: 8px 8px 0 0; }
  .grid tfoot td.best { border-radius: 0 0 8px 8px; }
  .grid tfoot td.best .count { color: var(--accent-dark); }
  .best-flag { display: block; font-size: 10px; font-weight: 700; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
  .best-line { margin-top: 6px; font-size: 14px; }
  .best-line b { color: var(--accent-dark); }
  .empty { color: var(--muted); font-size: 14px; margin-top: 12px; }
  .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
  .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .legend .cell { width: 24px; height: 20px; font-size: 12px; }
  .del { border: 0; background: none; color: #B42318; font-weight: 700; padding: 0 6px; margin-right: 4px; font-size: 15px; }
  .note-inline { color: var(--accent-dark); font-weight: 500; }
  .unsaved { color: var(--accent-dark); font-weight: 500; }
  .toast {
    position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
    transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
    background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
    width: max-content; max-width: min(440px, calc(100vw - 32px)); text-align: center; box-shadow: 0 6px 24px rgba(26,29,36,.18);
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  .toast.err { background: #B42318; }
  footer { color: var(--muted); font-size: 12px; text-align: center; margin: 32px 0 8px; }

  @media (max-width: 560px) {
    .card { padding: 16px; }
    .grid-wrap { margin: 14px -16px -16px; }
    .grid th.name, .grid td.name { padding-left: 16px; min-width: 104px; max-width: 120px; }
    .date-row { flex-wrap: wrap; gap: 8px; }
    .seg { width: 100%; }
    .seg button { flex: 1; padding: 10px 6px; }
  }
