/* =============================================================
   73.cirspb.com — portal v2 · mobile-first, dark default
   Дизайн в духе Linear/Vercel/Stripe с инженерным характером.
   ============================================================= */

/* ===== Tokens ===== */
:root {
  /* Surfaces — dark default */
  --bg: #0a0e16;
  --bg-elev: #0e131e;
  --panel: #131927;
  --panel-2: #1a2236;
  --panel-3: #232d45;
  --line: #232d45;
  --line-soft: #1c2438;

  /* Text */
  --text: #e8edf5;
  --text-soft: #b8c1d1;
  --muted: #7a869e;
  --muted-2: #5a6580;

  /* Brand · teal/mint */
  --primary: #2dd4bf;
  --primary-2: #14b8a6;
  --primary-3: #0d9488;
  --primary-soft: rgba(45, 212, 191, 0.12);
  --primary-border: rgba(45, 212, 191, 0.35);

  /* Accent · amber (money) */
  --accent: #fbbf24;
  --accent-2: #f59e0b;
  --accent-soft: rgba(251, 191, 36, 0.13);
  --accent-border: rgba(251, 191, 36, 0.4);

  /* States */
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
  --ok-border: rgba(52, 211, 153, 0.4);
  --warn: #fb923c;
  --warn-soft: rgba(251, 146, 60, 0.13);
  --warn-border: rgba(251, 146, 60, 0.4);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --danger-border: rgba(248, 113, 113, 0.4);

  /* Role accents */
  --role-main: #2dd4bf;
  --role-senior: #fbbf24;
  --role-tech: #fb923c;
  --role-initiator: #c084fc;

  /* Geometry */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-glow-primary: 0 8px 28px rgba(45, 212, 191, 0.18);
  --shadow-glow-accent: 0 8px 28px rgba(251, 191, 36, 0.18);

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 160ms;
  --t-mid: 240ms;
  --t-slow: 320ms;

  /* Layout */
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --content-max: 1180px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ===== Light theme ===== */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --bg-elev: #ffffff;
    --panel: #ffffff;
    --panel-2: #f1f3f9;
    --panel-3: #e4e8f1;
    --line: #e2e6ef;
    --line-soft: #ecf0f6;

    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;

    --primary-soft: rgba(13, 148, 136, 0.10);
    --primary-border: rgba(13, 148, 136, 0.32);
    --primary: #0d9488;
    --primary-2: #14b8a6;

    --accent: #d97706;
    --accent-2: #b45309;
    --accent-soft: rgba(217, 119, 6, 0.10);
    --accent-border: rgba(217, 119, 6, 0.3);

    --ok: #10b981;
    --ok-soft: rgba(16, 185, 129, 0.10);
    --ok-border: rgba(16, 185, 129, 0.3);
    --warn: #ea580c;
    --warn-soft: rgba(234, 88, 12, 0.10);
    --warn-border: rgba(234, 88, 12, 0.3);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --danger-border: rgba(220, 38, 38, 0.3);

    --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-2: 0 6px 24px rgba(15, 23, 42, 0.08);
  }
}

/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  /* subtle dotted background for character */
  background-image:
    radial-gradient(circle at 18% -10%, rgba(45, 212, 191, 0.05), transparent 40%),
    radial-gradient(circle at 90% 0%, rgba(251, 191, 36, 0.04), transparent 35%);
  background-attachment: fixed;
}

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--primary-2); }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

::selection { background: var(--primary-soft); color: var(--text); }

/* ===== Buttons ===== */
button, .btn {
  appearance: none;
  -webkit-appearance: none;
  background: var(--primary);
  color: #06231f;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  height: 44px;
  min-height: 44px;
  font: 600 14.5px/1 var(--font-sans);
  letter-spacing: -0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--primary-2); transform: translateY(-1px); box-shadow: var(--shadow-glow-primary); }
button:active, .btn:active { transform: translateY(0); box-shadow: none; }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:disabled, .btn:disabled {
  background: var(--panel-2); color: var(--muted-2);
  cursor: not-allowed; transform: none; box-shadow: none;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--panel-3); box-shadow: var(--shadow-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--panel-2); color: var(--text); box-shadow: none; }

.btn-danger {
  background: var(--danger);
  color: #2a0606;
}
.btn-danger:hover { background: #ef4444; box-shadow: 0 8px 24px rgba(248,113,113,0.25); }

.btn-warn {
  background: var(--warn);
  color: #2a1206;
}

.btn-sm {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13.5px;
  border-radius: 8px;
}

a.btn { text-decoration: none; }

/* ===== Inputs ===== */
input, select, textarea {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  height: 44px;
  min-height: 44px;
  font: 15px/1.4 var(--font-sans);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
textarea {
  min-height: 92px;
  padding: 11px 13px;
  resize: vertical;
  line-height: 1.5;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a869e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: var(--panel-3); }
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--primary);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }

label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px; font-weight: 500; letter-spacing: 0.01em; }

