:root {
  --bg: #f5f6fb;
  --bg-2: #eef1f7;
  --card: #ffffff;
  --text: #1c1b1f;
  --muted: #5e5e66;
  --accent: #6750a4;
  --accent-2: #7f67be;
  --accent-3: #b3261e;
  --border: rgba(28, 27, 31, 0.08);
  --shadow: 0 8px 20px rgba(28, 27, 31, 0.08);
  --shadow-strong: 0 12px 30px rgba(28, 27, 31, 0.12);
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --radius-8: 8px;
  --radius-12: 12px;
  --radius-16: 16px;
  --font-12: 12px;
  --font-13: 13px;
  --font-14: 14px;
  --font-16: 16px;
  --font-20: 20px;
  --font-24: 24px;
  --container-max: 1200px;
  --container-max-xl: 1560px;
}

* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Roboto", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8f9ff 0%, #f2f3f8 100%);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.no-scroll { overflow: hidden; }
body.auth-body { background: #f2f3f8; }
body.auth-body .container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

img { max-width: 100%; height: auto; }
svg { display: inline-block; }

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

button, input, select, textarea { font: inherit; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: width 0.2s ease;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(103, 80, 164, 0.12);
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-text { font-family: "Roboto", sans-serif; font-weight: 600; font-size: 16px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }

.nav-section {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
}

.nav-item:hover { background: rgba(103, 80, 164, 0.08); text-decoration: none; }

.nav-item.active {
  background: rgba(103, 80, 164, 0.16);
  color: var(--accent);
}

.nav-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}

.sidebar-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
}

.sidebar-action svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-action:hover { background: rgba(103, 80, 164, 0.08); text-decoration: none; }
.sidebar-action.logout { color: var(--accent-3); border-color: rgba(179, 38, 30, 0.3); }

.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;
}

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.topbar-actions .btn { white-space: nowrap; }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px 0;
  font-size: 12px;
  color: var(--muted);
}

.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs-sep { color: rgba(28, 27, 31, 0.3); }

.container { max-width: var(--container-max); margin: 0 auto; padding: 20px 24px 60px; width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-16);
  padding: var(--space-20);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: visible;
}
.card:focus-within { z-index: 10; }

.card.glass { background: #ffffff; }
.card.soft { background: rgba(103, 80, 164, 0.06); }
.card.compact { padding: 12px; margin-bottom: 12px; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 360px);
  gap: 24px;
  align-items: center;
  justify-content: center;
  max-width: 940px;
  margin: 0;
  padding: 0 16px;
  width: 100%;
}
.auth-card { margin: 0; padding: 24px; }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card h3 { margin-top: 0; margin-bottom: 12px; }
.auth-card .field.mb-12 { margin-bottom: 10px; }
.auth-card input { padding: 10px 12px; }
.auth-card-main .btn { width: 100%; }
.auth-card-side { background: rgba(103, 80, 164, 0.04); }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.auth-brand-name { font-weight: 700; font-size: 16px; }
.auth-brand-caption { font-size: 12px; color: var(--muted); }
.auth-heading { margin-bottom: 12px; }
.auth-subtitle { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.auth-list { padding-left: 18px; margin: 0 0 12px; color: var(--muted); }
.auth-list li { margin-bottom: 6px; }
.auth-side-note { color: var(--muted); font-size: 12px; }
.auth-card .logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 14px;
}
.auth-card .logo-text { font-size: 15px; }
.auth-alt { margin-top: 6px; }
.auth-alt-title {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  color: #6b6f7b;
  font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(0, 0, 0, 0.08);
}
.telegram-login {
  display: flex;
  justify-content: flex-start;
}
.telegram-login iframe { max-width: 100%; }
.auth-alt .telegram-login iframe { border-radius: 12px; box-shadow: 0 8px 20px rgba(17, 24, 39, 0.12); }
.settings-section { margin-bottom: 20px; }
.settings-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 6px 6px 12px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.settings-header { margin-bottom: 12px; }
.settings-admins { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.settings-admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.settings-admin-name { font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.settings-admin-form .form-row { gap: 12px; }
.mt-8 { margin-top: 8px; }
.settings-telegram-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.settings-telegram-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.settings-telegram-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.settings-telegram-label { font-weight: 600; }
.settings-telegram-widget { margin-top: 8px; display: grid; gap: 8px; }
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
}

.details-card summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
  list-style: none;
}
.details-card summary::-webkit-details-marker { display: none; }

h1, h2, h3, h4 { margin-top: 0; }

h1 { font-size: 28px; }

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  gap: 20px;
}

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.topbar-actions,
.quick-actions {
  align-items: center;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(28, 29, 34, 0.06);
}

.kpi-card.mini { padding: 12px; margin-bottom: 10px; }

