:root {
  --bg: #edf2f8;
  --surface: #ffffff;
  --line: #d5deec;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --side: #07163a;
  --side-2: #0f2358;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Roboto", sans-serif;
  background: radial-gradient(circle at 15% -15%, #dbeafe 0, transparent 32%), var(--bg);
  color: var(--text);
  scrollbar-gutter: stable;
}

html {
  scrollbar-width: thin;
  scrollbar-color: #6aa7ff #dfeaf8;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.65) rgba(219, 234, 254, 0.75);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(219, 234, 254, 0.65), rgba(226, 232, 240, 0.9));
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #60a5fa, #2563eb 58%, #1d4ed8);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #38bdf8, #2563eb 62%, #1e40af);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

a { text-decoration: none; color: inherit; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.auth-brand {
  background: linear-gradient(145deg, var(--side) 0%, var(--side-2) 55%, var(--brand) 100%);
  color: #dbeafe;
  padding: 28px;
}

.auth-brand h1 { font-size: 34px; margin-bottom: 12px; }
.auth-brand p { opacity: 0.95; line-height: 1.45; }

.auth-main { padding: 28px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }

.tab-btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

form { display: grid; gap: 10px; }
label { font-size: 13px; color: #334155; margin-bottom: 4px; display: block; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
}

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

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); }

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

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--side), #051233 80%);
  color: #cbd5e1;
  padding: 16px 10px;
}