.field { margin-bottom: 14px; }
.field.prefilled input,
.field.prefilled textarea,
.field.prefilled select {
  border-color: var(--primary-border);
  background: linear-gradient(180deg, var(--panel-2), var(--primary-soft) 800%);
}
.pf-hint {
  font-size: 11.5px;
  color: var(--primary);
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== Layout ===== */
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

main {
  padding: 20px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 + .subtitle {
  color: var(--muted);
  margin-bottom: 22px;
  font-size: 14px;
  max-width: 60ch;
}
h2 {
  margin: 28px 0 14px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h3 {
  margin: 16px 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.subtitle { color: var(--muted); }

/* ===== Topbar ===== */
.topbar {
  background: rgba(10, 14, 22, 0.85); /* фолбэк для iOS < 16.2 */
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.topbar .brand-logo {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: block;
}
.topbar .brand-host { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 1px; }
.topbar .brand-ver {
  align-self: flex-end;
  margin-left: -3px;
  margin-bottom: 1px;
  color: var(--text-soft);
  opacity: 0.8;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0;
  text-decoration: none;
  line-height: 1;
}
.topbar .brand-ver:hover { opacity: 1; text-decoration: underline; }

.topbar nav {
  display: none;
  gap: 2px;
  flex-wrap: wrap;
  margin-left: 8px;
}
.topbar nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative;
}
.topbar nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.topbar nav a.active {
  color: var(--text);
  background: var(--panel-2);
}
.topbar nav a.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px;
  bottom: -2px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.topbar .spacer { flex: 1; }

.user-chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 5px 6px 5px 14px;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}
.user-chip > span:not(.lvl):not(.streak-chip) {
  overflow: hidden; text-overflow: ellipsis; max-width: 160px;
  color: var(--text-soft);
}
.user-chip .lvl {
  background: linear-gradient(135deg, var(--primary), var(--primary-3));
  color: #042421;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.01em;
}
.user-chip a.muted {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg);
  font-size: 12px;
  border: 1px solid var(--line);
}
.user-chip a.muted:hover { color: var(--danger); border-color: var(--danger-border); }

/* ===== Cards ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
}

/* ===== Grid ===== */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
/* Очень узкие экраны: статкарты с крупными числами в одну колонку, чтобы суммы не обрезались */
@media (max-width: 380px) {
  .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 720px) {
  .grid { gap: 14px; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .grid { gap: 16px; }
}

/* Helpers */
.muted { color: var(--muted); }
.bold { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }

/* ===== Stat cards ===== */
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 100% 0%, var(--primary-soft), transparent 50%);
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease);
  pointer-events: none;
}
.stat:hover { transform: translateY(-1px); border-color: var(--panel-3); }
.stat:hover::before { opacity: 0.6; }
.stat .lbl {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.stat .val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.stat .hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.stat.accent .val { color: var(--accent); }
.stat.accent::before { background: radial-gradient(120% 80% at 100% 0%, var(--accent-soft), transparent 50%); }
.stat.primary .val { color: var(--primary); }
.stat.ok .val { color: var(--ok); }
.stat.ok::before { background: radial-gradient(120% 80% at 100% 0%, var(--ok-soft), transparent 50%); }
.stat.danger .val { color: var(--danger); }

/* ===== Level card ===== */
.lvl-card {
  position: relative;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(45, 212, 191, 0.18), transparent 55%),
    radial-gradient(80% 70% at 0% 100%, rgba(251, 191, 36, 0.10), transparent 55%),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
  margin-bottom: 14px;
}
.lvl-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 18px 18px;
  pointer-events: none;
  opacity: 0.6;
}
.lvl-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  position: relative;
}
.lvl-badge {
  flex-shrink: 0;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-3) 100%);
  color: #042421;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(45, 212, 191, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative;
}
.lvl-badge::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.5), transparent 50%);
  mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  padding: 1px;
  pointer-events: none;
}
.lvl-badges-link {
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-soft);
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.lvl-badges-link:hover { background: var(--panel-3); border-color: var(--primary); text-decoration: none; }
.lvl-badges-link:active { transform: scale(0.96); }
.lvl-badges-link .icon { width: 22px; height: 22px; color: var(--primary); }
.lvl-badges-count { font-size: 16px; font-weight: 800; line-height: 1; }
.lvl-badges-text { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.lvl-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.lvl-mult {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

/* ===== Progress bar ===== */
.progress {
  height: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: var(--radius-pill);
  transition: width var(--t-slow) var(--ease);
  position: relative;
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.3);
}
.progress > div::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
  animation: shimmer 2.4s var(--ease) infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.progress-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ===== Test period timer (collapsible) ===== */
.test-period {
  position: relative;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.test-period-sum {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
.test-period-sum::-webkit-details-marker { display: none; }
.test-period-sum .tp-emoji { font-size: 13px; line-height: 1; }
.test-period-sum .tp-label { font-weight: 600; color: var(--text); }
.test-period-sum .tp-date {
  font-size: 11px;
  color: var(--muted-2);
  white-space: nowrap;
}
.test-period-sum::after {
  content: "▾";
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-2);
  transition: transform 0.2s var(--ease, ease);
}
.test-period[open] .test-period-sum::after { transform: rotate(180deg); }
.test-period-body {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius, 10px);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.test-period-body .tp-row + .tp-row { margin-top: 6px; }
.test-period-body .tp-accent { color: var(--text); font-weight: 600; }

/* ===== Lists / Deal cards ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.list-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--muted-2);
  opacity: 0.6;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.list-row:hover { border-color: var(--panel-3); }
.list-row:hover::before { opacity: 1; }

/* Role color stripes */
.list-row:has(.badge.ok)::before        { background: var(--role-main); }
.list-row:has(.badge.accent)::before    { background: var(--role-senior); }
.list-row:has(.badge.warn)::before      { background: var(--role-tech); }

.list-row .meta {
  flex: 1 1 220px;
  min-width: 0;
}
.list-row .meta .title {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  line-height: 1.35;
  word-break: break-word;
}
.list-row .meta .sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  line-height: 1.5;
  word-break: break-word;
}
.list-row .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
@media (max-width: 540px) {
  .list-row .actions { width: 100%; }
  .list-row .actions .btn,
  .list-row .actions button { flex: 1; min-width: 130px; }
}

/* Подсказка по сделке-проверке: занеси данные в карточку судна */
.deal-check-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
}
.deal-check-hint .dch-body { flex: 1 1 auto; min-width: 0; }
.deal-check-hint .dch-title { font-weight: 700; font-size: 13.5px; color: #fbbf24; }
.deal-check-hint .dch-text { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.deal-check-hint .btn { flex-shrink: 0; }
@media (max-width: 540px) {
  .deal-check-hint { flex-wrap: wrap; }
  .deal-check-hint .btn { width: 100%; }
}

/* Подписи названий судов на карте (постоянные тултипы Leaflet) */
.leaflet-tooltip.vessel-label {
  background: rgba(15, 23, 42, 0.86);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  line-height: 1.25;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  white-space: nowrap;
  text-align: center;
}
.leaflet-tooltip.vessel-label::before { display: none; }
.leaflet-tooltip.vessel-label .vl-name { font-size: 12px; font-weight: 700; }
.leaflet-tooltip.vessel-label .vl-sub { font-size: 10.5px; font-weight: 500; opacity: .85; margin-top: 1px; }
.leaflet-tooltip.vessel-label .vl-stale { font-size: 10.5px; font-weight: 700; color: #fb7185; margin-top: 1px; }
.leaflet-tooltip.vessel-label.stale { background: rgba(120, 20, 30, 0.9); box-shadow: 0 0 0 2px rgba(225,29,72,.55); }

/* Мультивыбор-чипы (несоответствия при приёмке/возврате) */
.issue-chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 13px;
  min-height: 40px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.issue-chip.on {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
  font-weight: 600;
}

/* ===== Badges (pills) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-soft);
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.badge.short  { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.badge.full   { background: var(--accent-soft);  color: var(--accent);  border-color: var(--accent-border); }
.badge.ok     { background: var(--ok-soft);      color: var(--ok);      border-color: var(--ok-border); }
.badge.warn   { background: var(--warn-soft);    color: var(--warn);    border-color: var(--warn-border); }
.badge.danger { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.badge.accent { background: var(--accent-soft);  color: var(--accent);  border-color: var(--accent-border); }
.badge.muted  { color: var(--muted); }

/* ===== Tables ===== */
.card table { margin: -4px 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
}
th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  background: transparent;
  position: sticky; top: 0;
}
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 30% 20%, rgba(45, 212, 191, 0.10), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(251, 191, 36, 0.06), transparent 50%);
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-2);
  animation: rise 360ms var(--ease) both;
}
.login-box h1 {
  font-size: 22px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-box h1::before {
  content: "";
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-3) 100%);
  box-shadow: 0 4px 14px rgba(45, 212, 191, 0.35);
}
.login-box .sub { color: var(--muted); margin-bottom: 22px; font-size: 13.5px; }
.login-box button { width: 100%; margin-top: 8px; height: 48px; font-size: 15px; }
/* Компактная карточка уровня для новичка */
.lvl-card-compact {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
}
.lvl-card-compact .lvl-badge { width: 38px; height: 38px; font-size: 16px; }