.kpi-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: var(--font-14); min-width: 600px; }
.table th, .table td { padding: 12px 14px; text-align: left; }
.table th {
  background: rgba(103, 80, 164, 0.08);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.table tr:nth-child(even) td { background: rgba(103, 80, 164, 0.04); }
.table tr td { border-bottom: 1px solid var(--border); }
.table.compact th, .table.compact td { padding: 8px 10px; }
.table td { vertical-align: top; word-break: break-word; }
.hide-md, .hide-sm, .hide-xs { }
.table .table-input {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
  max-width: 160px;
  text-align: right;
}
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-actions { display: inline-flex; gap: 8px; align-items: center; }
.actions-cell { text-align: right; width: 160px; }
.comment-cell { max-width: 280px; width: 280px; }
.comment-display {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  outline: none;
  box-shadow: none;
}
.comment-display:focus { outline: none; box-shadow: none; }
.comment-display:focus-visible {
  outline: 1px dashed var(--border);
  outline-offset: 2px;
}
.comment-display .comment-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 20px;
}
.comment-display.is-empty { color: var(--muted); }
.comment-display .comment-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  opacity: 0.45;
}
.comment-display:hover .comment-icon { opacity: 0.9; }

.side-panel {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 70;
}
.side-panel.is-open { display: block; }
.side-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 16, 20, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.side-panel-card {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(420px, 100%);
  background: #fff;
  box-shadow: 0 20px 60px rgba(28, 29, 34, 0.25);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.side-panel.is-open .side-panel-card { transform: translateX(0); }
.side-panel.is-open .side-panel-backdrop { opacity: 1; }
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.side-panel-body { display: grid; gap: 12px; flex: 1; }
.side-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.comment-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 4px;
}

.comment-bubble {
  background: rgba(103, 80, 164, 0.08);
  border: 1px solid rgba(103, 80, 164, 0.16);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  max-width: 100%;
  align-self: flex-start;
}

.comment-bubble .comment-time {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 200px; }
.form-row.top-gap { margin-top: 12px; }
.field.align-end { align-self: flex-end; }
.field.mb-12 { margin-bottom: 12px; }
.field.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.label-block { display: block; }

label { display: block; font-size: var(--font-12); color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.6px; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(103, 80, 164, 0.18);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(28, 27, 31, 0.6) 50%),
    linear-gradient(135deg, rgba(28, 27, 31, 0.6) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

select::-ms-expand { display: none; }

textarea {
  resize: vertical;
  min-height: 96px;
}

.btn,
button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-12);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 6px;
}

.btn svg,
button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn { text-decoration: none; }

button,
[type="button"],
[type="submit"] {
  -webkit-appearance: none;
  appearance: none;
}

.btn.secondary,
button.secondary { background: #625b71; }

.btn.ghost,
button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(103, 80, 164, 0.4);
  box-shadow: none;
}

.btn.ghost.danger,
button.ghost.danger {
  color: var(--accent-3);
  border-color: rgba(179, 38, 30, 0.35);
}

.btn.small,
button.small {
  padding: 6px 12px;
  min-height: 34px;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: none;
}

.btn.danger,
button.danger {
  color: #b3261e;
  border-color: rgba(179, 38, 30, 0.35);
}

button:disabled,
.btn.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(103, 80, 164, 0.55);
  outline-offset: 2px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(103, 80, 164, 0.16);
  color: var(--accent);
  font-size: var(--font-12);
}