.logo { font-size: 22px; font-weight: 800; padding: 8px 10px 14px; color: #fff; }
.user-card {
  margin: 6px 8px 12px;
  border: 1px solid rgba(203, 213, 225, 0.22);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  background: rgba(148, 163, 184, 0.15);
}

.user-card strong { display: block; font-size: 13px; color: #fff; margin-bottom: 4px; }

.menu { display: grid; gap: 4px; margin-bottom: 10px; }
.menu a {
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd5e1;
}
.menu a.active, .menu a:hover { background: #1e3a79; color: #fff; }

.menu-bottom { display: grid; gap: 8px; margin: 12px 8px 0; }

.main {
  flex: 1;
  padding: 18px;
}

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

/* ───── Панель фильтров ───── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.filter-input {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.filter-select {
  flex: 0 1 190px;
  min-width: 140px;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.filter-archive-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  margin-left: auto;
}

.filter-archive-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary, #3b82f6);
}

h1 { font-size: 25px; }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.kpi .tile { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.kpi .tile small { color: var(--muted); display: block; margin-bottom: 4px; }
.kpi .tile strong { font-size: 23px; }

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

.dashboard-shell {
  display: grid;
  gap: 14px;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: stretch;
  padding: 20px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #f4f8ff 52%, #eef6ff 100%);
}

.dashboard-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #1d4ed8;
  font-weight: 800;
  margin-bottom: 10px;
}

.dashboard-hero h2 {
  font-size: 30px;
  line-height: 1.05;
  margin-bottom: 10px;
}

.dashboard-hero-copy {
  max-width: 760px;
  color: #475569;
  line-height: 1.55;
  font-size: 14px;
}

.dashboard-live-box {
  min-width: 290px;
  border-radius: 16px;
  padding: 16px 18px;
  background: #081a46;
  color: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(191, 219, 254, 0.18);
}

.dashboard-live-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.18);
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-kpi-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 6px;
  min-height: 136px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.dashboard-kpi-card::after {
  content: "";
  position: absolute;
  inset: auto -24px -32px auto;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  opacity: 0.18;
  background: currentColor;
}

.dashboard-kpi-card small {
  font-size: 12px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.dashboard-kpi-card strong {
  font-size: 30px;
  line-height: 1;
}

.dashboard-kpi-card span {
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
  max-width: 24ch;
}

.accent-blue { color: #2563eb; }
.accent-cyan { color: #0891b2; }
.accent-amber { color: #d97706; }
.accent-emerald { color: #059669; }
.accent-indigo { color: #4f46e5; }
.accent-slate { color: #334155; }

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(340px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.dashboard-column {
  display: grid;
  gap: 14px;
}

.dashboard-panel {
  padding: 16px;
}

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

.panel-head h3 {
  font-size: 17px;
  margin-bottom: 4px;
}

.tender-progress-list {
  display: grid;
  gap: 12px;
}

.dashboard-scroll {
  overflow: auto;
  padding-right: 8px;
  margin-right: -4px;
}

.dashboard-scroll-tenders {
  max-height: calc((var(--visible-count, 4) * 188px) + ((var(--visible-count, 4) - 1) * 12px));
}

.dashboard-scroll-feed {
  max-height: calc((var(--visible-count, 6) * 90px) + ((var(--visible-count, 6) - 1) * 10px));
}

.dashboard-scroll-tasks {
  max-height: 420px;
}

.dashboard-scroll::-webkit-scrollbar {
  width: 10px;
}

.dashboard-scroll::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #edf4ff, #e2ebf6);
  border-radius: 999px;
}

.dashboard-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #93c5fd, #3b82f6 55%, #1d4ed8);
  border: 2px solid #eef5ff;
}

.tender-progress-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  border: 1px solid #dbe6f5;
  min-height: 176px;
}

.tender-progress-card.tone-early {
  border-left: 5px solid #3b82f6;
}

.tender-progress-card.tone-mid {
  border-left: 5px solid #f59e0b;
}

.tender-progress-card.tone-late {
  border-left: 5px solid #8b5cf6;
}

.tender-progress-card.tone-done {
  border-left: 5px solid #10b981;
}

.tender-progress-card.tone-risk {
  border-left: 5px solid #ef4444;
}

.tender-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.tender-progress-number {
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.tender-progress-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.tender-progress-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-progress-bar {
  height: 12px;
  background: #dbeafe;
}

.dashboard-progress-bar > div {
  background: linear-gradient(90deg, #0ea5e9 0%, #2563eb 55%, #1d4ed8 100%);
}

.tender-progress-foot {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.tender-progress-foot strong {
  font-size: 22px;
  line-height: 1;
}

.tender-progress-foot span {
  color: #475569;
  font-size: 13px;
}

.deadline-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px !important;
}

.deadline-chip.deadline-danger {
  background: #fee2e2;
  color: #991b1b;
}

.deadline-chip.deadline-warning {
  background: #fef3c7;
  color: #92400e;
}

.deadline-chip.deadline-focus {
  background: #dbeafe;
  color: #1d4ed8;
}

.deadline-chip.deadline-calm {
  background: #e2e8f0;
  color: #334155;
}

.tender-progress-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tender-progress-metrics span {
  font-size: 12px;
  color: #334155;
  border-radius: 999px;
  padding: 7px 10px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
}

.dashboard-feed,
.dashboard-task-list,
.dashboard-alerts {
  display: grid;
  gap: 10px;
}

.feed-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  min-height: 80px;
}

.feed-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  background: linear-gradient(180deg, #38bdf8, #2563eb);
}

.feed-text {
  font-size: 13px;
  line-height: 1.45;
  color: #0f172a;
}

.dashboard-task-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.dashboard-task-card.tone-high {
  border-left: 5px solid #ef4444;
}

.dashboard-task-card.tone-medium {
  border-left: 5px solid #f59e0b;
}

.dashboard-task-card.tone-low {
  border-left: 5px solid #3b82f6;
}

.dashboard-task-card.tone-done {
  border-left: 5px solid #10b981;
}

.dashboard-task-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.dashboard-task-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 4px;
}

.dashboard-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-task-meta span {
  font-size: 12px;
  color: #334155;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
}

.dashboard-task-body {
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}

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

.focus-stat {
  display: grid;
  gap: 6px;
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, #f8fbff, #eff6ff);
  border: 1px solid #dbeafe;
}

.focus-stat span {
  color: #64748b;
  font-size: 12px;
}

.focus-stat strong {
  font-size: 24px;
}

.alert-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.alert-card.danger {
  background: #fff1f2;
  border-color: #fecdd3;
}

.alert-card.warning {
  background: #fffbeb;
  border-color: #fde68a;
}

.alert-card.focus {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.alert-card.calm {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.dashboard-empty {
  padding: 18px;
  border-radius: 14px;
  border: 1px dashed #cbd5e1;
  color: #64748b;
  background: #f8fafc;
  font-size: 13px;
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; border-bottom: 1px solid #e2e8f0; padding: 8px; }
.table th { color: #475569; font-size: 12px; }

.status {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
}
.status.open { background: #dbeafe; color: #1e40af; }
.status.review { background: #fef3c7; color: #92400e; }
.status.draft { background: #e2e8f0; color: #334155; }
.status.closed { background: #dcfce7; color: #166534; }
.status.shipped { background: #cffafe; color: #155e75; }
.status.commission { background: #fde68a; color: #92400e; }
.status.awaiting_signing { background: #bfdbfe; color: #1e3a8a; }
.status.signed { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.status.executed { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.status.awaiting_payment { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.status.unpaid { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.status.paid { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.status.stocked { background: #cffafe; color: #155e75; border: 1px solid #67e8f9; }
.status.warehouse { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.status.scheduled { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.status.received { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.status.awaiting_picking {
  background: #ffedd5;
  color: #9a3412;
  border: 1px solid #fdba74;
}
.status.awaiting_application {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}
.status.submitted {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.status.won_waiting_sign {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
.status.signed_ours {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.status.signed_both {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.status.archived_lost {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid #bcd0f5;
  background: #eaf1ff;
  color: #1e3a8a;
  font-size: 12px;
}
.row-actions button:hover {
  background: #dbeafe;
}
.row-actions button.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.row-actions button.btn-primary:hover {
  background: var(--brand-dark);
}
.row-actions button.btn-danger-outline {
  background: #fff1f2;
  color: #b91c1c;
  border-color: #fecdd3;
}

.list { display: grid; gap: 8px; max-height: 360px; overflow: auto; }
.list-item { border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; padding: 10px; font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; margin-top: 4px; }

.progress {
  height: 10px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}

.progress > div {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.toast-wrap {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: grid;
  gap: 8px;
  z-index: 1000;
}

.toast {
  min-width: 230px;
  max-width: 350px;
  color: #fff;
  background: #1d4ed8;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.quotes-panel {
  background: var(--bg);
  border-radius: 8px;
  padding: 4px 16px 12px;
  border: 1px solid var(--border);
}

.quotes-panel h4 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* ── Modal ──────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 500; }
.modal-backdrop.open { display: flex; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,.18); }
.modal-box.modal-wide { max-width: 820px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 12px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-confirm-msg { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.btn-secondary { border: 1.5px solid var(--border); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: 13px; }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: #ef4444; color: #fff; border: none; border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: 13px; }
.btn-danger:hover { background: #dc2626; }
.btn-danger-outline { border: 1.5px solid #ef4444; background: #fff; color: #ef4444; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.toast-error { background: #ef4444 !important; }

.instructions-shell {
  display: grid;
  gap: 14px;
}

.instructions-hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  border: 1px solid #bfdbfe;
  background:
    radial-gradient(circle at 92% 8%, rgba(14, 165, 233, 0.2), transparent 35%),
    linear-gradient(135deg, #ffffff 0%, #f5f9ff 45%, #e9f3ff 100%);
}

.instructions-eyebrow {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #1d4ed8;
  font-weight: 800;
  margin-bottom: 8px;
}

.instructions-hero h2 {
  font-size: 29px;
  line-height: 1.15;
  margin-bottom: 10px;
}

.instructions-hero p {
  color: #475569;
  font-size: 14px;
  line-height: 1.55;
}

.instructions-hero-box {
  border-radius: 14px;
  padding: 14px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}

.instructions-hero-box h3 {
  margin-bottom: 8px;
}

.instructions-hero-box ol {
  margin-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #1e3a8a;
}

.instructions-common h3,
.instructions-footer h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

.instructions-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.rule-block,
.role-block {
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #dbe6f5;
  background: #f8fbff;
}

.rule-block h4,
.role-block h4 {
  margin-bottom: 8px;
}

.rule-block p,
.role-block p,
.role-block li {
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
}

.role-block ul,
.role-block ol {
  margin-left: 18px;
  display: grid;
  gap: 6px;
}

.role-section {
  display: grid;
  gap: 12px;
}

.role-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.role-head h3 {
  font-size: 19px;
}

.role-director { border-left: 5px solid #4f46e5; }
.role-manager { border-left: 5px solid #2563eb; }
.role-picker { border-left: 5px solid #0891b2; }
.role-logistic { border-left: 5px solid #0ea5e9; }
.role-accountant { border-left: 5px solid #d97706; }
.role-admin { border-left: 5px solid #dc2626; }

@media (max-width: 1280px) {
  .dashboard-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .instructions-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 220px;
  }

  .dashboard-hero {
    flex-direction: column;
  }

  .dashboard-live-box {
    min-width: 0;
  }

  .dashboard-kpi-grid,
  .dashboard-focus-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tender-progress-head {
    flex-direction: column;
  }

  .tender-progress-badges {
    justify-content: flex-start;
  }

  .dashboard-task-head {
    flex-direction: column;
  }

  .instructions-hero {
    grid-template-columns: 1fr;
  }

  .instructions-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .main {
    padding: 12px;
  }

  .dashboard-kpi-grid,
  .dashboard-focus-list {
    grid-template-columns: 1fr;
  }

  .instructions-grid-3 {
    grid-template-columns: 1fr;
  }

  .dashboard-hero h2 {
    font-size: 24px;
  }

  .instructions-hero h2 {
    font-size: 22px;
  }

  .tender-progress-foot {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ── Admin Panel Dark Theme ──────────────────────────────────── */
body.admin-dark {
  background-color: #0f1419 !important;
  color: #e3e8f0 !important;
}

body.admin-dark .main {
  background-color: #0f1419 !important;
}

body.admin-dark .aside {
  background-color: #1a1f26 !important;
}

.admin-container {
  background-color: #1a1f26;
  border: 1px solid #2d3139;
  border-radius: 12px;
  margin: 20px;
}

.admin-section {
  background-color: #1a1f26;
  border-bottom: 1px solid #2d3139;
  padding: 20px;
}

.admin-section h2 {
  color: #3b82f6;
  margin-bottom: 15px;
  font-size: 20px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.stat-card {
  background-color: #242a33;
  border-left: 4px solid #3b82f6;
  padding: 15px;
  border-radius: 6px;
}

.stat-card div {
  color: #a0aec0;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  color: #3b82f6;
  font-size: 24px;
  display: block;
}

.admin-dark table {
  width: 100%;
  background-color: #1a1f26;
  border-collapse: collapse;
  color: #e3e8f0;
  margin-top: 10px;
}

.admin-dark table thead {
  background-color: #242a33;
  border-bottom: 2px solid #3b82f6;
}

.admin-dark table th {
  color: #3b82f6;
  font-weight: 600;
  padding: 12px;
  text-align: left;
  font-size: 12px;
}

.admin-dark table td {
  padding: 12px;
  border-bottom: 1px solid #2d3139;
}

.admin-dark table tr:hover {
  background-color: #242a33;
}

.admin-dark .btn {
  color: #e3e8f0;
  border-color: #3b82f6;
  background: transparent;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid;
  cursor: pointer;
  font-size: 13px;
}

.admin-dark .btn:hover {
  background-color: #3b82f6;
  color: white;
}

.admin-dark .btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.admin-dark .badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  display: inline-block;
}

.admin-dark .badge-success {
  background-color: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.admin-dark .badge-warning {
  background-color: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.admin-dark .badge-danger {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.admin-dark input,
.admin-dark select {
  background-color: #242a33;
  border: 1px solid #2d3139;
  color: #e3e8f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}

.admin-dark input:focus,
.admin-dark select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.admin-dark label {
  display: block;
  margin-bottom: 5px;
  color: #a0aec0;
  font-size: 13px;
  font-weight: 500;
}

.input-group {
  margin-bottom: 15px;
}

/* ── Импорт тендеров ──────────────────────────── */
/* ── Кликабельные элементы и детали ──────────────── */
[data-entity-type][data-entity-id] {
  cursor: pointer;
  color: var(--brand);
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 1px dotted var(--brand);
}

[data-entity-type][data-entity-id]:hover {
  color: var(--brand-dark);
  border-bottom: 1px solid var(--brand-dark);
  opacity: 0.8;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 10000;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 30px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.details-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.details-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
  border-bottom: 2px solid var(--brand);
  padding-bottom: 8px;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
}

.details-table tr {
  border-bottom: 1px solid var(--line);
}

.details-table tr:last-child {
  border-bottom: none;
}

.details-table td {
  padding: 10px 0;
  vertical-align: top;
}

.details-table td.label {
  font-weight: 600;
  color: var(--muted);
  width: 35%;
  padding-right: 15px;
}

.details-table td.value {
  color: var(--text);
}

.details-table a {
  color: var(--brand);
  text-decoration: underline;
}

.details-table a:hover {
  color: var(--brand-dark);
}

/* Темная тема для модали */
body.admin-dark .modal-content {
  background: #1a1f26;
  color: #e3e8f0;
}

body.admin-dark .details-section h3 {
  color: #e3e8f0;
  border-bottom-color: #3b82f6;
}

body.admin-dark .details-table tr {
  border-bottom: 1px solid #2d3139;
}

body.admin-dark .details-table td.label {
  color: #a0aec0;
}

body.admin-dark .details-table td.value {
  color: #e3e8f0;
}

body.admin-dark .details-table a {
  color: #3b82f6;
}

body.admin-dark [data-entity-type][data-entity-id] {
  color: #3b82f6;
  border-bottom: 1px dotted #3b82f6;
}

body.admin-dark [data-entity-type][data-entity-id]:hover {
  color: #60a5fa;
  border-bottom: 1px solid #60a5fa;
}

.tab-btn {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  margin-right: 4px;
  transition: all .2s;
}
.tab-btn:hover { background: var(--bg); }
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

@media (max-width: 980px) {
  .auth-card { grid-template-columns: 1fr; }
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .kpi { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .kpi { grid-template-columns: 1fr; }
}

/* ── Mail Client UI ──────────────────────────── */
.mail-shell {
  display: grid;
  grid-template-columns: 250px minmax(320px, 1fr) minmax(340px, 1.2fr);
  gap: 12px;
}

.mail-sidebar-panel,
.mail-list-panel,
.mail-preview-panel {
  margin-bottom: 0;
  min-height: calc(100vh - 185px);
}

.mail-compose-btn {
  width: 100%;
  border-radius: 12px;
  background: linear-gradient(140deg, #2563eb, #1d4ed8);
  color: #fff;
  padding: 11px 14px;
  margin-bottom: 14px;
}

.mail-compose-btn:hover { filter: brightness(1.06); }

.mailbox-chip {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #f7fbff, #edf5ff);
  padding: 10px;
  margin-bottom: 12px;
}

.mailbox-chip-title { font-size: 12px; color: var(--muted); }
.mailbox-chip-address { margin-top: 4px; font-weight: 700; color: #0f172a; }
.mailbox-chip-state { margin-top: 6px; color: #1d4ed8; font-size: 12px; }

.mail-folders { display: grid; gap: 6px; }

.mail-contacts-box {
  margin-top: 12px;
  border-top: 1px solid #dbe5f3;
  padding-top: 10px;
}

.mail-contacts-title {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mail-contacts-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}

.mail-contact-pick {
  text-align: left;
  border: 1px solid #dbe5f3;
  background: #fff;
  border-radius: 8px;
  padding: 7px 8px;
}

.mail-contact-pick:hover {
  background: #f8fbff;
  border-color: #93c5fd;
}

.mail-contact-pick strong {
  display: block;
  font-size: 12px;
  color: #0f172a;
}

.mail-contact-pick span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: #64748b;
}

.mail-folder {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #0f172a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
}

.mail-folder.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.mail-folder-count { font-size: 12px; color: #64748b; }

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

.mail-list-head h3 { font-size: 16px; }
.mail-list-head input { max-width: 260px; }

.mail-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 275px);
  overflow: auto;
  padding-right: 2px;
}

.mail-item {
  border: 1px solid #dbe5f3;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  text-align: left;
}

.mail-item:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.mail-item.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.mail-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
}

.mail-item-top strong { font-size: 13px; }
.mail-item-top span { color: #64748b; font-size: 11px; white-space: nowrap; }
.mail-item-subject { font-size: 13px; font-weight: 600; color: #0f172a; }

.mail-item-preview {
  color: #64748b;
  font-size: 12px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-item-foot {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mail-item-attach-flag {
  font-size: 12px;
  color: #475569;
}

.mail-status {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.mail-status-sent { background: #dcfce7; color: #15803d; }
.mail-status-failed { background: #fee2e2; color: #b91c1c; }
.mail-status-queued { background: #fef3c7; color: #92400e; }
.mail-status-draft { background: #e2e8f0; color: #334155; }

.mail-preview,
.mail-preview-empty {
  min-height: calc(100vh - 255px);
}

.mail-preview-empty {
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 14px;
}

.mail-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 10px;
}

.mail-preview-head h4 { font-size: 20px; }

.mail-preview-meta {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 13px;
}

.mail-preview-actions {
  margin-top: 12px;
}

.mail-preview-attachments {
  margin-top: 10px;
  font-size: 13px;
  color: #334155;
}

.mail-preview-attachment-tags {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mail-preview-attachment {
  display: inline-flex;
  align-items: center;
  border: 1px solid #dbe5f3;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: #f8fbff;
}

.mail-preview-error {
  margin-top: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
}

.mail-preview-body {
  margin-top: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
  min-height: 240px;
  font-size: 14px;
  line-height: 1.52;
  white-space: pre-wrap;
}

.mail-composer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 700;
}

.mail-composer-backdrop.open { display: flex; }

.mail-composer-card {
  width: min(720px, calc(100% - 24px));
  border-radius: 14px;
  background: #fff;
  border: 1px solid #dbe5f3;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.mail-composer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.mail-close-btn {
  background: transparent;
  border: 1px solid #dbe5f3;
  border-radius: 8px;
  color: #475569;
  padding: 4px 8px;
}

.mail-compose-form {
  display: grid;
  gap: 8px;
  padding: 14px 16px 16px;
}

.mail-compose-form label {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mail-recipient-box {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 7px;
  background: #fff;
}

.mail-compose-inline-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 2px;
}

.mail-link-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 13px;
  padding: 0;
}

.mail-ccbcc-wrap {
  display: grid;
  gap: 8px;
}

.mail-recipient-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.mail-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.mail-chip button {
  border: none;
  background: transparent;
  color: #1d4ed8;
  padding: 0;
  font-size: 12px;
}

#mailToInput,
#mailCcInput,
#mailBccInput {
  border: none;
  padding: 4px 6px;
  width: 100%;
}

#mailToInput:focus,
#mailCcInput:focus,
#mailBccInput:focus {
  outline: none;
}

.mail-compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.mail-attachment-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.mail-attachment-help {
  color: #64748b;
  font-size: 12px;
}

.mail-attachment-list {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.mail-attachment-empty {
  color: #64748b;
  font-size: 12px;
}

.mail-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #dbe5f3;
  border-radius: 10px;
  background: #f8fbff;
  padding: 6px 10px;
  font-size: 12px;
  color: #334155;
}

.mail-attachment-item button {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  padding: 2px 8px;
}

.mail-empty {
  border: 1px dashed #bfdbfe;
  border-radius: 10px;
  padding: 12px;
  color: #475569;
  text-align: center;
  background: #f8fbff;
}

@media (max-width: 1100px) {
  .mail-shell { grid-template-columns: 220px 1fr; }
  .mail-preview-panel { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .mail-shell { grid-template-columns: 1fr; }
  .mail-sidebar-panel,
  .mail-list-panel,
  .mail-preview-panel { min-height: auto; }
  .mail-list,
  .mail-preview,
  .mail-preview-empty { max-height: none; min-height: auto; }
  .mail-list-head { flex-direction: column; align-items: stretch; }
  .mail-list-head input { max-width: none; }
}