/* Показать пароль */
.pass-wrap { position: relative; }
.pass-wrap input { width: 100%; padding-right: 46px; }
.login-box .pass-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; margin: 0; padding: 0;
  background: transparent; border: none; box-shadow: none;
  font-size: 18px; line-height: 1; cursor: pointer; opacity: 0.75;
}
.login-box .pass-eye:active { opacity: 1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Verification — sections ===== */
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.section-title .sec-name { min-width: 0; flex: 1 1 auto; }
/* Ряд тумблеров секции (Нет на судне / Второй X нет / Безжидкостной) — переносится на узких экранах */
.sec-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 14px;
}
.section-title .pct {
  font-weight: 700;
  font-size: 11.5px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.section-title .pct.pct-mid {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
}
.section-title .pct.pct-done {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-border);
}
.section-title .pct.pct-absent {
  background: rgba(120,120,120,.12);
  color: var(--muted);
  border-color: var(--line);
}
.fv2-absent-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: all .12s;
  flex-shrink: 0;
  white-space: nowrap;
}
.fv2-absent-btn:hover { background: var(--panel-3, var(--panel-2)); color: var(--ink); }
.fv2-absent-btn.is-on {
  background: rgba(120,120,120,.18);
  color: var(--ink);
  border-color: var(--muted);
}
.fv2-absent-note {
  font-size: 13px;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  margin-top: 6px;
}
.na-note {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  padding: 8px 0;
  align-self: center;
}
.section.fv2-absent { opacity: .72; }
.section.fv2-absent .section-title { color: var(--muted); }
.equipment-block.inst-absent { opacity: .62; border-style: solid; }
.equipment-block.inst-absent .eq-title { color: var(--muted); }

