:root {
  --bg: #0a0a0c;
  --bg-2: #101014;
  --surface: #16161b;
  --surface-2: #1e1e25;
  --surface-3: #26262f;
  --text: #f5f5f7;
  --text-2: #a1a1aa;
  --text-3: #6b6b75;
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-2: rgba(255, 255, 255, 0.06);
  --accent: #0a84ff;
  --accent-2: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --green: #30d158;
  --green-bg: rgba(48, 209, 88, 0.14);
  --amber: #ff9f0a;
  --amber-bg: rgba(255, 159, 10, 0.14);
  --red: #ff453a;
  --red-bg: rgba(255, 69, 58, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --surface-3: #e6e6ea;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --hairline: rgba(0, 0, 0, 0.1);
  --hairline-2: rgba(0, 0, 0, 0.06);
  --accent: #0071e3;
  --accent-2: #0a84ff;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --green: #248a3d;
  --green-bg: rgba(36, 138, 61, 0.12);
  --amber: #b25000;
  --amber-bg: rgba(255, 159, 10, 0.16);
  --red: #d70015;
  --red-bg: rgba(215, 0, 21, 0.1);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 34px; height: 34px; flex: 0 0 auto; object-fit: contain; display: block; }
.brand-text { display: block; min-width: 0; }
.brand-name { display: block; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand-visa { color: var(--text); }
.brand-pro { color: var(--accent); }
.brand-sub { display: block; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.brand img.logo-for-dark { display: block; }
.brand img.logo-for-light { display: none; }
[data-theme="light"] .brand img.logo-for-dark { display: none; }
[data-theme="light"] .brand img.logo-for-light { display: block; }

.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.side {
  background: var(--bg-2);
  border-right: 1px solid var(--hairline);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand { padding: 6px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--text-2);
  font: inherit; font-size: 15px; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  color: var(--text-2); font: inherit; font-size: 14px;
  text-decoration: none; cursor: pointer;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 26px; border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.content { padding: 24px 26px 64px; max-width: 1400px; width: 100%; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--hairline); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 550; padding: 9px 15px;
  border-radius: 999px; cursor: pointer; transition: transform 0.06s ease, background 0.15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex: 0 0 auto; }
.btn .btn-ico { display: inline-flex; align-items: center; }
.btn .btn-ico svg { width: 16px; height: 16px; }
.btn-sm .btn-ico svg { width: 15px; height: 15px; }

.input, .select, textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit; font-size: 14px; outline: none;
}
.input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888890' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select option { background: var(--surface-2); color: var(--text); padding: 6px; }
.select:hover, .input:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--hairline)); }
.input.invalid, .select.invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.req-star { color: var(--red); margin-left: 3px; }
.field, label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { color: var(--text-2); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .input { width: 280px; }
.toolbar .select { width: auto; min-width: 140px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
}
.filter { display: flex; flex-direction: column; gap: 5px; min-width: 170px; }
.filter-search { flex: 1 1 260px; max-width: 380px; }
.filters .select, .filters .input { min-height: 40px; }
.filters .btn { min-height: 40px; }
.filters .spacer { flex: 1; }

.view-toggle { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px; }
.vt-btn {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 550;
  padding: 7px 13px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.vt-btn:hover { color: var(--text); }
.vt-btn.active { background: var(--accent); color: #fff; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: transform 0.08s ease, border-color 0.15s;
  display: flex; flex-direction: column; gap: 10px;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline)); }
.card .name { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.card .meta { color: var(--text-2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; }
.card .row { display: flex; align-items: center; gap: 8px; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; }
.flags { display: flex; gap: 4px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge-work { background: var(--surface-3); color: var(--text-2); }
.badge-recorded { background: var(--green-bg); color: var(--green); }
.badge-error { background: var(--red-bg); color: var(--red); }
.badge-removed { background: var(--amber-bg); color: var(--amber); }

/* Статус с комментарием: при наведении показываем комментарий. */
.badge-tip { position: relative; cursor: help; }
.badge-tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--hairline);
  box-shadow: var(--shadow); font-size: 12px; font-weight: 500; line-height: 1.4;
  text-align: left; white-space: normal; letter-spacing: normal; text-transform: none;
  opacity: 0; visibility: hidden; transition: opacity 0.12s ease;
  z-index: 80; pointer-events: none;
}
.badge-tip:hover::after, .badge-tip:focus-visible::after { opacity: 1; visibility: visible; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--hairline); }