.badge.success { background: rgba(6, 118, 71, 0.14); color: #067647; }
.badge.warn { background: rgba(179, 38, 30, 0.15); color: #b3261e; }

.error {
  color: #b42318;
  font-weight: 600;
  margin-bottom: 12px;
  background: rgba(179, 38, 30, 0.08);
  border: 1px solid rgba(179, 38, 30, 0.25);
  padding: 10px 12px;
  border-radius: 12px;
}

.success {
  color: #067647;
  font-weight: 600;
  margin-bottom: 12px;
  background: rgba(6, 118, 71, 0.08);
  border: 1px solid rgba(6, 118, 71, 0.25);
  padding: 10px 12px;
  border-radius: 12px;
}

.field-error {
  margin-top: 6px;
  font-size: 12px;
  color: #b42318;
  line-height: 1.3;
}

.field-help {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.autocomplete { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  z-index: 2000;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
.autocomplete-item { padding: 10px 12px; cursor: pointer; }
.autocomplete-item:hover { background: rgba(103, 80, 164, 0.08); }
.autocomplete-item.empty { cursor: default; }
.autocomplete-title { font-weight: 600; }
.autocomplete-meta { font-size: 12px; color: var(--muted); }

.footer-note { color: var(--muted); font-size: var(--font-12); }
.link { color: var(--accent); font-weight: 600; }

label.required::after {
  content: " *";
  color: var(--accent-3);
  font-weight: 700;
}

body.pay-public-body {
  background: var(--bg);
}

body.pay-public-body .container {
  max-width: 980px;
  padding-top: 28px;
}

.pay-page {
  display: grid;
  gap: 20px;
}

.pay-hero {
  display: grid;
  gap: 14px;
  padding: 20px 22px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #f6f7ff 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.pay-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pay-brand-title { font-weight: 700; font-size: 16px; }
.pay-brand-sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }

.pay-hero-text h1 { margin: 0; font-size: 26px; }
.pay-hero-text .footer-note { margin: 2px 0 0; }

.pay-steps {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.pay-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(103, 80, 164, 0.08);
  font-size: 13px;
  font-weight: 600;
}

.pay-step span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
}

.pay-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 20px;
  align-items: start;
}

.pay-summary h2 { margin-bottom: 6px; font-size: 20px; }

.pay-items { display: grid; gap: 10px; margin-top: 16px; }

.pay-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.pay-item-title { font-weight: 500; }
.pay-item-amount { font-weight: 600; }

.pay-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-weight: 700;
  font-size: 16px;
}

.qr-card {
  display: grid;
  gap: 12px;
  text-align: center;
  align-items: center;
}

.qr-image {
  width: min(320px, 100%);
  margin: 0 auto;
  display: block;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
}

.pay-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(103, 80, 164, 0.14);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.pay-status.success {
  background: rgba(6, 118, 71, 0.14);
  color: #067647;
}

.pay-layout.pay-is-paid .qr-image { display: none; }
.pay-layout.pay-is-paid .js-pay-action { display: none; }
.pay-layout.pay-is-paid .js-pay-cta { display: none; }

.pay-expired {
  display: none;
  gap: 10px;
  align-items: center;
  justify-items: center;
}

.pay-expired.show { display: grid; }

.pay-layout.qr-expired .qr-image,
.pay-layout.qr-expired .js-pay-action {
  display: none;
}

.pay-help {
  display: flex;
  justify-content: center;
}

.pay-help-card {
  width: 100%;
  border-radius: 16px;
  border: 1px dashed var(--border);
  padding: 16px 18px;
  background: #fff;
  text-align: center;
}

.pay-help-title { font-weight: 700; margin-bottom: 4px; }
.pay-help-text { font-size: 13px; color: var(--muted); }
.pay-min-note { margin-top: 10px; font-size: 12px; color: var(--muted); }

.pay-result {
  max-width: 520px;
  margin: 40px auto;
  text-align: center;
}

.pay-result.warn h1 { color: #b42318; }

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.icon-btn,
button.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 36px;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover { background: rgba(103, 80, 164, 0.08); text-decoration: none; }
.icon-btn.delete,
button.icon-btn.delete {
  color: var(--accent-3);
  border-color: rgba(179, 38, 30, 0.3);
}

.table-actions form {
  margin: 0;
  display: inline-flex;
}

.table-actions form button,
.card form .icon-btn {
  margin-top: 0;
}

.sidebar-collapsed .sidebar { width: 82px; }
.sidebar-collapsed .logo-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-section,
.sidebar-collapsed #sidebarToggle { display: none; }

.toggle-group {
  display: inline-flex;
  gap: 8px;
  background: rgba(103, 80, 164, 0.12);
  padding: 6px;
  border-radius: 16px;
  margin-bottom: 12px;
}

.toggle-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

.toggle-option input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-option span { display: inline-block; }
.toggle-option input:checked + span {
  background: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.segmented {
  display: inline-flex;
  background: rgba(103, 80, 164, 0.16);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.segmented-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.segmented-item input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-item span {
  padding: 6px 12px;
  border-radius: 12px;
  font-weight: 600;
}
.segmented-item input:checked + span {
  background: #fff;
  box-shadow: var(--shadow);
}

.deal-header-actions { min-width: 280px; }
.deal-status-form { display: grid; gap: 8px; }
.deal-status-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px 12px;
  align-items: end;
}
.deal-status-inline .field { margin: 0; }
.deal-status-inline label { margin-bottom: 4px; }
.deal-status-inline select,
.deal-status-inline input {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.card form button:not(.icon-btn) { margin-top: 8px; }
.form-actions { display: flex; justify-content: flex-start; margin-top: 12px; }

.deal-block { border: 1px solid var(--border); border-radius: 16px; padding: 12px; margin-bottom: 12px; background: rgba(255, 255, 255, 0.7); }
.deal-block-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.shipping-form .toggle-group { margin: 8px 0 12px; }
.shipping-form .btn { margin-top: 8px; }
.arrival-edit-form .form-actions { margin-top: 12px; }

.quick-status select { min-width: 150px; }
.quick-status select.js-status-autosave {
  min-width: 160px;
  height: 38px;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 10px;
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 4px 4px;
}

.qty-cell {
  width: 180px;
}

.qty-input {
  width: 120px;
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
}

.qty-field {
  display: inline-flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 180px;
}

.qty-field .field-error {
  flex-basis: 100%;
  margin-top: 4px;
}

.qty-remove {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
}

.deal-items-form .repeatable-row .form-row {
  align-items: flex-start;
}

.deal-items-form .repeatable-row .form-row .field.align-end {
  flex: 0 0 auto;
  min-width: auto;
  margin-left: auto;
}

.filter-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(103, 80, 164, 0.12);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  border: 1px solid rgba(103, 80, 164, 0.2);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-badge:hover {
  background: rgba(103, 80, 164, 0.18);
  text-decoration: none;
}

.filter-badge.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.inline-actions { display: flex; gap: 8px; align-items: center; }

.pay-empty {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px dashed rgba(179, 38, 30, 0.35);
  background: rgba(179, 38, 30, 0.04);
}

.pay-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(179, 38, 30, 0.12);
  color: var(--accent-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.pay-empty-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.pay-empty-text {
  color: var(--muted);
}

.pay-help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  justify-content: center;
}

.pay-help-actions .pay-contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 10px 16px;
}

.pay-help-actions .pay-contact-btn svg {
  width: 18px;
  height: 18px;
}

.pay-help-actions .pay-contact-btn svg.icon-stroke {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pay-help-actions .pay-contact-btn svg.icon-fill {
  fill: currentColor;
  stroke: none;
}

.badge.info {
  background: rgba(103, 80, 164, 0.16);
  color: var(--accent);
  border: 1px solid rgba(103, 80, 164, 0.35);
}
.manual-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
}

.manual-total-amount {
  font-size: 18px;
  color: var(--accent);
}

.is-loading { position: relative; opacity: 0.65; }
.is-loading:after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(103, 80, 164, 0.35);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.toast-root,
#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: #11694e; }
.toast.error { background: #7f1d1d; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.modal.is-open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 16, 20, 0.45);
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  width: min(520px, calc(100% - 32px));
  box-shadow: 0 20px 60px rgba(28, 29, 34, 0.2);
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-body { display: grid; gap: 12px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

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

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    z-index: 20;
    box-shadow: var(--shadow-strong);
  }
  .sidebar.open { left: 0; }
  .content { margin-left: 0; }
  .sidebar-collapsed .sidebar { width: 260px; }
  .sidebar-collapsed .logo-text,
  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .nav-section,
  .sidebar-collapsed #sidebarToggle { display: block; }
}

@media (max-width: 860px) {
  .form-row { flex-direction: column; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .hide-md { display: none !important; }
}

@media (max-width: 680px) {
  body { overflow-x: hidden; }
  .container { padding: 16px 16px 48px; }
  .card { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .topbar-actions .btn { width: 100%; }
  .breadcrumbs { padding: 8px 16px 0; flex-wrap: wrap; }
  .pay-layout { grid-template-columns: 1fr; }
  .pay-hero { padding: 16px; }
  .pay-hero-text h1 { font-size: 22px; }
  .table-wrap { overflow-x: visible; }
  .table { min-width: 0; table-layout: fixed; display: block; }
  .table thead { display: none; }
  .table tbody { display: block; }
  .table tr {
    display: block;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-16);
    padding: 12px;
    box-shadow: var(--shadow);
  }
  .table tr:last-child { margin-bottom: 0; }
  .table td {
    display: block;
    padding: 0 0 10px;
    border: 0;
    text-align: left;
  }
  .table td:last-child { padding-bottom: 0; }
  .table td::before {
    content: attr(data-label);
    display: block;
    font-size: var(--font-12);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
  }
  .table tr:nth-child(even) td { background: transparent; }
  .table .table-actions { display: flex; flex-wrap: wrap; justify-content: flex-start; }
  .table .comment-display { width: 100%; }
  .table .actions-cell,
  .table .comment-cell,
  .table .qty-cell { width: auto; max-width: none; text-align: left; }
  .table .table-input { max-width: 100%; width: 100%; text-align: left; }
  .table .hide-sm,
  .table .hide-md,
  .table .hide-xs { display: block !important; }
  .hide-sm { display: none !important; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .nav-item { padding: 10px 10px; }
  .table { min-width: 0; }
  .hide-xs { display: none !important; }
}

@media (min-width: 1920px) {
  .sidebar { width: 280px; }
  .container { max-width: var(--container-max-xl); padding: 28px 36px 72px; }
  .card { padding: 24px; }
  .table th, .table td { padding: 14px 16px; }
}

@media (min-width: 1200px) and (min-resolution: 2dppx) {
  :root {
    --shadow: 0 6px 16px rgba(28, 27, 31, 0.06);
    --shadow-strong: 0 10px 24px rgba(28, 27, 31, 0.1);
  }
  html { font-size: 16.5px; }
}