.vessel-header-card .hint-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--panel-2);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}

.equipment-block {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  background: var(--panel-2);
}
.equipment-block .eq-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}
.equipment-block .eq-header .eq-title {
  font-weight: 600;
  font-size: 14px;
}

.row-2, .row-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 680px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Checkbox ===== */
.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: pointer;
  min-height: 44px;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.checkbox:hover { border-color: var(--primary-border); background: var(--panel-3); }
.checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  margin: 1px 0 0; padding: 0;
  min-height: 0;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.checkbox label {
  margin: 0;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
}

/* ===== Sticky actions ===== */
.sticky-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  background: rgba(10, 14, 22, 0.92); /* фолбэк для iOS < 16.2 */
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  margin: 24px -16px -24px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 30;
  flex-wrap: wrap;
}
.sticky-actions .left {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.sticky-actions button,
.sticky-actions .btn { flex: 1; min-width: 130px; }
@media (min-width: 680px) {
  .sticky-actions .left { flex: 1 1 auto; }
  .sticky-actions button,
  .sticky-actions .btn { flex: 0 0 auto; }
}

/* ===== Toasts ===== */
#toasts {
  position: fixed;
  left: 0; right: 0;
  /* Сверху, а не снизу: снизу перекрывала клавиатура при заполнении форм */
  top: max(14px, env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  max-width: 480px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 260ms var(--ease);
}
.toast::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.toast.ok {
  border-color: var(--ok-border);
  background: linear-gradient(180deg, var(--panel), var(--ok-soft));
}
.toast.ok::before { background: var(--ok); box-shadow: 0 0 12px var(--ok); }
.toast.err {
  border-color: var(--danger-border);
  background: linear-gradient(180deg, var(--panel), var(--danger-soft));
  color: var(--danger);
}
.toast.err::before { background: var(--danger); box-shadow: 0 0 12px var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Empty state ===== */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty::before {
  content: "";
  display: block;
  width: 40px; height: 40px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px dashed var(--line);
}

/* ===== Индикатор загрузки экрана ===== */
.route-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  min-height: 50dvh;
}
.route-spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: btnspin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .route-spinner { animation-duration: 1.4s; }
}

/* ===== Points ===== */
.points-big {
  color: var(--accent);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.points-mid {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ===== Streak chip ===== */
.streak-chip {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 11.5px;
  border: 1px solid var(--warn-border);
  display: inline-flex;
  gap: 3px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

/* ===== Badges row (horizontal scroll on dashboard) ===== */
.badges-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 8px;
  margin-top: 4px;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.badges-row::-webkit-scrollbar { height: 6px; }
.badges-row::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 3px; }
.badge-tile {
  flex: 0 0 auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 116px;
  text-align: center;
  scroll-snap-align: start;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease);
  position: relative;
  overflow: hidden;
}
.badge-tile:hover {
  transform: translateY(-3px);
  border-color: var(--primary-border);
  box-shadow: var(--shadow-glow-primary);
}
.badge-tile .badge-icon { font-size: 26px; margin-bottom: 4px; line-height: 1; }
.badge-tile .badge-name { font-size: 11.5px; color: var(--text-soft); font-weight: 500; }

/* fresh-shimmer for first badge in row */
.badge-tile:first-child::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.18) 50%, transparent 70%);
  animation: shimmer 3.2s var(--ease) infinite;
  pointer-events: none;
}

/* ===== Badges grid (full screen) ===== */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.badge-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease);
  position: relative;
  overflow: hidden;
}
.badge-card.earned {
  border-color: var(--primary-border);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--primary-soft), transparent 60%),
    var(--panel);
}
.badge-card.earned::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}
.badge-card.locked { opacity: 0.45; filter: grayscale(0.6); }
.badge-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.badge-card.earned:hover { box-shadow: var(--shadow-glow-primary); }

.badge-icon-big { font-size: 40px; line-height: 1; margin-bottom: 4px; }
.badge-name-big { font-weight: 700; font-size: 14px; margin-top: 8px; letter-spacing: -0.01em; }
.badge-status { font-size: 11.5px; color: var(--ok); margin-top: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-status.locked { color: var(--muted); font-weight: 500; }

/* ===== Progress overview (verification top card) ===== */
.progress-overview {
  background:
    radial-gradient(140% 90% at 100% 0%, rgba(251, 191, 36, 0.10), transparent 55%),
    radial-gradient(80% 70% at 0% 100%, rgba(45, 212, 191, 0.12), transparent 55%),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border-color: var(--line);
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: 20;
  box-shadow: var(--shadow-2);
}
.progress-overview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.progress-overview .overall-pct {
  font-size: 38px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(45, 212, 191, 0.4);
  flex-shrink: 0;
}

/* ===== Section pills ===== */
.sec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sec-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  border: 1px solid var(--line);
  background: var(--panel);
  white-space: nowrap;
  color: var(--text-soft);
  transition: transform var(--t-fast) var(--ease);
}
.sec-pill:hover { transform: translateY(-1px); }
.sec-pill.done {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-border);
}
.sec-pill.mid {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
}
.sec-pill.empty { color: var(--muted); }
.sec-pill-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.sec-pill-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== SVG icons (inline in JS) ===== */
.icon {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm { width: 14px; height: 14px; stroke-width: 2.2; }
.icon-lg { width: 22px; height: 22px; }

/* ===== Bottom tab bar (mobile) ===== */
.tabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  /* Solid фон — иначе in-app браузеры могут не рендерить backdrop-blur */
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
  display: flex;
  z-index: 1000;
}
/* отступ под таббар внутри main, чтобы контент не уходил под него */
main { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 4px 4px;
  position: relative;
  min-height: 44px;
  transition: color var(--t-fast) var(--ease);
}
.tabbar a:hover { color: var(--text-soft); text-decoration: none; }
.tabbar a .icon { width: 22px; height: 22px; stroke-width: 1.9; }
.tabbar a.active {
  color: var(--primary);
}
.tabbar a.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2.5px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 0 10px var(--primary);
}