.empty { text-align: center; color: var(--text-2); padding: 60px 0; }

.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); display: none; z-index: 100; align-items: flex-start; justify-content: center; overflow: auto; padding: 40px 16px; }
.modal-scrim.on { display: flex; }
.modal { background: var(--bg-2); border: 1px solid var(--hairline); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 860px; padding: 22px; }
.modal h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.modal .sub { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin: 20px 0 10px; }

.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--shadow-sm); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 14px; max-width: 360px; }
.toast.error { border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.toast.ok { border-color: color-mix(in srgb, var(--green) 50%, transparent); }

.calendar { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell { text-align: center; padding: 7px 0; border-radius: 8px; font-size: 13px; cursor: pointer; user-select: none; color: var(--text); }
.cal-cell.muted { color: var(--text-3); cursor: default; }
.cal-cell.weekday { color: var(--text-3); font-size: 11px; cursor: default; }
.cal-cell:hover:not(.muted):not(.weekday) { background: var(--surface-3); }
.cal-cell.selected { background: var(--accent); color: #fff; }
.cal-cell.excluded { background: var(--red); color: #fff; }
.cal-cell.range { background: var(--accent-soft); color: var(--accent); }

.drop { border: 1.5px dashed var(--hairline); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--text-2); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.scan-preview { max-width: 100%; border-radius: var(--radius-sm); margin-top: 10px; }

.doc { max-width: 920px; }
.doc-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.doc-head h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.doc-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: 0 0 auto; }
.doc .help { margin-bottom: 14px; }
.doc .help pre { margin: 10px 0 0; }
.doc code { background: var(--surface-3); padding: 2px 6px; border-radius: 6px; font-size: 12px; color: var(--text); }
.doc .help pre code { background: transparent; padding: 0; }
.endpoint { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.ep-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ep-head code { background: transparent; padding: 0; font-size: 15px; font-weight: 600; }
.method { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: 0.04em; }
.m-get { background: var(--accent-soft); color: var(--accent); }
.m-post { background: var(--green-bg); color: var(--green); }
.m-patch { background: var(--amber-bg); color: var(--amber); }
.m-del { background: var(--red-bg); color: var(--red); }
.endpoint p { margin: 0 0 10px; }
.endpoint pre, .doc pre { background: var(--bg); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 8px 0 0; }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.doc-table th, .doc-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--hairline-2); vertical-align: top; }
.doc-table th { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.help-warn { border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-bg); color: var(--text); }
.doc-links { display: flex; flex-wrap: wrap; gap: 10px; }

.list { display: grid; gap: 10px; }
.list-row { display: grid; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 14px 16px; }

.list-rows { display: grid; gap: 8px; }
.req-headrow, .req-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 150px) minmax(0, 1fr) 170px;
  gap: 12px; align-items: center;
}
body[data-role="agent"] .req-headrow, body[data-role="agent"] .req-row {
  grid-template-columns: 96px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 150px) minmax(0, 1fr) 170px;
}
.req-headrow {
  padding: 0 16px 8px; font-size: 11px; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-3);
}
.req-headrow .sort-active { color: var(--text-1); }
.req-headrow .sort-active:hover { color: var(--accent); }
.req-row {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 12px 16px; cursor: pointer; transition: transform 0.06s ease, border-color 0.15s;
}
.req-row:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline)); transform: translateY(-1px); }
.req-row .r-flag { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.req-row .r-flag .flag { flex: 0 0 auto; }
.req-row .r-country { font-size: 10px; line-height: 1.15; color: var(--text-3); text-align: center; }
.req-row .r-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-row .r-sub { font-size: 12px; color: var(--text-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-row .r-cell { font-size: 13px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-row .c-agent { color: var(--text); font-weight: 550; }
.req-row .r-status { justify-self: start; display: flex; align-items: center; gap: 8px; }
@media (max-width: 1200px) {
  .c-visa { display: none; }
  .req-headrow, .req-row { grid-template-columns: 96px minmax(0,1.5fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 170px; }
  body[data-role="agent"] .req-headrow, body[data-role="agent"] .req-row { grid-template-columns: 96px minmax(0,1.7fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 170px; }
}
@media (max-width: 900px) {
  .c-cities { display: none; }
  .req-headrow, .req-row { grid-template-columns: 96px minmax(0,1.5fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) 170px; }
  body[data-role="agent"] .req-headrow, body[data-role="agent"] .req-row { grid-template-columns: 96px minmax(0,1.6fr) minmax(0,1fr) minmax(0,1fr) 170px; }
}
@media (max-width: 700px) {
  .c-dates { min-width: 150px; white-space: nowrap; }
.c-dates, .c-sub { display: none; }
  .req-headrow { display: none; }
  .req-row { grid-template-columns: 34px minmax(0,1fr) minmax(0,1fr) auto; }
  body[data-role="agent"] .req-row { grid-template-columns: 34px minmax(0,1fr) auto; }
  .req-row .r-country { display: none; }
  .topbar { padding: 12px 14px; gap: 8px; }
  .topbar h1 { font-size: 17px; }
  .content { padding: 18px 14px 56px; }
}

.flag { width: 22px; height: 15px; border-radius: 3px; display: inline-block; object-fit: cover; box-shadow: 0 0 0 1px var(--hairline) inset; vertical-align: middle; }
.flag-lg { width: 46px; height: 32px; border-radius: 5px; }
.flag-none { display: inline-flex; width: 22px; height: 15px; align-items: center; justify-content: center; font-size: 12px; }
.help { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.help code { background: var(--surface-3); padding: 2px 6px; border-radius: 6px; font-size: 12px; color: var(--text); }
.help pre { background: var(--bg); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px; overflow: auto; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.scrim-mobile { display: none; }
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 90; transform: translateX(-100%); transition: transform 0.2s ease; width: 260px; }
  .side.open { transform: none; }
  .scrim-mobile.on { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 80; }
}
@media (min-width: 1025px) {
  body.side-collapsed .app { grid-template-columns: 1fr; }
  body.side-collapsed .side { display: none; }
}

.multi { position: relative; min-width: 170px; }
.ms-btn {
  width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: 14px; padding: 0 12px; cursor: pointer; text-align: left;
}
.ms-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline)); }
.ms-btn.open { border-color: var(--accent); }
.ms-btn.ms-active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--hairline)); }
.ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--text-3); flex: 0 0 auto; }
.ms-panel {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; min-width: 100%; max-height: 280px; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px;
}
.ms-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ms-item:hover { background: var(--surface-3); }
.ms-cb { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; cursor: pointer; }
.ms-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scan-thumb {
  width: 96px; height: 66px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--hairline);
  cursor: zoom-in; margin-top: 8px; transition: transform 0.12s ease, border-color 0.12s;
}
.scan-thumb:hover { transform: scale(1.03); border-color: var(--accent); }

