/* Импульс CRM Mobile — мини-PWA для старшего оператора.
   Самодостаточный CSS: токены темы (airy/dark) зеркалируют public/styles.css,
   но вёрстка целиком мобильная (без десктоп-грида и сайдбара). */

:root {
  --accent: #D4F250;
  --accent-2: #C6E739;
  --accent-soft: #F0F8C2;
  --accent-text: #1B2A05;
  --on-accent: #1B2A05;

  --bg: #F2EFE8;
  --bg-2: #EBE7DC;
  --surface: #FFFFFF;
  --surface-2: #F7F4EB;
  --border: #E0DCD0;
  --border-2: #D2CDC0;
  --text: #0B0B0A;
  --text-2: #2A2A26;
  --text-3: #525049;

  --success: #1F8A5B;
  --success-soft: #E4F4EC;
  --warn: #C77A14;
  --warn-soft: #F8EAD3;
  --danger: #D14A2F;
  --danger-soft: #FBE5DE;
  --info: #5B8DEF;
  --info-soft: #E1ECFC;
  --purple: #9B6BFF;
  --purple-soft: #ECE2FF;

  --shadow-sm: 0 1px 2px rgba(11,11,10,0.05), 0 1px 3px rgba(11,11,10,0.04);
  --shadow-md: 0 4px 10px -2px rgba(11,11,10,0.10);
  --shadow-lg: 0 12px 28px -8px rgba(11,11,10,0.18);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;

  --navbar-h: 60px;
  --topbar-h: 54px;

  --font: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --accent: #D97757;
  --accent-2: #E08768;
  --accent-soft: rgba(217,119,87,0.18);
  --accent-text: #E8A98E;
  --on-accent: #ffffff;

  --bg: #1F1E1C;
  --bg-2: #262522;
  --surface: #2D2C29;
  --surface-2: #252421;
  --border: rgba(245,235,215,0.08);
  --border-2: rgba(245,235,215,0.16);
  --text: #F5EBD7;
  --text-2: #B8AC95;
  --text-3: #857B69;

  --success: #7BAE7C;
  --success-soft: rgba(123,174,124,0.18);
  --warn: #E0A05A;
  --warn-soft: rgba(224,160,90,0.18);
  --danger: #D4756F;
  --danger-soft: rgba(212,117,111,0.18);
  --info: #7B9DC9;
  --info-soft: rgba(123,157,201,0.18);
  --purple: #A99BD4;
  --purple-soft: rgba(169,155,212,0.18);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 10px rgba(0,0,0,0.45);
  --shadow-lg: 0 18px 40px -10px rgba(0,0,0,0.65);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body, #root { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
input, select, textarea, button { font-family: inherit; font-size: 16px; color: inherit; }
.mono, .money, .num { font-family: var(--font-mono); letter-spacing: -0.01em; }
a { color: var(--info); text-decoration: none; }

/* ── App shell ───────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-back {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text); border-radius: 10px;
}
.topbar-back:active { background: var(--bg-2); }
.topbar-action {
  border: none; background: transparent; color: var(--text-2);
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
.topbar-action:active { background: var(--bg-2); }

.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(var(--navbar-h) + env(safe-area-inset-bottom) + 16px);
}

/* ── Bottom navigation ───────────────────────────────────── */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--navbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px -6px rgba(0,0,0,0.18);
}
.nav-tab {
  flex: 1; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 600;
  position: relative; padding-top: 6px;
}
.nav-tab.active { color: var(--accent-text); }
[data-theme="dark"] .nav-tab.active { color: var(--accent); }
.nav-tab .nav-ico { width: 24px; height: 24px; }
.nav-tab .nav-badge {
  position: absolute; top: 2px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 9px;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}

/* ── Cards / list ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  margin-bottom: 12px;
}
.card.tap:active { background: var(--surface-2); }
.card-row { display: flex; align-items: center; gap: 12px; }
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3); margin: 18px 4px 8px;
}
.section-title:first-child { margin-top: 4px; }
.muted { color: var(--text-3); }
.subtle { color: var(--text-2); font-size: 13px; }
.empty {
  text-align: center; color: var(--text-3); padding: 48px 20px; font-size: 14px;
}
.empty .empty-emoji { font-size: 34px; display: block; margin-bottom: 10px; opacity: .7; }

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Badges / chips ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--bg-2); color: var(--text-2);
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  min-height: 46px; cursor: pointer; width: 100%;
}
.btn:active { background: var(--bg-2); }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: transparent;
  box-shadow: var(--shadow-sm); }
.btn-primary:active { background: var(--accent-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { min-height: 38px; padding: 8px 12px; font-size: 13px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { width: auto; flex: 1; }

/* ── Inputs ──────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; min-height: 48px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
}
.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23857b69' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }

.search-bar { position: relative; margin-bottom: 12px; }
.search-bar .input { padding-left: 42px; }
.search-bar .search-ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

/* ── Sheet (bottom modal) ────────────────────────────────── */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,15,12,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh;
  background: var(--surface); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: slideup .22s cubic-bezier(.2,.7,.3,1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-2);
  margin: 8px auto 4px; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 6px 16px 12px; flex: 0 0 auto; }
.sheet-head .sheet-title { font-weight: 700; font-size: 17px; flex: 1; }
.sheet-close { border: none; background: var(--bg-2); color: var(--text-2);
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; }
.sheet-body { overflow-y: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); display: flex; gap: 10px; flex: 0 0 auto; }
.sheet-foot > .btn { flex: 1; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Toast ───────────────────────────────────────────────── */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--navbar-h) + 18px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80; pointer-events: none; }
.toast {
  background: var(--text); color: var(--surface); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); max-width: 88%;
  animation: fade .15s ease;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--success); color: #fff; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap { min-height: 100%; display: flex; flex-direction: column; justify-content: center;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom)); }
.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; }
.login-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--accent);
  color: var(--accent-text); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 30px; box-shadow: var(--shadow-md); margin-bottom: 12px; }
.login-title { font-weight: 700; font-size: 20px; }
.login-sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* ── Misc ────────────────────────────────────────────────── */
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border-2); border-top-color: var(--accent-2);
  animation: spin .7s linear infinite; margin: 28px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: 10px; }
.hr { height: 1px; background: var(--border); margin: 14px 0; border: none; }
.list-line { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-line:last-child { border-bottom: none; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