/* Desktop layout */
@media (min-width: 769px) {
  :root {
    --tabbar-h: 0px;
  }
  .topbar { padding: 0 24px; height: 60px; }
  .topbar nav { display: flex; }
  .tabbar { display: none; }
  main { padding: 28px 24px 48px; }
  h1 { font-size: 28px; }
  h2 { font-size: 19px; margin-top: 32px; }
  .card { padding: 22px; margin-bottom: 16px; }
  .section { padding: 20px; }
  .stat { padding: 18px; }
  .stat .val { font-size: 28px; }
  .sticky-actions { bottom: 0; }
}
@media (min-width: 1024px) {
  main { padding: 32px 32px 64px; }
  h1 { font-size: 30px; letter-spacing: -0.025em; }
}

/* On mobile · hide the desktop nav inside topbar */
@media (max-width: 768px) {
  .topbar nav { display: none !important; }
  .topbar .spacer { flex: 1; }
  .user-chip > span:not(.lvl):not(.streak-chip),
  .user-chip a.muted { display: none; }
  .user-chip {
    padding: 4px 6px 4px 4px;
    background: transparent;
    border: 0;
  }
}

/* Hide tabbar when login screen / no ME (no #app children except login-wrap) */
.tabbar.hidden { display: none !important; }

/* ===== Scroll niceties ===== */
html { scroll-behavior: smooth; }
* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

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

main > h1, main > .subtitle, main > .card, main > .lvl-card, main > .section, main > .list, main > .grid {
  animation: fadeUp 320ms var(--ease) both;
}
main > *:nth-child(2) { animation-delay: 40ms; }
main > *:nth-child(3) { animation-delay: 80ms; }
main > *:nth-child(4) { animation-delay: 120ms; }
main > *:nth-child(5) { animation-delay: 160ms; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Admin nav (tab pill row) ===== */
main > div[style*="display:flex"][style*="margin-bottom: 18px"] a.btn,
main > div[style*="display:flex"][style*="margin-bottom: 18px"] a.btn-sm {
  text-decoration: none;
}

/* Pretty separator inside .sub */
.list-row .sub { white-space: normal; }

/* ===== Misc safe overrides ===== */
hr { border: 0; height: 1px; background: var(--line); margin: 20px 0; }
code, kbd, pre { font-family: var(--font-mono); font-size: 12.5px; }

/* avoid double-tap zoom on labels in iOS */
label, .checkbox, .badge { touch-action: manipulation; }

/* ===== Password modal ===== */
.pw-modal {
  position: fixed; inset: 0;
  background: rgba(8,12,20,0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 16px;
  animation: fadeUp 220ms var(--ease);
}
.pw-modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-2), 0 0 0 1px var(--primary-border);
}
.pw-modal-box h2 { font-size: 22px; letter-spacing: -0.01em; }
.pw-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.pw-label { color: var(--muted); font-size: 12px; min-width: 70px; }
.pw-val { font-size: 17px; font-weight: 600; flex: 1; word-break: break-all; }
.pw-val.mono { font-family: var(--font-mono); letter-spacing: 0.5px; }

/* ===== Confirm / prompt modal (свои, вместо нативных confirm/prompt) ===== */
.confirm-box { max-width: 420px; }
.confirm-box h2 { font-size: 19px; margin: 0 0 12px; letter-spacing: -0.01em; }
.confirm-box .confirm-text {
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0 0 10px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.confirm-box .confirm-text:last-of-type { margin-bottom: 4px; }
.confirm-box label.confirm-text { display: block; color: var(--muted); margin-bottom: 8px; }
.confirm-box input, .confirm-box textarea { margin-top: 4px; }
.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.confirm-actions .btn { flex: 1; min-width: 0; }
@media (max-width: 420px) {
  .confirm-actions { flex-direction: column-reverse; }
}

/* Кнопка в состоянии загрузки — спиннер, текст приглушён */
.btn.is-busy, button.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after, button.is-busy::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  top: 50%; left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--text);
  border-right-color: transparent;
  border-radius: 50%;
  animation: btnspin 0.6s linear infinite;
}
@keyframes btnspin { to { transform: rotate(360deg); } }

/* Disabled row appearance */
tr.row-muted td { opacity: 0.55; }

/* Hook log monospace */
.hook-log td { font-family: var(--font-mono); font-size: 12px; }