/* Скан: иконка-открывашка вместо превью */
.scan-open {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 10px;
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent-soft); color: var(--text); cursor: pointer; text-align: left;
  font: inherit; transition: background 0.12s ease, transform 0.12s ease;
}
.scan-open:hover { background: var(--accent-soft-hover, var(--accent-soft)); transform: translateY(-1px); }
.scan-open-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; background: var(--accent); color: #fff;
}
.scan-open-text { font-size: 14px; font-weight: 500; }

/* Страна с флагом в форме заявки */
.country-pick { display: flex; align-items: center; gap: 10px; }
.country-pick .select { flex: 1 1 auto; min-width: 0; }
.country-flag { flex: 0 0 auto; display: inline-flex; align-items: center; }
.country-flag .flag { width: 30px; height: 20px; }

/* Подтверждение удаления внутри модалки */
.confirm-foot { align-items: center; }
.confirm-text { font-size: 14px; color: var(--text); }

.lightbox {
  position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.82); backdrop-filter: blur(4px); padding: 28px; cursor: default;
}
.lightbox.on { display: flex; animation: lb-in 0.16s ease; }
.lightbox-body { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 96vw; max-height: 92vh; }
.lightbox-img { max-width: 96vw; max-height: 88vh; border-radius: var(--radius); box-shadow: var(--shadow); }
.lightbox-hint { color: #fff; font-size: 13px; text-align: center; }
.lightbox-err { color: #ffb4b4; margin-bottom: 6px; }

.pay-list { display: grid; gap: 8px; }

@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal { animation: fade-up 0.16s ease; }
.card { animation: fade-up 0.16s ease; }
.list-row { animation: fade-up 0.16s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .lightbox.on { animation: none; }
}

/* Справка: регистрация в Almaviva */
.guide-list { margin: 8px 0 14px 20px; padding: 0; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.guide-list li { margin-bottom: 6px; }
.guide-list b { color: var(--text); font-weight: 600; }
.guide-p { color: var(--text-2); font-size: 14px; line-height: 1.6; margin: 8px 0 12px; }
.help-figure { margin: 14px 0 18px; }
.help-figure img {
  display: block; width: 100%; max-width: 760px; height: auto; border-radius: var(--radius);
  border: 1px solid var(--hairline); background: var(--surface, transparent);
}
.help-figure figcaption { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* Неактивный пункт (Испания в API пока отключена) */
.card.is-disabled, .nav button:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.card.is-disabled .meta::after { content: " · скоро"; color: var(--text-3); }

/* Кнопка справки рядом с полями ЛК */
.lk-help-row { display: flex; justify-content: flex-end; margin-top: -4px; }
.lk-help-row a { font-size: 13px; }

/* Статус агента: кнопки */
.status-agent { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-agent .muted { font-size: 13px; }
/* Форма заявки: скан первым, остальное закрыто до его загрузки */
.lockable { border: 0; margin: 0; padding: 0; min-width: 0; }
.lockable:disabled { opacity: 0.4; pointer-events: none; filter: grayscale(0.3); }
.recorded-hint { font-size: 13px; margin-top: 6px; }

/* Логин, пароль и справка в одной строке */
.lk-help-cell { display: flex; align-items: flex-end; }
.lk-help-cell .btn { width: 100%; justify-content: center; white-space: nowrap; }

/* Подпись поля с иконкой-подсказкой */
.field-cap { display: inline-flex; align-items: center; gap: 6px; }
.hint { position: relative; display: inline-flex; align-items: center; color: var(--text-3); cursor: help; }
.hint-ico { display: inline-flex; }
.hint-ico svg { width: 15px; height: 15px; }
.hint::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: 230px; max-width: 70vw; padding: 8px 10px; border-radius: 8px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--hairline);
  box-shadow: var(--shadow); font-size: 12px; line-height: 1.4; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity 0.12s ease; z-index: 80; pointer-events: none;
}
.hint:hover::after, .hint:focus::after { opacity: 1; visibility: visible; }

/* Статус распознавания скана: зелёный/оранжевый/красный */
.scan-msg { color: var(--text-2); }
.scan-msg.ok { color: var(--green); }
.scan-msg.warn { color: var(--amber); }
.scan-msg.err { color: var(--red); }

/* Кнопка скачивания подтверждения записи (PDF) */
.conf-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; flex: 0 0 auto; cursor: pointer;
  border-radius: 8px; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft); color: var(--accent);
}
.conf-btn:hover { background: var(--accent-2); color: #fff; border-color: transparent; }
.conf-btn.conf-btn-danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 40%, transparent);
  background: var(--red-bg);
}
.conf-btn.conf-btn-danger:hover { background: var(--red); color: #fff; border-color: transparent; }
.conf-btn.conf-btn-missing { opacity: 0.45; border-style: dashed; }
.conf-btn.conf-btn-status {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
}
.conf-btn.conf-btn-status:hover { background: var(--accent-2); color: #fff; border-color: transparent; }
.conf-btn-ico { display: inline-flex; }
.conf-btn-ico svg { width: 16px; height: 16px; }

/* Модалка со статусом заявления (закрывается сама через 5 секунд) */
.status-modal { min-width: 320px; max-width: 480px; }
.status-modal-text { font-size: 14px; line-height: 1.5; margin: 0 0 4px; word-break: break-word; }
.status-modal-text.ok { color: var(--green); }
.status-modal-text.info { color: var(--amber); }
.status-modal-text.err { color: var(--red); }
.status-modal-text.muted { color: var(--text-2); }

/* Проверка записи (ID записи -> PDF) */
.check-record-form {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  margin: 16px 0 12px;
}
.check-record-form .field { min-width: 260px; }
.check-record-result { font-size: 13px; margin-top: 8px; }
.check-record-result.ok { color: var(--green); }
.check-record-result.err { color: var(--red); }
.check-record-result.muted { color: var(--text-2); }

/* Настройки инструментов Альмавива */
.almaviva-settings { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.almaviva-worker-fields { margin-top: 4px; }

/* Telegram: подключение агента и настройки бота в админке */
.telegram-block, .telegram-admin { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin-bottom: 6px; }
.telegram-connect { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.telegram-hint { font-size: 13px; line-height: 1.45; }
.telegram-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.telegram-status.ok { color: var(--green); }
.telegram-status.warn { color: var(--amber); }
.telegram-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.telegram-link { justify-content: center; }
.agent-form { max-width: 560px; }

/* Агент отключён администратором */
.disabled-banner {
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  margin: 16px; padding: 18px 20px; border-radius: 12px;
  border: 1px solid var(--red, #e05a5a);
  background: var(--surface, #17171b); color: var(--text-1, #f2f2f5);
}
.disabled-banner-title { font-size: 16px; font-weight: 600; color: var(--red, #e05a5a); }
.disabled-banner-text { font-size: 14px; color: var(--text-2, #9a9aa4); }
body.is-disabled-agent .side,
body.is-disabled-agent .main { display: none; }

/* Блок подключения Telegram в личном кабинете агента */
.telegram-block { max-width: none; }
.settings-section-title { margin-top: 18px; }
.tg-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.tg-guide-title { font-size: 14px; font-weight: 500; margin: 0 0 8px; color: var(--text-1); }
.tg-guide-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.tg-card { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--hairline); border-radius: 12px; padding: 16px; background: var(--surface); max-width: 360px; }
.tg-card-title { font-size: 14px; font-weight: 500; color: var(--text-1); }
.tg-card-sub { font-size: 13px; margin-top: 2px; }
.tg-card .btn { width: 100%; justify-content: center; gap: 8px; }
.telegram-check { justify-content: center; gap: 8px; }
.telegram-link.is-loading { opacity: .6; pointer-events: none; }
.telegram-link.is-disabled { opacity: .5; pointer-events: none; }

/* Статус в модалке (админ) и комментарий справа от статуса */
.status-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Статус-селект не должен растягиваться на всю ширину. */
.status-line .select { width: auto; flex: 0 0 auto; min-width: 200px; }
.status-comment { color: var(--text-2); font-size: 13px; font-style: italic; word-break: break-word; }
.comment-under-status { margin-top: 12px; }
.input[type="number"] { font-variant-numeric: tabular-nums; }

/* Кнопки в настройках в один ряд */
.settings-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* Крестик в лайтбоксе */
.lightbox-close {
  position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.5); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(0,0,0,0.75); }
/* Отдельная страница справки (без панели навигации) */
.guide-page { background: var(--bg, #0a0a0c); }
.guide-wrap { max-width: 860px; margin: 0 auto; padding: 28px 18px 48px; }
.guide-foot { display: flex; justify-content: flex-end; margin-top: 22px; }
/* Поля: иконка внутри поля, копирование в одном поле */
.input-wrap { position: relative; display: block; }
.input-wrap .input.has-icon { padding-right: 46px; width: 100%; }
/* Две кнопки внутри поля (перегенерация + копирование) — правее, одна рядом с другой. */
.input-wrap.two-actions .input.has-icon { padding-right: 80px; }
.input-wrap.two-actions .input-icon-btn { position: absolute; }
.input-wrap.two-actions .input-icon-btn:first-of-type { right: 40px; }
.input-wrap.two-actions .input-icon-btn:last-of-type { right: 6px; }
.input-icon-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.input-icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.input-copy { display: flex; gap: 8px; align-items: center; }
.input-copy .input { flex: 1 1 auto; min-width: 0; }

/* Выпадающий список стран при создании заявки */
.modal-foot { position: relative; }
.country-menu {
  position: absolute; right: 0; bottom: 100%; margin-bottom: 8px; min-width: 260px; z-index: 70;
  background: var(--bg-2); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.country-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent;
  color: var(--text); border-radius: var(--radius-sm); cursor: pointer; text-align: left; font: inherit;
}
.country-item:hover:not(:disabled) { background: var(--accent-soft); }
.country-item:disabled { opacity: 0.45; cursor: not-allowed; }

/* Страна в существующей заявке — только для показа */
.country-static { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--text-2); }

/* Строка ЛК и кнопка справки */
.lk-row { margin-top: 14px; }
.lk-help-btn { display: inline-flex; align-items: center; gap: 8px; }
.lk-help-icon { display: inline-flex; }

/* Редактирование оплаты */
.pay-edit { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; width: 100%; }
.pay-edit-fields { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.pay-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Неактивные ссылки справки */
.is-disabled { opacity: 0.45; pointer-events: none; cursor: not-allowed; }

/* Настройки: поля токена и вебхука не на всю ширину */
.settings-form { max-width: 560px; }

/* Выпадающий список стран по кнопке «+ Заявка» */
.country-menu-pop { min-width: 240px; }

/* Оверлей распознавания скана */
.scan-overlay {
  position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center;
  background: rgba(8, 8, 10, 0.55); backdrop-filter: blur(3px);
}
.scan-overlay.on { display: flex; animation: fade-up 0.14s ease; }
.scan-overlay-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 30px 38px; background: var(--bg-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.scan-overlay-text { font-size: 15px; font-weight: 600; color: var(--text); }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.6s; } }

/* Вкладка «Агенты»: карточки с показателями */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 16px; }
.agent-card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
}
.agent-head { display: flex; align-items: center; gap: 12px; }
.agent-avatar {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 20px; font-weight: 700;
}
.agent-title { min-width: 0; flex: 1; }
.agent-name { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.agent-head .badge { flex: 0 0 auto; }
.agent-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.agent-stat { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.agent-stat-value { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.agent-stat-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.agent-money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.agent-money-item { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 10px 12px; }
.agent-money-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.agent-money-value { font-size: 16px; font-weight: 650; margin-top: 3px; }
.agent-money-item.neg .agent-money-value { color: var(--red); }
.agent-money-item.pos .agent-money-value { color: var(--amber); }
.agent-money-item.zero .agent-money-value { color: var(--green); }
.agent-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.agent-actions .btn { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.agent-actions .btn .btn-ico svg { width: 14px; height: 14px; }
/* Отключённый агент виден сразу: приглушён и с красной кнопкой. */
.agent-card.is-off, .agent-row.is-off { opacity: 0.75; }
.agent-card.is-off { border-color: var(--red, #e05a5a); }
.agent-row.is-off { border-left: 3px solid var(--red, #e05a5a); }
.agent-card.is-off .agent-name, .agent-row.is-off .agent-name { color: var(--red, #e05a5a); }
.agent-actions .btn-danger { background: var(--red-bg, rgba(224, 90, 90, .16)); color: var(--red, #e05a5a); border-color: var(--red, #e05a5a); }
.agent-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 12px 16px;
}
.agent-row-main { display: flex; align-items: center; gap: 12px; flex: 1 1 220px; min-width: 0; }
.agent-row-title { min-width: 0; }
.agent-avatar.sm { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }
.agent-row-money { display: flex; gap: 8px; flex-wrap: wrap; }
.agent-row-money .agent-money-item { min-width: 108px; }
.agent-row .agent-actions { flex: 0 0 auto; }
@media (max-width: 720px) {
  .agent-row { align-items: stretch; }
  .agent-row-money { width: 100%; }
}
@media (max-width: 560px) {
  .agent-stats { grid-template-columns: repeat(2, 1fr); }
  .agent-money { grid-template-columns: 1fr; }
}

/* Подтверждение в отдельной модалке */
.confirm-scrim { z-index: 150; }
.confirm-modal { max-width: 440px; }
.confirm-message { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
