/* styles.css — минималистичный интерфейс */

:root {
  --bg: #f4f5f7;
  --bg-elev: #ffffff;
  --text: #14181f;
  --muted: #687080;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #eef3ff;
  --green: #0f766e;
  --green-soft: #e8f6f2;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --red: #b42318;
  --red-soft: #fdecea;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --bg-elev: #161a21;
    --text: #e8eaee;
    --muted: #98a1b0;
    --line: #252b35;
    --line-strong: #333b48;
    --accent: #6d9bff;
    --accent-ink: #0b1220;
    --accent-soft: #1a2438;
    --green: #4fd1b5;
    --green-soft: #102a26;
    --amber: #f1b04c;
    --amber-soft: #2b2113;
    --red: #ff8d82;
    --red-soft: #2c1715;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .topbar { background: var(--bg); }
}

.topbar-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: var(--shadow);
}

.brand-mark .icon { width: 21px; height: 21px; stroke-width: 2; }

.titles { min-width: 0; }

.titles h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.titles p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------- Кнопки ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text);
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  .btn-success { color: #06231e; }
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--text); border-color: transparent; }

.btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--red);
}
.btn-danger:hover { background: var(--red-soft); border-color: transparent; }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

.icon-btn {
  appearance: none;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover { background: var(--bg-elev); color: var(--text); border-color: var(--line); }
.icon-btn:focus-visible { outline: 3px solid var(--accent-soft); }

.link-danger {
  appearance: none;
  border: 0;
  background: none;
  color: var(--red);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  padding: 8px 0;
}

.link-danger:hover { text-decoration: underline; }

/* ---------- Основной контейнер ---------- */

.main {
  max-width: 940px;
  margin: 0 auto;
  padding: 20px 20px 120px;
}

/* ---------- Список ---------- */

.list-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search .icon {
  position: absolute;
  left: 13px;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search input::placeholder { color: var(--muted); }

.search-clear {
  position: absolute;
  right: 7px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover { background: var(--bg); color: var(--text); }

.segmented {
  display: inline-flex;
  align-self: flex-start;
  background: var(--line);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button:hover { color: var(--text); }

.segmented button.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
}

.segmented .count {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.request-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.request-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.07);
}

.request-card:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.rc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.rc-number {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.rc-client {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.rc-address {
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.rc-money { font-weight: 600; color: var(--text); }

/* ---------- Статусы ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
}

.status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-new { background: var(--accent-soft); color: var(--accent); }
.status-work { background: var(--amber-soft); color: var(--amber); }
.status-closed { background: var(--green-soft); color: var(--green); }

/* ---------- Карточки и формы ---------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
}

.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.card-sub {
  margin: -9px 0 15px;
  font-size: 13px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid .full { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--muted);
}

.field small {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 42px;
}

.field textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--muted); opacity: 0.75; }

.field input[type="number"] { font-variant-numeric: tabular-nums; }

/* ---------- Расчёт стоимости ---------- */

.calc {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 4px;
}

.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.calc-row:last-child { border-bottom: 0; }

.calc-row strong {
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.calc-row.total { background: var(--accent-soft); }
.calc-row.total strong { color: var(--accent); font-size: 19px; }

/* ---------- Уведомления, подсказки ---------- */

.muted { color: var(--muted); }
.hint { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.notice {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

@media (prefers-color-scheme: dark) {
  .notice { color: #a9c2ff; }
}

/* ---------- Пустое состояние ---------- */

.empty {
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon .icon { width: 26px; height: 26px; }

.empty h2 { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.empty p { margin: 0 auto 18px; max-width: 360px; color: var(--muted); font-size: 13.5px; }

/* ---------- Вставка сообщения ---------- */

.paste-card { padding: 24px; }

.paste-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.paste-card > p { margin: 0 0 16px; font-size: 13.5px; }

.source-input {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 14px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  outline: none;
}

.source-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.paste-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ---------- Исходное сообщение ---------- */

.source {
  margin: 4px 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  overflow: hidden;
}

.source summary {
  cursor: pointer;
  padding: 12px 15px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  user-select: none;
}

.source summary:hover { color: var(--text); }

.source pre {
  margin: 0;
  padding: 0 15px 15px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Mono", Consolas, "SF Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- Панель действий ---------- */

.actions-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin: 22px -20px -120px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .actions-bar { background: var(--bg); }
}

.actions-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.actions-inner .spacer { flex: 1 1 auto; }

/* ---------- Чек ---------- */

.receipt-card { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }

.receipt-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 15px;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

.receipt-actions {
  display: flex;
  gap: 9px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.receipt-amount {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 11px;
}

.receipt-amount strong {
  color: var(--text);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Модальное окно ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 14, 20, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.16s ease;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
}

.modal {
  width: 100%;
  max-width: 470px;
  max-height: 92vh;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: slideUp 0.2s ease;
}

@media (min-width: 640px) {
  .modal { border-radius: 18px; animation: popIn 0.18s ease; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.modal-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.modal .field { margin-bottom: 12px; }

.modal .calc { margin: 4px 0 12px; }

.modal-error {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  margin: 0 0 12px;
}

.modal-actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.receipt-mini {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 12.8px;
  line-height: 1.5;
  color: var(--muted);
  max-height: 96px;
  overflow: auto;
}

/* ---------- Тосты ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  z-index: 80;
  max-width: calc(100vw - 40px);
  background: #14181f;
  color: #fff;
  border-radius: 11px;
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .toast { background: #e8eaee; color: #14181f; }
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Настройки ---------- */

.settings-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.settings-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 2px 0 0;
}

/* ---------- Деньги, чеки, группы ---------- */

.money-summary {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.money-summary:hover { border-color: var(--accent); }

.ms-row {
  display: flex;
  align-items: center;
  gap: 22px;
}

.ms-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ms-item span { font-size: 11.5px; color: var(--muted); }
.ms-item strong {
  font-size: 17px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.ms-item strong.is-green { color: var(--green); }
.ms-arrow { margin-left: auto; color: var(--muted); display: flex; }
.ms-foot { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat span { display: block; font-size: 11.5px; color: var(--muted); }
.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 19px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat small { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.stat .is-amber { color: var(--amber); }
.stat .is-green { color: var(--green); }

.receipt-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.receipt-tools .segmented { align-self: auto; }

.status-unpaid { background: var(--amber-soft); color: var(--amber); }
.status-paid { background: var(--green-soft); color: var(--green); }

.rc-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}
.rc-note .unpaid { color: var(--amber); font-weight: 550; }
.rc-note .paid { color: var(--green); font-weight: 550; }

.group-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }

.group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
}

.group-row:hover { background: var(--bg); }

.group-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-decoration: none;
  color: inherit;
}

.group-title { font-size: 13.5px; font-weight: 600; }
.group-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-money {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.group-remove {
  width: 32px;
  height: 32px;
  color: var(--muted);
}
.group-remove:hover { color: var(--red); background: var(--red-soft); border-color: transparent; }

.select-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 290px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px;
  background: var(--bg);
}

.select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  background: var(--bg-elev);
  border: 1px solid transparent;
}

.select-row:hover { border-color: var(--line-strong); }

.select-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.sr-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sr-main strong {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-main small {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-amount { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.receipt-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.rl-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.rl-left strong { font-size: 14px; }
.rl-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.notice-green {
  background: var(--green-soft);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 25%, transparent);
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--amber);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .nav-badge { color: #2b2113; }
}

body.modal-open { overflow: hidden; }

.field input[disabled],
.field input[readonly],
.field textarea[readonly] {
  color: var(--muted);
  background: var(--bg);
  cursor: default;
}

/* ---------- Анимации ---------- */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(18px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(0.97); opacity: 0.5; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Мобильные ---------- */

@media (max-width: 700px) {
  .topbar-inner { padding: 8px 14px; }
  .main { padding: 14px 14px 130px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .titles h1 { font-size: 17px; }
  .titles p { font-size: 12px; }
  .card { padding: 16px; border-radius: 13px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .paste-card { padding: 18px; }
  .actions-bar { margin: 18px -14px -130px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .actions-inner .spacer { display: none; }
  .actions-inner .btn { flex: 1 1 auto; }
  .actions-inner .btn-ghost { flex: 0 0 auto; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding: 0 8px; }
  .field input, .field textarea, .field select, .search input, .source-input { font-size: 16px; }
  .rc-head { margin-bottom: 5px; }
  .rc-client { font-size: 15.5px; }
}

@media (max-width: 380px) {
  .btn { padding: 0 12px; }
  .topbar-actions .btn span { display: none; }
}

/* ---------- Экран входа и загрузка ---------- */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.auth-brand p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.auth-tabs {
  width: 100%;
  margin-bottom: 18px;
}

.auth-tabs button { flex: 1; }

.auth-form .field { margin-bottom: 13px; }

.auth-submit {
  width: 100%;
  height: 44px;
  margin-top: 4px;
}

.auth-error {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 14px;
}

.auth-note {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Файлы ---------- */

.files-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.file-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-thumb .icon { width: 19px; height: 19px; }

.file-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-decoration: none;
  color: inherit;
}

.file-name {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 11.5px;
  color: var(--muted);
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.file-actions .icon-btn {
  width: 32px;
  height: 32px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.upload-row .hint { margin: 0; }

.file-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0 2px;
}

/* ---------- Аккаунт ---------- */

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.user-info strong {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
}

.user-info span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}

.btn[disabled] { opacity: 0.55; cursor: default; }

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat.wide { grid-column: 1 / -1; }
  .receipt-tools { align-items: stretch; }
  .receipt-tools .segmented { flex: 1 1 100%; }
  .receipt-tools .btn { width: 100%; }
  .money-summary .ms-row { gap: 14px; }
  .ms-item strong { font-size: 16px; }
  .auth-card { padding: 22px 18px; border-radius: 16px; }
  .file-row { padding: 7px; }
  .file-thumb { width: 36px; height: 36px; }
}

/* ---------- Дополнения ---------- */

.field .static {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14.5px;
  color: var(--text);
}

.modal-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

/* ---------- Тексты для чеков ---------- */

.receipt-tools-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.texts-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.texts-intro p {
  margin: 0;
  max-width: 620px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.texts-intro p strong { color: var(--text); }

.text-card { padding: 18px; }

.text-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.text-card-main { min-width: 0; }

.text-card-money {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  flex: 0 0 auto;
}

.text-card-money strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.text-card-money span { font-size: 12px; color: var(--muted); }

.text-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 640px) {
  .receipt-tools-actions { width: 100%; }
  .receipt-tools-actions .btn { width: 100%; }
  .texts-intro { flex-direction: column; }
  .texts-intro .receipt-tools-actions { width: 100%; }
  .texts-intro .receipt-tools-actions .btn { flex: 1 1 auto; width: auto; }
  .text-card-head { flex-direction: column; }
  .text-card-money { text-align: left; }
  .text-card-actions .btn { flex: 1 1 auto; }
}

/* ---------- Дубли и повторные выезды ---------- */

.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.check-line input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.notice-repeat {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 25%, transparent);
}

.repeat-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.duplicate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  margin-bottom: 12px;
}

.duplicate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.duplicate-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.duplicate-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duplicate-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duplicate-row .btn { flex: 0 0 auto; }

/* ---------- Фильтры ---------- */

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

.filter-row select {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 9px;
  padding: 0 10px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
}

.filter-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-row .btn { height: 38px; }

.filter-summary {
  font-size: 12.5px;
  color: var(--muted);
}

.filter-summary strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rc-summary {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

@media (max-width: 640px) {
  .filter-row select { flex: 1 1 42%; }
  .filter-row .btn { flex: 1 1 100%; }
}

/* ---------- Отменённые и быстрые действия ---------- */

.status-cancelled {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line-strong);
}

.request-card.has-actions { padding: 0; }

.request-card.has-actions .request-card-main {
  display: block;
  padding: 15px 17px 12px;
  text-decoration: none;
  color: inherit;
}

.request-card.has-actions .request-card-main:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: -3px;
  border-radius: var(--radius);
}

.request-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 17px 12px;
}

.request-card-actions .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

@media (max-width: 640px) {
  .request-card.has-actions .request-card-main { padding: 14px 14px 10px; }
  .request-card-actions { padding: 0 14px 10px; }
  .request-card-actions .btn { flex: 1 1 auto; }
}

.segmented button { white-space: nowrap; }

@media (max-width: 480px) {
  .segmented .count { display: none; }
  .segmented button { padding: 0 6px; font-size: 12.5px; }
}

/* ---------- Входящие и интеграции ---------- */

.inbox-card {
  margin-bottom: 10px;
}

.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.inbox-source {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.inbox-date {
  font-size: 12px;
  color: var(--muted);
}

.inbox-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.inbox-meta {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

.inbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.inbox-actions .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

.integration-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.integration-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.integration-link > span {
  flex: 0 0 150px;
  font-size: 12.5px;
  color: var(--muted);
}

.integration-link code {
  flex: 1 1 240px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--text);
}

.integration-link .btn {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

@media (max-width: 640px) {
  .integration-link > span { flex-basis: 100%; }
  .integration-link code { flex-basis: 100%; }
  .integration-link .btn { flex: 0 0 auto; }
}

@media (max-width: 420px) {
  .topbar-inner { gap: 6px; }
  .topbar-actions { gap: 3px; }
  .topbar-actions .icon-btn { width: 36px; height: 36px; }
  .topbar-actions .btn { padding: 0 9px; }
}

.inbox-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.main.drag-over {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
  border-radius: 14px;
}