/* ===== Date picker trio (день / месяц / год) ===== */
.date-trio {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 80px;
  gap: 6px;
}
.date-trio select {
  padding: 0 8px;
  padding-right: 22px;   /* меньше места под стрелку */
  background-position: right 6px center;
  background-size: 10px 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  min-width: 0;
}
@media (max-width: 480px) {
  .date-trio {
    grid-template-columns: 58px minmax(0, 1fr) 78px;
    gap: 4px;
  }
  .date-trio select {
    font-size: 13px;
    padding: 0 6px;
    padding-right: 20px;
    background-position: right 5px center;
  }
}

/* ===== Photo grid ===== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.photo-del {
  position: absolute;
  top: 6px; right: 6px;
  width: 34px; height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(8,12,20,0.72);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 20px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
/* Невидимое расширение зоны нажатия до ~48px, чтобы палец не мазал */
.photo-del::before {
  content: "";
  position: absolute;
  inset: -7px;
}
.photo-del:hover { background: var(--danger); transform: none; }
.photo-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  grid-column: 1 / -1;
}

/* ===== Progress overview compact (mobile-first) ===== */
.po-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
  -webkit-user-select: none;
}
.po-bar-left {
  display: flex;
  flex-direction: column;
  min-width: 90px;
  gap: 2px;
}
.po-pct {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.02em;
}
.po-money {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.po-bar-progress {
  flex: 1;
  height: 8px;
  background: var(--panel-2);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
.po-bar-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  transition: width var(--t-mid) var(--ease);
}
.po-chevron {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--muted);
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.po-collapsed { padding: 0; }
.po-details {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

/* ===== Badges row — fix overflow on dashboard ===== */
.badges-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;        /* Firefox */
}
.badges-row::-webkit-scrollbar { display: none; }
.badge-tile {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 110px;
  min-height: 96px;
}

/* На мобиле прогресс ещё компактнее */
@media (max-width: 768px) {
  .po-bar { padding: 2px 0; }
  .po-pct { font-size: 18px; }
  .po-money { font-size: 13px; }
  .po-bar-left { min-width: 78px; }
}

/* ===== Photo buttons (camera / gallery) ===== */
.photo-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.photo-input-hidden {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.photo-btn {
  cursor: pointer;
  text-align: center;
  flex-direction: column;
  height: 76px;
  gap: 4px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}
.photo-btn-icon {
  font-size: 26px;
  line-height: 1;
}
@media (max-width: 480px) {
  .photo-btn { height: 84px; font-size: 13.5px; }
}

/* ===== Photo upload progress ===== */
.photo-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}
.photo-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 100px;
  overflow: hidden;
}
.photo-progress-bar > div {
  height: 100%;
  background: var(--primary);
  border-radius: 100px;
  transition: width var(--t-mid) var(--ease);
}

/* Кликабельная карточка сделки в списке */
.meta-link {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  margin: -8px -8px -8px -8px;
  padding: 8px;
  transition: background var(--t-fast) var(--ease);
}
.meta-link:hover { background: var(--panel-2); text-decoration: none; }
.meta-link .title { color: var(--text); }

/* ===== Формы регистра ===== */
.forms-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px) {
  .forms-grid { grid-template-columns: repeat(3, 1fr); }
}
.form-slot {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--panel-2);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.form-slot.done {
  border-color: var(--ok-border);
  background: var(--panel-2); /* фолбэк для iOS < 16.2 */
  background: linear-gradient(135deg, var(--panel-2), color-mix(in oklab, var(--ok-soft) 60%, transparent));
}
.form-slot-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.form-slot-title { font-weight: 700; font-size: 14px; }
.form-slot-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.form-slot .form-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
.form-slot .photo-thumb { aspect-ratio: 1; }

/* ===== Date picker v3 — компактнее, плейсхолдеры ДД ММ ГГГГ ===== */
.date-trio select {
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}
/* Узкий iPhone (≤390px) — компактные тройные селекты остаются в строку */
@media (max-width: 390px) {
  .date-trio {
    grid-template-columns: 54px minmax(0, 1fr) 76px;
    gap: 4px;
  }
  .date-trio select {
    padding: 0 4px;
    padding-right: 18px;
    background-position: right 4px center;
    font-size: 13px;
  }
}

/* ===== Full V2: status rows (ОК / не ОК) ===== */
.fv2-checks-header {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 8px;
  font-weight: 600;
}
.fv2-status-row {
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}
.fv2-status-row:first-of-type { border-top: none; }
.fv2-status-label {
  font-size: 13.5px;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text-soft);
}
.fv2-status-choices {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.fv2-status-btn {
  flex: 1;
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text-soft);
  border: 1.5px solid var(--line);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.fv2-status-btn.ok.active {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-border);
}
.fv2-status-btn.bad.active {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}
.fv2-status-btn:hover { background: var(--panel-3); transform: none; box-shadow: none; }
.fv2-note { margin-top: 6px; }
.fv2-note input { font-size: 13px; padding: 0 10px; min-height: 38px; height: 38px; }

/* Индикатор автосохранения */
.sync-ind {
  font-size: 11px;
  color: var(--ok);
  margin-top: 2px;
  transition: color var(--t-fast) var(--ease);
}
.sync-ind.pending {
  color: var(--warn);
}

