:root {
      /* Дизайн-токены DAYNET Direct — стандарты: docs/design-system.md */
      --canvas: #FBFBFA;
      --paper: #FFFFFF;
      --bg-subtle: #F4F4F3;
      --bg-inset: #F7F7F6;
      --ink: #111111;
      --ink-2: #333333;
      --muted: #787774;
      --placeholder: #A8A7A4;
      --line: #EAEAEA;
      --line-strong: #D9D9D7;
      --grid: #ECECEA;
      --red: #9F2F2D;
      --red-bg: #FDEBEC;
      --red-line: #EFC3C2;
      --red-line-2: #E4A5A4;
      --blue: #1F6C9F;
      --blue-bg: #E1F3FE;
      --green: #346538;
      --green-bg: #EDF3EC;
      --yellow: #956400;
      --yellow-bg: #FBF3DB;
      --ring: rgba(17, 17, 17, 0.28);
      --shadow-float: 0 1px 2px rgba(17, 17, 17, 0.04), 0 8px 24px rgba(17, 17, 17, 0.05);
      --shadow-pop: 0 2px 4px rgba(17, 17, 17, 0.05), 0 12px 32px rgba(17, 17, 17, 0.07);
      --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
      --ease: cubic-bezier(0.16, 1, 0.3, 1);
      --press: cubic-bezier(0.3, 0.7, 0.4, 1);
    }
    * { box-sizing: border-box; }
    html, body { min-height: 100dvh; }
    body {
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
      font-size: 14px;
      line-height: 1.6;
      background: var(--canvas);
      color: var(--ink);
    }
    .hidden { display: none !important; }
    h1, h2, h3 { letter-spacing: -0.02em; }
    h2 { font-size: 19px; font-weight: 650; margin: 0 0 6px; }
    h3 { font-size: 16px; font-weight: 650; margin: 22px 0 8px; }
    .sub { color: var(--muted); margin: 0 0 4px; }
    .hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
    .mono { font-family: var(--mono); font-size: 13px; }
    a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
    a:hover { color: var(--muted); }

    .card {
      background: var(--paper);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 20px 24px;
      margin-bottom: 16px;
      box-shadow: var(--shadow-float);
    }
    .card h2 + .sub { margin-bottom: 16px; }

    label { display: block; font-size: 12px; font-weight: 600; margin: 0 0 4px; }
    input, textarea, select {
      width: 100%;
      border: 1px solid var(--line);
      background: var(--paper);
      color: var(--ink);
      border-radius: 8px;
      padding: 8px 12px;
      font: inherit;
      outline: none;
      transition: border-color 160ms var(--ease);
    }
    input:focus, textarea:focus, select:focus { border-color: var(--ink); }
    button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
      outline: 2px solid var(--ring);
      outline-offset: 2px;
    }
    input::placeholder, textarea::placeholder { color: var(--placeholder); }
    input[type="checkbox"] { width: 15px; height: 15px; min-height: 0; padding: 0; margin: 0; flex: none; accent-color: var(--ink); }
    textarea { min-height: 112px; resize: vertical; font-family: var(--mono); font-size: 13px; }
    .field { margin-bottom: 16px; min-width: 0; }

    .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
    .row .field { margin: 0; }

    button {
      appearance: none;
      border: 1px solid var(--ink);
      cursor: pointer;
      font: inherit;
      font-size: 13px;
      font-weight: 600;
      border-radius: 6px;
      padding: 8px 16px;
      background: var(--ink);
      color: #FFFFFF;
      transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 100ms var(--press);
    }
    button:hover { background: var(--ink-2); border-color: var(--ink-2); }
    button:active { transform: scale(0.98); }
    button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
    button.ghost:hover { background: var(--bg-subtle); border-color: var(--line-strong); }
    button.danger { background: transparent; color: var(--red); border-color: var(--red-line); }
    button.danger:hover { background: var(--red-bg); border-color: var(--red-line-2); }
    button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
    button.small { padding: 4px 12px; font-size: 13px; }

    .spin {
      display: inline-block;
      width: 12px;
      height: 12px;
      border: 2px solid rgb(255 255 255 / 0.35);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin 700ms linear infinite;
      vertical-align: -2px;
      margin-right: 7px;
    }
    button.ghost .spin, button.danger .spin {
      border-color: rgb(17 17 17 / 0.2);
      border-top-color: currentColor;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .msg { font-size: 13px; color: var(--muted); min-height: 1.2em; margin: 10px 0 0; }
    .msg.err { color: var(--red); }
    .msg.ok { color: var(--green); }

    .pill {
      display: inline-block;
      font-size: 11px;
      font-weight: 650;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      border-radius: 999px;
      padding: 2px 8px;
      vertical-align: 1px;
    }
    .pill.new { background: var(--blue-bg); color: var(--blue); }
    .pill.confirmed { background: var(--yellow-bg); color: var(--yellow); }
    .pill.done { background: var(--green-bg); color: var(--green); }
    .pill.rejected { background: var(--red-bg); color: var(--red); }
    .pill.on { background: var(--green-bg); color: var(--green); }
    .pill.off { background: var(--bg-subtle); color: var(--muted); }

    table.rpt { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 4px; }
    table.rpt th, table.rpt td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
    table.rpt th { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
    table.rpt td.num, table.rpt th.num { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
    table.rpt tr:last-child td { border-bottom: 0; }
    .rpt-sec { margin: 16px 0 0; }
    .rpt-sec:first-of-type { margin-top: 0; }

    .stats {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
      gap: 10px 14px;
      margin: 14px 0;
    }
    .stats div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
    .stats b { display: block; font-family: var(--mono); font-size: 16px; letter-spacing: -0.02em; }
    .stats span { color: var(--muted); font-size: 12px; }

    .empty {
      color: var(--muted);
      border: 1px dashed var(--line);
      border-radius: 10px;
      padding: 22px;
      text-align: center;
      font-size: 13px;
    }
    .skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--line-strong) 50%, var(--bg-subtle) 75%); background-size: 200% 100%; animation: pulse 1.4s infinite; height: 13px; margin: 9px 0; }
    @keyframes pulse { from { background-position: 200% 0; } to { background-position: -200% 0; } }

    /* Логин */
    #gate { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
    #gate .card { width: min(400px, 100%); padding: 32px; }
    #gate h1 { font-size: 24px; margin: 0 0 2px; }
    #gate .tagline { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

    /* Каркас */
    #app { min-height: 100dvh; display: grid; grid-template-columns: 232px 1fr; }
    .rail {
      border-right: 1px solid var(--line);
      background: var(--paper);
      padding: 24px 16px 16px;
      display: flex;
      flex-direction: column;
      gap: 20px;
      position: sticky;
      top: 0;
      height: 100dvh;
      overflow-y: auto;
    }
    .brand h1 { font-size: 16px; margin: 0; }
    .brand .hint { margin: 0; }
    .nav { display: flex; flex-direction: column; gap: 2px; }
    .nav button {
      width: 100%;
      text-align: left;
      background: transparent;
      color: var(--muted);
      border: 0;
      border-radius: 8px;
      padding: 8px 11px;
      font-weight: 600;
    }
    .nav button:hover { background: var(--bg-subtle); color: var(--ink); }
    .nav button.on { background: var(--bg-subtle); color: var(--ink); }
    .rail-sec { border-top: 1px solid var(--line); padding-top: 14px; }
    .rail-sec .hint { margin: 0 0 7px; font-weight: 600; color: var(--ink); font-size: 12px; }
    .conn { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
    .conn b { color: var(--ink); font-weight: 600; }
    .who { font-size: 13px; color: var(--muted); margin: 0 0 8px; word-break: break-all; }
    .rail-foot { margin-top: auto; }

    .stage { padding: 24px 32px 40px; min-width: 0; }
    .stage-inner { max-width: none; }
    .card > p, .card > ol, .card > ul { max-width: 110ch; }

    .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
    .tabs button {
      background: transparent;
      color: var(--muted);
      border: 0;
      border-radius: 6px 6px 0 0;
      padding: 8px 16px 12px;
      font-weight: 600;
      box-shadow: none;
    }
    .tabs button:hover { background: transparent; color: var(--ink); }
    .tabs button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0; }

    .pane { animation: in 240ms var(--ease); }
    @keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

    /* Рекомендации */
    #recs, #reportRecs {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
      gap: 10px;
    }
    #recs > .empty, #reportRecs > .empty { grid-column: 1 / -1; }
    .rec {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--paper);
      padding: 12px 16px;
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 4px 10px;
      align-items: start;
    }
    .rec input[type="checkbox"] { margin-top: 4px; }
    .rec > div { grid-column: 2; }
    .rec-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
    .rec-id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
    .rec-type { font-weight: 650; }
    .rec div.analysis { margin: 0 0 6px; }
    .rec .change { color: var(--muted); font-size: 13px; margin: 0 0 2px; }
    .rec .effect { font-size: 13px; color: var(--green); margin: 0 0 10px; }
    .rec .row input { flex: 1 1 150px; min-width: 0; max-width: none; }

    /* Черновик */
    .grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 8px; margin: 8px 0; }
    .cluster { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 0; }
    .cluster .name { font-weight: 650; }
    .cluster .demand { font-family: var(--mono); color: var(--muted); font-size: 12px; }
    .cluster .phrases { color: var(--muted); font-size: 13px; margin-top: 2px; }
    .row-card .demand { font-family: var(--mono); color: var(--muted); font-size: 12px; font-weight: 400; }
    .phrase-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 13px; }
    .phrase-row .demand { font-family: var(--mono); color: var(--muted); white-space: nowrap; }
    details.phrases-box { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; background: var(--bg-inset); }
    details.phrases-box summary { cursor: pointer; font-size: 13px; color: var(--ink-2); user-select: none; }
    details.phrases-box[open] summary { margin-bottom: 6px; }
    details.phrases-box .chips.scroll { margin-top: 4px; }
    .chips.scroll { max-height: 180px; overflow-y: auto; }
    .llm-sec { border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px 12px; margin-top: 16px; background: var(--bg-inset); }
    .llm-sec h3 { margin: 0 0 2px; }
    .llm-sec .row { margin-top: 12px; }
    .llm-sec .row.end { justify-content: flex-end; }
    .row.between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
    .improve-box { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-inset); padding: 8px 12px; margin: 8px 0; }
    .improve-row { display: flex; gap: 12px; padding: 4px 0; font-size: 13px; }
    .improve-row + .improve-row { border-top: 1px dashed var(--line); }
    .improve-lbl { min-width: 96px; color: var(--muted); }
    .row-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 0; min-width: 0; }
    .row-card .t { font-weight: 650; }
    .row-card .x { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
    .notice-bar { background: #fdf3d7; border: 1px solid #e3cf8f; color: #6a5a20; border-radius: 10px; padding: 8px 14px; font-size: 13px; margin: 10px 14px; }
    .phrase-row span:first-child { overflow-wrap: anywhere; }
    .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
    .chips span {
      font-family: var(--mono);
      font-size: 12px;
      background: var(--bg-subtle);
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 2px 8px;
    }

    /* Тренд */
    .legend { display: flex; gap: 16px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
    .legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--ink); vertical-align: 3px; margin-right: 6px; }
    .legend i.dash { border-top-style: dashed; border-color: var(--red); }

    /* Онбординг */
    .steps { list-style: none; margin: 0; padding: 0; }
    .steps li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
    .steps li:last-child { border-bottom: 0; }
    .dot {
      flex: 0 0 auto;
      width: 9px; height: 9px;
      border-radius: 50%;
      border: 1.5px solid var(--line);
      background: var(--paper);
      display: inline-block;
      vertical-align: 0;
    }
    .dot.done { background: var(--green); border-color: var(--green); }

    /* Люди */
    .stats.people { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
    .split { display: grid; grid-template-columns: 230px 1fr; gap: 12px; align-items: start; }
    .pick { display: flex; flex-direction: column; gap: 2px; }
    .pick button {
      width: 100%;
      text-align: left;
      background: transparent;
      color: var(--ink);
      border-color: transparent;
      border-radius: 8px;
      padding: 8px 12px;
      font-weight: 600;
    }
    .pick button:hover { background: var(--bg-subtle); }
    .pick button.on { background: var(--bg-subtle); border-color: transparent; }
    .pick .st { margin-top: 2px; font-weight: 500; }

    pre.plate {
      white-space: pre-wrap;
      background: var(--bg-inset);
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 14px 16px;
      overflow: auto;
      font-family: var(--mono);
      font-size: 13px;
      color: var(--ink);
      margin: 12px 0 0;
      max-height: 420px;
    }

    .st { font-size: 13px; color: var(--muted); }
    .st.on { color: var(--green); font-weight: 600; }
    .st.err { color: var(--red); }
    .pri { margin: 8px 0 12px; padding-left: 1.2em; }
    .pri li { margin: 0 0 6px; }
    .risks { color: var(--red); margin: 8px 0 12px; padding-left: 1.2em; }
    kbd {
      font-family: var(--mono);
      font-size: 12px;
      border: 1px solid var(--line);
      border-radius: 4px;
      background: var(--bg-inset);
      padding: 2px 6px;
    }
    #view-help h3 { margin-top: 26px; }
    #view-help p, #view-help li { line-height: 1.65; }
    #view-help table.rpt td:first-child { font-weight: 600; width: 26%; }
    #view-help table.rpt th, #view-help table.rpt td { white-space: normal; vertical-align: top; }

    @media (max-width: 860px) {
      #app { grid-template-columns: 1fr; }
      .rail {
        position: static;
        height: auto;
        flex-direction: column;
        border-right: 0;
        border-bottom: 1px solid var(--line);
      }
      .rail-foot { margin-top: 0; }
      .stage { padding: 16px 12px 40px; }
      .stats, .stats.people { grid-template-columns: repeat(2, 1fr); }
      #recs, #reportRecs, .grid2 { grid-template-columns: 1fr; }
      .split { grid-template-columns: 1fr; }
    }
    @media (prefers-reduced-motion: reduce) {
      * { animation: none !important; transition: none !important; }
    }

.button-link { display: inline-block; padding: 4px 12px; border: 1px solid var(--ink); border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; background: var(--paper); }
.button-link:hover { background: var(--bg-subtle); }
.nav a { display: block; padding: 8px 10px; color: var(--ink); text-decoration: none; border-radius: 6px; font-size: 14px; }
.nav a.on { background: var(--bg-subtle); font-weight: 650; }
.nav a:hover { background: var(--bg-subtle); }
.gate-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.gate-wrap .card { width: 420px; }
