:root {
    --bg: #0b1120;
    --bg-soft: radial-gradient(1200px 600px at 15% -10%, #16213f 0%, transparent 55%),
               radial-gradient(1000px 500px at 100% 0%, #1a1830 0%, transparent 50%),
               #0b1120;
    --bg-panel: #121a2e;
    --bg-panel-raised: #16203a;
    --bg-card: #1a2440;
    --border: #263252;
    --border-soft: #1d2740;
    --text: #eef1f8;
    --text-dim: #8b94ac;
    --text-faint: #5c6785;
    --accent: #5fc6e8;
    --accent-soft: rgba(95,198,232,.14);
    --gold: #e8b95f;
    --gold-soft: rgba(232,185,95,.14);
    --green: #4ade9a;
    --green-soft: rgba(74,222,154,.14);
    --amber: #f5b25a;
    --amber-soft: rgba(245,178,90,.14);
    --red: #f2707a;
    --red-soft: rgba(242,112,122,.14);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --ease: cubic-bezier(.16,1,.3,1);
    --header-bg: rgba(18,26,46,.7);
    --nav-bg: rgba(18,26,46,.4);
  }
  :root[data-theme="light"] {
    --header-bg: rgba(255,255,255,.7);
    --nav-bg: rgba(255,255,255,.5);
    --bg: #f4f2ec;
    --bg-soft: radial-gradient(1200px 600px at 15% -10%, #e9e4d6 0%, transparent 55%),
               radial-gradient(1000px 500px at 100% 0%, #eae1ee 0%, transparent 50%),
               #f4f2ec;
    --bg-panel: #ffffff;
    --bg-panel-raised: #f4f1e8;
    --bg-card: #fbfaf5;
    --border: #ddd7c5;
    --border-soft: #e7e2d3;
    --text: #21201c;
    --text-dim: #635f54;
    --text-faint: #928d7e;
    --accent: #1c8fb0;
    --accent-soft: rgba(28,143,176,.12);
    --gold: #b4791f;
    --gold-soft: rgba(180,121,31,.14);
    --green: #1c9a63;
    --green-soft: rgba(28,154,99,.14);
    --amber: #c07d1a;
    --amber-soft: rgba(192,125,26,.14);
    --red: #c93f4a;
    --red-soft: rgba(201,63,74,.12);
  }
  * { box-sizing: border-box; }
  ::selection { background: var(--accent-soft); color: var(--text); }
  body {
    font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg-soft);
    background-attachment: fixed;
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }
  body.auth-locked {
    overflow: hidden;
  }
  body.auth-locked > :not(.login-overlay) {
    display: none !important;
  }
  .serif { font-family: "Source Serif 4", Georgia, serif; }

  .login-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-soft);
    overflow: hidden;
  }
  body.auth-locked .login-overlay {
    display: flex;
  }
  .login-scene { position: absolute; inset: 0; pointer-events: none; }
  .login-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .55;
    animation: loginDrift 16s ease-in-out infinite alternate;
  }
  .login-glow-a { width: 420px; height: 420px; top: -120px; left: -80px; background: var(--accent-soft); }
  .login-glow-b { width: 520px; height: 520px; bottom: -160px; right: -120px; background: var(--gold-soft); animation-delay: -8s; }
  @keyframes loginDrift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(42px, 26px, 0) scale(1.12); }
  }
  .login-card {
    position: relative;
    width: min(100%, 420px);
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: calc(var(--radius-lg) + 6px);
    padding: 34px 32px 24px;
    box-shadow: 0 34px 80px rgba(0, 0, 0, .35);
    animation: loginRise .5s var(--ease) both;
  }
  @keyframes loginRise {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  .login-brand { text-align: center; margin-bottom: 24px; }
  .login-mark {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: linear-gradient(160deg, var(--accent-soft), transparent 72%);
    border: 1px solid var(--border);
    border-radius: 18px;
  }
  .login-mark svg { width: 27px; height: 27px; }
  .login-brand h2 { margin: 0; font-size: 1.5rem; }
  .login-brand h2 em { font-style: normal; color: var(--accent); }
  .login-sub { margin: 7px 0 0; color: var(--text-dim); font-size: .84rem; }
  .login-field { margin-bottom: 14px; }
  .login-field label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-faint);
    margin-bottom: 7px;
  }
  .login-input-wrap { position: relative; display: flex; align-items: center; }
  .login-input-icon {
    position: absolute;
    left: 13px;
    width: 17px;
    height: 17px;
    color: var(--text-faint);
    pointer-events: none;
    transition: color .2s var(--ease);
  }
  .login-input-wrap:focus-within .login-input-icon { color: var(--accent); }
  .login-input-wrap select,
  .login-input-wrap input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: .92rem;
    padding: 12px 42px 12px 40px;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
    appearance: none;
  }
  .login-input-wrap select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a0b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 16px;
  }
  .login-input-wrap select:focus,
  .login-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .login-input-wrap input::placeholder { color: var(--text-faint); letter-spacing: .18em; }
  .login-eye {
    position: absolute;
    right: 7px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color .18s var(--ease), background .18s var(--ease);
  }
  .login-eye:hover { color: var(--text); background: var(--accent-soft); }
  .login-eye svg { width: 18px; height: 18px; }
  .login-eye .eye-closed { display: none; }
  .login-eye.visible .eye-open { display: none; }
  .login-eye.visible .eye-closed { display: block; }
  .login-capslock { margin: 7px 2px 0; font-size: .76rem; color: var(--amber); }
  .login-status {
    min-height: 18px;
    margin: 2px 2px 10px;
    font-size: .8rem;
    color: var(--red);
  }
  .login-submit {
    position: relative;
    width: 100%;
    padding: 13px 18px;
    font-size: .95rem;
  }
  .login-spinner {
    position: absolute;
    right: 16px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: currentColor;
    border-radius: 50%;
    opacity: 0;
    animation: loginSpin .7s linear infinite;
  }
  .login-submit.loading { pointer-events: none; filter: saturate(.8); }
  .login-submit.loading .login-spinner { opacity: 1; }
  @keyframes loginSpin { to { transform: rotate(360deg); } }
  .login-foot {
    margin: 16px 0 0;
    text-align: center;
    color: var(--text-faint);
    font-size: .74rem;
  }
  .login-card.login-error { animation: loginShake .4s var(--ease); }
  @keyframes loginShake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
  }
  @media (prefers-reduced-motion: reduce) {
    .login-glow, .login-card, .login-card.login-error { animation: none; }
  }

  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--header-bg);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  header .brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }
  header h1 {
    font-family: "Source Serif 4", serif;
    font-size: 1.35rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: .01em;
  }
  header h1 em {
    font-style: normal;
    color: var(--accent);
  }
  header .tagline {
    color: var(--text-faint);
    font-size: .74rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-left: 1px solid var(--border);
    padding-left: 10px;
  }
  .status {
    font-size: .8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .header-right { display: flex; align-items: center; gap: 16px; }
  .theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-dim);
    transition: border-color .18s var(--ease), color .18s var(--ease);
  }
  .theme-toggle:hover { border-color: var(--accent); color: var(--text); }
  .theme-toggle svg { width: 16px; height: 16px; }
  :root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  .header-action {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    padding: 8px 10px;
    transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
  }
  .header-action:hover,
  .header-action:focus-visible {
    border-color: var(--accent);
    color: var(--text);
    background: var(--bg-panel-raised);
    outline: none;
  }
  .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    display: inline-block;
    box-shadow: 0 0 0 3px var(--green-soft);
    animation: pulse 2.4s ease-in-out infinite;
  }
  .dot.off {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
    animation: none;
  }
  @keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--green-soft); }
    50% { box-shadow: 0 0 0 6px var(--green-soft); }
  }

  nav {
    display: flex;
    gap: 2px;
    padding: 0 32px;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border-soft);
    overflow-x: auto;
  }
  nav button {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 14px 18px;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    position: relative;
    transition: color .2s var(--ease);
  }
  nav button:hover { color: var(--text); }
  nav button.active {
    color: var(--text);
    border-bottom-color: var(--accent);
  }
  nav button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 4px;
  }
  nav button[hidden] {
    display: none !important;
  }

  main {
    padding: 36px 32px 60px;
    max-width: 1320px;
    margin: 0 auto;
  }
  section {
    display: none;
  }
  section.active {
    display: block;
    animation: rise .38s var(--ease);
  }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
  }
  h2 {
    font-family: "Source Serif 4", serif;
    font-size: 1.6rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: -.01em;
  }
  .hint {
    color: var(--text-dim);
    font-size: .84rem;
    margin: 0;
    max-width: 46ch;
    text-align: right;
  }

  /* Воронка */
  .pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    align-items: start;
  }
  .pipeline-col {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 12px;
    min-height: 220px;
  }
  .pipeline-col h3 {
    font-size: .74rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 6px 6px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-weight: 700;
  }
  .pipeline-col h3 small {
    color: var(--text-faint);
    font-size: .62rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
  }
  .pipeline-col h3 span {
    background: var(--bg-card);
    color: var(--text-dim);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .7rem;
  }
  .pipeline-col.hot h3 span {
    background: var(--gold-soft);
    color: var(--gold);
  }
  .deal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 13px;
    margin-bottom: 9px;
    font-size: .85rem;
    box-shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 20px -14px rgba(0,0,0,.6);
    transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
  }
  .deal-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 14px 30px -16px rgba(95,198,232,.35);
  }
  .deal-card .name { font-weight: 600; margin-bottom: 5px; letter-spacing: -.005em; }
  .deal-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 7px 0 8px;
  }
  .deal-card .contact {
    color: var(--text-dim);
    font-size: .76rem;
    word-break: break-word;
  }
  .deal-card .sum { color: var(--green); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
  .deal-card .sum.empty { color: var(--text-faint); font-weight: 400; }
  .deal-card .wait { color: var(--text-faint); font-size: .75rem; margin-top: 6px; }
  .deal-card .wait.warn { color: var(--amber); }
  .deal-card .wait.warn::before { content: "● "; font-size: .6rem; }
  .deal-card .actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
  }
  .deal-card .actions .btn {
    padding: 6px 9px;
    font-size: .74rem;
  }

  /* Клиенты */
  .table-wrap {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
  table { width: 100%; border-collapse: collapse; }
  th, td {
    text-align: left;
    padding: 13px 18px;
    font-size: .86rem;
    border-bottom: 1px solid var(--border-soft);
  }
  th {
    color: var(--text-faint);
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--bg-panel-raised);
  }
  tbody tr { transition: background .18s var(--ease); }
  tbody tr:hover { background: rgba(255,255,255,.02); }
  tr:last-child td { border-bottom: none; }
  td.name { font-weight: 600; }
  td.handle { color: var(--text-dim); font-variant-numeric: tabular-nums; }
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
  }
  .badge::before {
    content: "";
    width: 5px; height: 5px; border-radius: 50%;
    background: currentColor;
  }
  .badge.stage-deal { background: var(--green-soft); color: var(--green); }
  .badge.stage-proposal { background: var(--amber-soft); color: var(--amber); }
  .badge.stage-lost { background: var(--red-soft); color: var(--red); }
  .badge.status-done { background: var(--green-soft); color: var(--green); }
  .badge.status-refused { background: var(--red-soft); color: var(--red); }
  .badge.status-postponed { background: var(--amber-soft); color: var(--amber); }
  .badge.warn { background: var(--amber-soft); color: var(--amber); }
  .row-note { color: var(--text-faint); font-size: .74rem; margin-top: 4px; }
  .subhead {
    font-family: "Source Serif 4", serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 28px 0 14px;
  }

  /* Финансы */
  .stats {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 28px;
  }
  .stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    transition: transform .22s var(--ease), border-color .22s var(--ease);
  }
  .stat-card:hover { transform: translateY(-2px); border-color: var(--border); }
  .stat-card.primary {
    background: linear-gradient(150deg, var(--bg-panel-raised) 0%, var(--bg-panel) 65%);
    border-color: var(--border);
  }
  .stat-card .label {
    color: var(--text-faint);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    margin-bottom: 10px;
  }
  .stat-card .value {
    font-family: "Source Serif 4", serif;
    font-size: 2.1rem;
    font-weight: 600;
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
  }
  .stat-card strong {
    display: block;
    font-family: "Source Serif 4", serif;
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.1;
  }
  .stats.compact .stat-card {
    padding: 16px 18px;
  }
  .stat-card.primary .value { font-size: 2.4rem; color: var(--accent); }
  .stat-card.primary strong { color: var(--accent); }
  .stat-card .delta {
    margin-top: 8px;
    font-size: .78rem;
    color: var(--green);
    font-weight: 600;
  }
  .stat-card .delta.neutral { color: var(--text-faint); }

  .home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 22px;
  }
  .home-command-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 10px;
    margin: -8px 0 22px;
  }
  .home-command-btn {
    display: grid;
    gap: 4px;
    text-align: left;
    min-height: 76px;
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: transform .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
  }
  .home-command-btn:hover,
  .home-command-btn:focus-visible {
    transform: translateY(-2px);
    border-color: var(--accent);
    background: var(--bg-panel-raised);
    outline: none;
  }
  .home-command-btn.warn { border-left-color: var(--amber); }
  .home-command-btn.danger { border-left-color: var(--red); }
  .home-command-btn strong {
    font-size: .9rem;
    line-height: 1.2;
  }
  .home-command-btn span {
    color: var(--text-dim);
    font-size: .76rem;
    line-height: 1.35;
  }
  .home-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px;
  }
  .home-panel h3 {
    margin: 0 0 14px;
    font-size: .84rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-faint);
  }
  .home-actions {
    display: grid;
    gap: 10px;
  }
  .home-action {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    color: var(--text-dim);
    font-size: .86rem;
  }
  .home-action[role="button"] {
    cursor: pointer;
  }
  .home-action[role="button"]:hover strong,
  .home-action[role="button"]:focus-visible strong {
    color: var(--accent);
  }
  .home-action[role="button"]:focus-visible {
    outline: 2px solid var(--accent-soft);
    outline-offset: 3px;
  }
  .home-action::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .home-action.warn::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
  .home-action.danger::before { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
  .home-action strong {
    color: var(--text);
    font-weight: 700;
  }
  .home-next-review {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-card);
  }
  .home-next-review.attention {
    border-color: rgba(245,178,90,.38);
    background: var(--amber-soft);
  }
  .home-next-review strong {
    color: var(--text);
    font-size: .96rem;
    overflow-wrap: anywhere;
  }
  .home-next-review .meta {
    color: var(--text-dim);
    font-size: .8rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }
  .home-next-review .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .order-assist {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.2fr);
    gap: 14px;
    align-items: stretch;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-card);
  }
  .order-assist h4 {
    margin: 0 0 8px;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-faint);
  }
  .order-assist .checklist {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .order-assist .checklist li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-dim);
    font-size: .82rem;
  }
  .order-assist .checklist strong { color: var(--text); font-weight: 700; }
  .order-assist .telegram-preview {
    min-height: 154px;
    white-space: pre-wrap;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--bg);
    color: var(--text-dim);
    font-size: .84rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }
  .order-assist .assist-ok { color: var(--green); }
  .order-assist .assist-warn { color: var(--amber); }

  .guide-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
  }
  .guide-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px;
  }
  .guide-panel.wide { grid-column: 1 / -1; }
  .guide-panel h3 {
    margin: 0 0 12px;
    font-size: .92rem;
    color: var(--text);
  }
  .guide-panel p {
    margin: 0 0 12px;
    color: var(--text-dim);
    line-height: 1.55;
    font-size: .9rem;
  }
  .guide-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .guide-list li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    color: var(--text-dim);
    font-size: .88rem;
    line-height: 1.45;
  }
  .guide-step {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }
  .guide-example {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-dim);
    font-size: .86rem;
    line-height: 1.5;
  }
  .guide-example strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text);
  }
  .home-action span:last-child {
    color: var(--text-faint);
    font-size: .78rem;
  }

  .finance-note {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    color: var(--text-dim);
    font-size: .86rem;
    line-height: 1.6;
  }
  .finance-note strong { color: var(--text); }
  .chat-context {
    margin-top: 8px;
    white-space: pre-wrap;
    color: var(--text-dim);
    font-size: .82rem;
    line-height: 1.45;
  }
  .chat-context.compact {
    max-width: 360px;
    max-height: 120px;
    overflow: auto;
  }
  .source-message-toggle {
    margin-top: 8px;
  }
  .source-message-toggle summary {
    cursor: pointer;
    color: var(--text-dim);
    font-size: .78rem;
  }
  .source-message-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
  }
  .source-message-item {
    display: grid;
    gap: 3px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    background: var(--bg-card);
    font-size: .8rem;
  }
  .source-message-item.outgoing {
    border-color: var(--accent-soft);
    background: var(--bg-panel-raised);
  }
  .source-message-item.incoming {
    background: var(--bg-card);
  }
  .source-message-item .draft-flags {
    margin: 4px 0 0;
  }
  .source-message-meta {
    color: var(--text-faint);
    font-size: .72rem;
  }
  .source-message-text {
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .telegram-dialog {
    display: grid;
    grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
    overflow: hidden;
    height: min(640px, 72vh);
  }
  .telegram-dialog-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border-soft);
    background: var(--bg-card);
  }
  .telegram-dialog-list .empty-note {
    margin: 14px;
  }
  .telegram-dialog-item {
    display: grid;
    gap: 4px;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--border-soft);
    border-left: 3px solid transparent;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
  }
  .telegram-dialog-item:hover {
    background: var(--bg-panel-raised);
  }
  .telegram-dialog-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }
  .telegram-dialog-item.selected {
    background: var(--bg-panel-raised);
    border-left-color: var(--accent);
  }
  .telegram-dialog-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
  }
  .telegram-dialog-item-top strong {
    font-size: .84rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .telegram-dialog-item-time {
    color: var(--text-faint);
    font-size: .7rem;
    white-space: nowrap;
  }
  .telegram-dialog-item-preview {
    color: var(--text-faint);
    font-size: .76rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .telegram-dialog-item-badge {
    justify-self: start;
  }
  .telegram-dialog-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
  }
  .telegram-dialog-pane > .empty-note {
    margin: 14px;
  }
  .telegram-thread-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
  }
  .telegram-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
  }
  .telegram-thread-card h4 {
    margin: 0 0 6px;
    font-size: .94rem;
    letter-spacing: 0;
  }
  .telegram-thread-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .telegram-thread-feed {
    display: grid;
    gap: 8px;
    min-width: 0;
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    align-content: start;
  }
  .telegram-thread-feed .source-message-item {
    max-width: 86%;
  }
  .telegram-thread-feed .source-message-item.outgoing {
    justify-self: end;
  }
  .telegram-thread-compose {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-card);
  }
  .telegram-thread-compose textarea {
    width: 100%;
    min-height: 74px;
    resize: vertical;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: .84rem;
  }
  .telegram-thread-compose textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .telegram-thread-compose .row-actions {
    justify-content: flex-start;
  }
  .draft-panel {
    margin-bottom: 14px;
  }
  .draft-panel h4 {
    margin: 0 0 10px;
    font-size: .88rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-faint);
  }
  .draft-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
  }
  .draft-flag {
    border-radius: 999px;
    padding: 3px 9px;
    font-size: .72rem;
    color: var(--text-dim);
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
  }
  .draft-flag.warn {
    color: var(--amber);
    background: var(--amber-soft);
    border-color: rgba(245,190,92,.28);
  }
  .draft-confidence {
    display: grid;
    gap: 7px;
    margin: 0 0 12px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
  }
  .draft-confidence-title {
    color: var(--text-faint);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
  }
  .draft-confidence-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .field-confidence {
    border-radius: 999px;
    padding: 3px 8px;
    font-size: .72rem;
    color: var(--text-dim);
    border: 1px solid var(--border-soft);
    background: var(--bg-card);
  }
  .field-confidence.high {
    color: var(--green);
    background: var(--green-soft);
    border-color: rgba(71,201,141,.28);
  }
  .field-confidence.medium,
  .field-confidence.manual {
    color: var(--amber);
    background: var(--amber-soft);
    border-color: rgba(245,190,92,.28);
  }
  .field-confidence.low,
  .field-confidence.empty {
    color: var(--red);
    background: var(--red-soft);
    border-color: rgba(255,107,107,.26);
  }
  .bulk-toolbar {
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 10px 12px;
  }
  .bulk-toolbar .hint {
    text-align: left;
  }
  .bulk-selection-summary {
    display: none;
    width: 100%;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 2px;
  }
  .bulk-selection-summary.open {
    display: flex;
  }
  .bulk-selection-summary .draft-flag {
    background: rgba(255,255,255,.03);
  }
  .bulk-result {
    display: none;
    margin: -6px 0 16px;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-panel);
  }
  .bulk-result.open {
    display: block;
  }
  .bulk-result strong {
    display: block;
    margin-bottom: 6px;
    font-size: .84rem;
  }
  .bulk-result ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-dim);
    font-size: .82rem;
    line-height: 1.45;
  }
  .bulk-result li.success { color: var(--green); }
  .bulk-result li.warn { color: var(--amber); }
  .bulk-result li.error { color: var(--red); }
  .review-queue {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
  }
  .review-queue-controls {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(160px, auto));
    gap: 8px;
    align-items: center;
  }
  .review-queue-controls input,
  .review-queue-controls select {
    width: 100%;
  }
  .review-reason-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .review-reason-counts button {
    border: 1px solid var(--border-soft);
    background: var(--bg-card);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: .76rem;
    font-weight: 800;
    cursor: pointer;
  }
  .review-reason-counts button.active {
    color: var(--text);
    border-color: rgba(93,140,255,.42);
    background: rgba(93,140,255,.12);
  }
  .review-reason-counts button:disabled {
    opacity: .45;
    cursor: not-allowed;
  }
  .review-queue-toolbar {
    position: sticky;
    top: 104px;
    z-index: 12;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-panel);
    box-shadow: 0 10px 24px rgba(2, 6, 23, .16);
  }
  .review-queue-toolbar .hint {
    margin: 0;
  }
  .review-queue-toolbar .hint:first-child {
    color: var(--text);
    font-weight: 800;
  }
  .review-queue-list {
    display: grid;
    gap: 8px;
  }
  .work-queue,
  .finance-control {
    display: grid;
    gap: 12px;
    margin: 18px 0;
    padding: 16px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--bg-panel);
  }
  .work-queue-controls {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(160px, auto) auto auto;
    gap: 8px;
    align-items: center;
  }
  .work-queue-controls input,
  .work-queue-controls select { width: 100%; }
  .work-queue-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
  }
  .work-queue-pages { display: flex; gap: 8px; align-items: center; }
  .work-queue-list { display: grid; gap: 8px; }
  .work-queue-item {
    display: grid;
    grid-template-columns: minmax(120px, .7fr) minmax(180px, 1.4fr) minmax(150px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 11px 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-panel);
  }
  .work-queue-item strong { color: var(--text); }
  .work-queue-item .meta { color: var(--text-dim); font-size: .78rem; }
  .work-queue-item .status { justify-self: start; }
  .work-queue-empty,
  .finance-incomplete { color: var(--text-dim); font-size: .84rem; }
  .finance-period-change { font-size: .76rem; color: var(--text-dim); }
  .finance-period-change.positive { color: var(--green); }
  .finance-period-change.negative { color: var(--red); }
  .finance-payment-reconciliation {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: baseline;
    padding: 11px 13px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    font-size: .84rem;
  }
  .finance-payment-reconciliation strong { color: var(--text); }
  .finance-payment-reconciliation .meta { color: var(--text-dim); font-size: .76rem; }
  .finance-incomplete {
    display: grid;
    gap: 6px;
    padding-top: 4px;
  }
  .finance-incomplete a { color: var(--accent); }
  .client-history-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
  .client-history-stats > div {
    display: grid;
    gap: 4px;
    padding: 11px 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg-card);
  }
  .client-history-stats span,
  .client-history-row small { color: var(--text-dim); font-size: .76rem; }
  .client-history-stats strong { font-size: .95rem; }
  .client-history-list { display: grid; gap: 6px; }
  .client-history-row {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    text-align: left;
    cursor: pointer;
  }
  .client-history-row.static { cursor: default; }
  .client-history-row > span:first-child { display: grid; gap: 3px; min-width: 0; }
  .client-history-row:hover:not(.static) { border-color: var(--accent); }
  .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;
  }
  .review-order-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(150px, auto);
    gap: 10px 12px;
    align-items: start;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 10px;
    background: var(--bg-panel);
  }
  .review-order-card.attention {
    border-color: rgba(245,190,92,.38);
    border-left: 3px solid var(--amber);
    background: var(--bg-panel);
  }
  .review-order-check {
    width: 18px;
    height: 18px;
  }
  .review-order-title {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: .88rem;
    font-weight: 800;
  }
  .review-order-priority {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: .7rem;
    line-height: 1.2;
    background: var(--green-soft);
    color: var(--green);
  }
  .review-order-priority.warn {
    background: var(--amber-soft);
    color: var(--amber);
  }
  .review-order-meta {
    margin-top: 5px;
    color: var(--text-dim);
    font-size: .78rem;
    overflow-wrap: anywhere;
  }
  .review-order-statusline {
    margin-top: 5px;
    color: var(--text-faint);
    font-size: .74rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .review-order-reason {
    margin-top: 5px;
    padding-left: 8px;
    border-left: 2px solid var(--border-soft);
    color: var(--text-dim);
    font-size: .78rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }
  .review-order-fix {
    margin-top: 3px;
    padding-left: 8px;
    border-left: 2px solid var(--amber);
    color: var(--text);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  .review-order-fix strong { color: var(--amber); }
  .review-order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: flex-start;
  }
  .review-order-actions .btn {
    padding: 7px 10px;
    font-size: .74rem;
  }
  .review-order-missing {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }
  .review-order-missing .draft-flag {
    padding: 2px 7px;
    font-size: .68rem;
    background: transparent;
  }
  .review-checklist {
    display: grid;
    gap: 6px;
    margin: 4px 0 12px;
  }
  .review-checklist .draft-flag {
    width: fit-content;
  }
  .review-checklist-note {
    color: var(--text-dim);
    font-size: .82rem;
    line-height: 1.45;
  }
  .select-cell {
    width: 38px;
    text-align: center;
  }

  /* Динамика: формы, статусы, служебные элементы */
  .toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
  }
  .btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    color: #08121f;
    font-weight: 700;
    font-family: inherit;
    font-size: .82rem;
    cursor: pointer;
    transition: transform .15s var(--ease), filter .15s var(--ease);
  }
  .btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .btn:disabled,
  .read-only-disabled {
    cursor: not-allowed;
    opacity: .55;
    transform: none;
    filter: none;
  }
  .btn.secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .btn.danger {
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid transparent;
    padding: 5px 10px;
    font-size: .74rem;
  }
  .inline-form {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 18px;
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
  }
  .inline-form.open { display: flex; }
  .service-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    max-width: 560px;
  }
  .service-row.pipeline-stage-row {
    max-width: 900px;
  }
  .pipeline-stage-row .stage-order {
    flex: 0 0 54px;
    color: var(--text-faint);
    font-size: .76rem;
    text-align: right;
  }
  .service-row input,
  .service-row select {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: .84rem;
  }
  .pipeline-stage-row select {
    flex: 0 0 150px;
  }
  .service-row input:disabled,
  .service-row select:disabled { opacity: .55; }
  .service-row input:focus,
  .service-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .source-preview {
    width: 100%;
    margin: -6px 0 10px;
  }
  .source-preview .table-wrap {
    border-radius: var(--radius-md);
  }
  .source-preview td,
  .source-preview th {
    padding: 10px 12px;
    font-size: .8rem;
  }
  .inline-form .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .order-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
  }
  .order-thread-chat {
    color: var(--text-faint);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
  }
  .order-thread-item {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 10px 14px;
  }
  .order-thread-meta {
    color: var(--text-faint);
    font-size: .74rem;
    margin-bottom: 4px;
  }
  .order-thread-text {
    font-size: .87rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
  }
  .field-missing label {
    color: var(--red);
  }
  .field-missing label::after {
    content: " *";
  }
  .field-missing input,
  .field-missing select,
  .field-missing textarea {
    border-color: var(--red) !important;
    box-shadow: 0 0 0 1px var(--red-soft);
  }
  .inline-form label {
    color: var(--text-faint);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
  }
  .inline-form input,
  .inline-form select,
  .inline-form textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: .84rem;
    min-width: 140px;
  }
  .inline-form textarea {
    min-width: min(620px, 100%);
    min-height: 180px;
    resize: vertical;
    line-height: 1.5;
  }
  .inline-form .field.wide {
    flex: 1 1 620px;
  }
  .inline-form input:focus,
  .inline-form select:focus,
  .inline-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .stage-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    color: var(--text-dim);
    font-family: inherit;
    font-size: .74rem;
    margin-top: 8px;
    width: 100%;
    cursor: pointer;
  }
  .row-actions { display: flex; align-items: center; gap: 10px; }
  .inline-status {
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid rgba(242,112,122,.3);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: .82rem;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
  }
  .inline-status.success {
    background: var(--green-soft);
    color: var(--green);
    border-color: rgba(74,222,154,.3);
  }
  .inline-status button {
    background: none;
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-family: inherit;
    font-size: .76rem;
    cursor: pointer;
  }
  .empty-note {
    color: var(--text-faint);
    font-size: .82rem;
    padding: 8px 2px;
  }
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .72);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 40;
  }
  .modal-backdrop.open { display: flex; }
  .modal {
    width: min(860px, 100%);
    max-height: min(760px, 92vh);
    overflow: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }
  .modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--border-soft);
  }
  .modal-head h3 { margin: 0; font-size: 1.08rem; }
  .modal-body { padding: 20px 24px 24px; }
  .detail-section-title {
    margin: 18px 0 10px;
    color: var(--text-faint);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
  }
  .modal-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .modal-form .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
  }
  .modal-form .field.wide { grid-column: 1 / -1; }
  .modal-form label {
    color: var(--text-faint);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
  }
  .modal-form input,
  .modal-form select,
  .modal-form textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: .84rem;
    width: 100%;
  }
  .modal-form textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.5;
  }
  .modal-form input:focus,
  .modal-form select:focus,
  .modal-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .modal-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 4px;
  }
  .review-order-form .modal-actions {
    position: sticky;
    bottom: -24px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-soft);
    padding: 12px 0 0;
    z-index: 2;
  }
  .detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .detail-field {
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 10px;
    min-width: 0;
  }
  .detail-field.full { grid-column: 1 / -1; }
  .detail-label {
    color: var(--text-faint);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
  }
  .detail-value {
    color: var(--text);
    font-size: .9rem;
    overflow-wrap: anywhere;
  }
  .order-photos {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .order-photo-card {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 10px;
    background: var(--bg-card);
    min-width: 0;
  }
  .order-photo-card img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg-panel);
    margin-bottom: 8px;
  }
  .order-photo-link,
  .order-photo-empty {
    display: block;
    color: var(--text-dim);
    font-size: .82rem;
    overflow-wrap: anywhere;
  }
  .order-photo-link { color: var(--accent); }
  .timeline {
    display: grid;
    grid-template-columns: repeat(5, minmax(112px, 1fr));
    gap: 8px;
    margin-top: 18px;
  }
  .timeline-step {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 10px;
    min-height: 72px;
  }
  .timeline-step.done {
    border-color: rgba(74,222,154,.35);
    background: var(--green-soft);
  }
  .timeline-step strong {
    display: block;
    font-size: .76rem;
    margin-bottom: 6px;
  }
  .timeline-step span {
    color: var(--text-dim);
    font-size: .76rem;
  }

  footer {
    text-align: center;
    color: var(--text-faint);
    font-size: .76rem;
    padding: 26px 20px 34px;
    letter-spacing: .01em;
  }

  @media (max-width: 1080px) {
    .pipeline { grid-template-columns: repeat(3, 1fr); }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .home-command-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-grid { grid-template-columns: 1fr; }
    .guide-grid { grid-template-columns: 1fr; }
    .telegram-dialog {
      grid-template-columns: 1fr;
      height: auto;
    }
    .telegram-dialog-list {
      max-height: 240px;
      border-right: none;
      border-bottom: 1px solid var(--border-soft);
    }
    .telegram-thread-feed { max-height: 55vh; }
  }
  @media (max-width: 720px) {
    header { padding: 14px 18px; }
    header .tagline { display: none; }
    nav { padding: 0 18px; }
    main { padding: 24px 18px 44px; }
    .pipeline { grid-template-columns: 1fr 1fr; }
    .stats { grid-template-columns: 1fr; }
    .home-command-bar { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .client-history-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .modal-form { grid-template-columns: 1fr; }
    .modal-backdrop { padding: 8px; align-items: stretch; }
    .modal { max-height: calc(100vh - 16px); width: 100%; }
    .modal-head { position: sticky; top: 0; z-index: 2; background: var(--bg-panel); padding: 14px 16px 12px; }
    .modal-body { padding: 14px 16px 18px; }
    .order-photos { grid-template-columns: 1fr; }
    .timeline { grid-template-columns: 1fr; }
    .review-queue-controls { grid-template-columns: 1fr; }
    .work-queue-controls { grid-template-columns: 1fr; }
    .work-queue-item { grid-template-columns: 1fr; }
    .work-queue-item .status { justify-self: start; }
    .review-order-card { grid-template-columns: auto minmax(0, 1fr); }
    .review-order-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .review-order-actions .btn { width: 100%; }
    .order-assist { grid-template-columns: 1fr; }
    .section-head { flex-direction: column; align-items: flex-start; }
    .hint { text-align: left; }
    table { font-size: .8rem; }
    .table-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
    .table-wrap table { white-space: nowrap; }
  }
  @media (max-width: 480px) {
    .pipeline { grid-template-columns: 1fr; }
  }
  @media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  }