/* Кликабельные chips в topbar */
.user-chip a, .streak-chip {
  cursor: pointer;
  transition: filter var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.user-chip a:hover, .streak-chip:hover {
  filter: brightness(1.15);
  text-decoration: none;
}
.user-chip a.lvl:hover, a.streak-chip:hover {
  transform: scale(1.03);
}
.lvl-mini {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ===== Date picker v4 — фикс-ширины символов ===== */
.date-trio {
  display: flex !important;
  gap: 6px;
  grid-template-columns: none !important;
  align-items: center;
}
.date-trio select {
  width: auto !important;
  flex: 0 0 auto;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.date-trio select[aria-label="День"]    { width: 4.5ch; padding: 0 4px; padding-right: 14px; background-position: right 2px center; }
.date-trio select[aria-label="Месяц"]   { width: 4.5ch; padding: 0 4px; padding-right: 14px; background-position: right 2px center; }
.date-trio select[aria-label="Год"]     { width: 6.5ch; padding: 0 4px; padding-right: 14px; background-position: right 2px center; }
@media (max-width: 390px) {
  .date-trio select { font-size: 13px; height: 40px; min-height: 40px; }
}

/* Прячем низ при открытой клавиатуре (поддерживает Safari 15.4+) */
body:has(input:focus, textarea:focus) .tabbar,
body:has(input:focus, textarea:focus) .sticky-actions {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--t-mid) var(--ease), opacity var(--t-fast) var(--ease);
}

/* JS-fallback (если :has() не поддерживается) */
body.kb-active .tabbar,
body.kb-active .sticky-actions {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--t-mid) var(--ease), opacity var(--t-fast) var(--ease);
}

/* Карточка инициативы */
.init-card {
  cursor: pointer;
  border: 1.5px solid var(--line);
  transition: all var(--t-fast) var(--ease);
}
.init-card:hover { border-color: var(--accent-border); background: var(--panel-2); }
.init-card.active {
  background: linear-gradient(135deg, var(--accent-soft), var(--primary-soft));
  border-color: var(--accent-border);
  box-shadow: var(--shadow-glow-accent);
}
.init-card.active input[type="checkbox"] { accent-color: var(--accent); }

/* Streak chip — с подписью «серия» */
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.streak-num { font-weight: 800; }
.streak-text { font-size: 10px; font-weight: 500; opacity: 0.7; letter-spacing: 0.5px; }
@media (max-width: 480px) {
  .streak-text { display: none; }
}

/* ===== Лестница уровней — карточки ===== */
.levels-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 768px) {
  .levels-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .levels-grid { grid-template-columns: repeat(3, 1fr); }
}
.level-card {
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--t-fast) var(--ease);
}
.level-card.current {
  background: linear-gradient(135deg, var(--primary-soft), var(--panel));
  border-color: var(--primary-border);
  box-shadow: var(--shadow-glow-primary);
}
.level-card.locked { opacity: 0.55; }
.level-card.locked .lvl-badge { background: var(--panel-3); color: var(--muted); }
.level-card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.level-card .lvl-badge {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #06231f;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
}
.level-name {
  font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.you-are-here {
  background: var(--primary) !important;
  color: #06231f !important;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.level-mult {
  font-weight: 800;
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.level-rates {
  display: flex; flex-direction: column; gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
}
.rate-row { display: flex; justify-content: space-between; }

/* Предупреждение о деградации */
.decay-warn {
  background: linear-gradient(135deg, var(--warn-soft), var(--panel));
  border-color: var(--warn-border);
}
.decay-warn h3 { color: var(--warn); }

/* ===== Защита от горизонтального overflow ===== */
html, body, #app {
  overflow-x: hidden;
  max-width: 100vw;
}
main { max-width: 100vw; }
.card, .section, .equipment-block, .form-slot, .repeat-block, .init-card, .lvl-card {
  max-width: 100%;
  overflow: hidden;
  word-wrap: break-word;
}
.grid, .grid-2, .grid-3, .grid-4, .row-2, .row-3, .info-grid {
  max-width: 100%;
  min-width: 0;
}
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > *, .row-2 > *, .row-3 > *, .info-grid > * {
  min-width: 0;
}
/* Таблицы — горизонтальный скролл внутри своего контейнера, не на всю страницу */
table { max-width: 100%; }
.card > table { display: block; overflow-x: auto; }

/* ===== Lightbox для фото ===== */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(8,12,20,0.92);
  display: grid; place-items: center;
  z-index: 10000;
  padding: 16px;
  animation: fadeUp 220ms var(--ease);
}
.lightbox img {
  max-width: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: var(--radius-sm);
  cursor: zoom-out;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lightbox-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px; height: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 26px;
  cursor: pointer;
  padding: 0;
  display: grid; place-items: center;
  line-height: 1;
}
.lightbox-close:hover { background: var(--danger); transform: none; box-shadow: none; }

/* ===== Карточка-ссылка «Документы» на главной ===== */
.doc-shortcut {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--text);
}
.doc-shortcut:hover { border-color: var(--primary-border); text-decoration: none; }
@media (hover: none) { .doc-shortcut:active { transform: scale(0.99); } }
.doc-shortcut-ic { font-size: 26px; line-height: 1; flex-shrink: 0; }
.doc-shortcut-title { font-weight: 700; font-size: 16px; }
.doc-shortcut-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.doc-shortcut-arrow { width: 20px; height: 20px; color: var(--muted-2); margin-left: auto; flex-shrink: 0; }

/* ===== Инструкция инженера: модалка + плитки документов ===== */
.docs-card {
  margin-top: 18px;
  margin-bottom: 18px;
  padding: 18px;
}
.docs-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}
.docs-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.doc-tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: var(--ink);
}
.doc-tile:hover {
  border-color: var(--accent);
  background: var(--panel);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,.18);
}
.doc-icon { font-size: 28px; margin-bottom: 8px; }
.doc-name { font-weight: 700; font-size: 15px; margin-bottom: 3px; color: var(--ink); }
.doc-desc { color: var(--muted); font-size: 13px; }

.manual-modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.manual-modal-box {
  background: #fff;
  color: #0f172a; /* явно тёмный текст независимо от темы */
  border-radius: 18px;
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}
.manual-modal-box * { color: inherit; }
.manual-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; gap: 10px;
  background: #f6f7fb;
  color: #0f172a;
}
.manual-modal-header h2 { flex: 1; color: #0f172a; }
.manual-close {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
}
.manual-close:hover { background: var(--panel-2); color: var(--ink); }
.manual-content {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px; line-height: 1.55;
  color: #1e293b;
  background: #fff;
}
.manual-content h2 {
  font-size: 17px; color: #2563eb;
  margin: 18px 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}
.manual-content h2:first-child { margin-top: 0; }
.manual-content ul, .manual-content ol { padding-left: 22px; margin: 6px 0 12px; color: #1e293b; }
.manual-content li { margin-bottom: 4px; color: #1e293b; }
.manual-content p { margin: 0 0 10px; color: #1e293b; }
.manual-content b, .manual-content strong { color: #0f172a; }
.manual-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex; gap: 12px; align-items: center;
  background: #f6f7fb;
  color: #1e293b;
}
.manual-modal-footer .muted { color: #64748b !important; }
@media (max-width: 600px) {
  .manual-modal { padding: 0; }
  .manual-modal-box { border-radius: 0; max-height: 100vh; max-height: 100dvh; height: 100vh; height: 100dvh; }
}

/* =========================================================
   MOBILE POLISH v2 (95% мобильных) — анти-зум, тач-фидбек,
   скролл таблиц, dvh, безопасные зоны. Не трогает десктоп.
   ========================================================= */

/* 1) Анти-зум iOS: текстовые поля >=16px на тач-устройствах.
   Селекты не зумят (открывают пикер) — их не трогаем, чтобы
   тройной date-picker остался компактным. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea {
    font-size: 16px;
  }
  /* Вторичные кнопки чуть крупнее под палец */
  .btn-sm { height: 40px; min-height: 40px; }
  /* Низкие чекбоксы/радио — увеличиваем зону нажатия */
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; width: 22px; height: 22px; }
}

/* 2) Тач-отклик (на телефоне нет :hover) — лёгкое «вдавливание»
   для всех кликабельных карточек/строк/чипов. */
@media (hover: none) {
  .doc-tile:active, .meta-link:active, .init-card:active,
  .level-card:active, .badge-tile:active, .sec-pill:active,
  .list-row:active, .stat:active {
    transform: scale(0.985);
    transition: transform 90ms var(--ease, ease);
  }
  .meta-link:active { background: var(--panel-2); }
  /* Отключаем «залипающий» hover-фон после тапа */
  tbody tr:hover { background: transparent; }
}

/* 3) Таблицы — на мобиле горизонтальный скролл внутри себя,
   чтобы широкие таблицы админки не обрезались overflow-guard'ом. */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  table thead, table tbody, table tr { width: 100%; }
  /* шапки таблиц не должны липнуть в горизонтальном скролле */
  th { position: static; }
  /* Рейтинг: не сжимать колонки до разрыва цифр — пусть скроллится горизонтально */
  .lb-table th, .lb-table td { white-space: nowrap; }
}

/* Рейтинг: моя строка выделена */
.lb-table tr.lb-me td {
  background: rgba(45, 212, 191, 0.13); /* primary 13%, без color-mix ради старых iOS */
}
.lb-table tr.lb-me td:first-child { border-radius: 8px 0 0 8px; }
.lb-table tr.lb-me td:last-child { border-radius: 0 8px 8px 0; }

/* 4) overscroll-behavior: прокрутка внутри модалок/чата не утягивает
   фон страницы. */
.manual-content, .comments-list, .lightbox, .pw-modal, .manual-modal {
  overscroll-behavior: contain;
}

/* 5) Якорный скролл к секциям не прячется под липкую шапку. */
.section, h2, [id] {
  scroll-margin-top: calc(var(--topbar-h, 52px) + 14px);
}

/* 6) Длинные слова/коды/email не ломают вёрстку на узких экранах. */
.title, .sub, .list-row, .card, .pw-val, .doc-desc, .lvl-name {
  overflow-wrap: anywhere;
}

/* 7) Картинки и медиа не выходят за контейнер. */
img, svg, video, canvas { max-width: 100%; }

/* 8) Полноэкранные тач-цели в нижнем меню — увеличенная высота нажатия. */
@media (max-width: 768px) {
  .tabbar a { min-height: 52px; }
}
