/* Radar v2 -- WSG palette: Midnight Navy #172A34, Naples #FAD564,
   Sand #D6C8AE, Warm White #F7F6F2, Charcoal #2D3032.
   Red/green/amber are status colors only. */

:root, [data-theme="light"] {
  --navy: #172A34;
  --accent: #FAD564;
  --accent-hover: #F3CA50;
  --sand: #D6C8AE;
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --raised: #EFEADF;
  --line: #D6C8AE;
  --line-soft: #E7E0D2;
  --text: #2D3032;
  --muted: #5B666C;
  --faint: #7F888D;
  --heading: #172A34;
  --link: #172A34;
  --good: #24694B;   --good-bg: #E3F0E7;
  --bad: #A43725;    --bad-bg: #F8E4DF;
  --warn: #7A5A0A;   --warn-bg: #FFF4D2;
  --info-bg: #EEE8DD;
  --side-bg: #172A34;
  --side-text: #D6C8AE;
  --side-hover: #203640;
  --shadow: 0 1px 2px rgba(23, 42, 52, .06), 0 4px 14px rgba(23, 42, 52, .05);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #10202A;
  --surface: #172A34;
  --raised: #203640;
  --line: #34505C;
  --line-soft: #26404B;
  --text: #F7F6F2;
  --muted: #B8C8CE;
  --faint: #8FA3AB;
  --heading: #F7F6F2;
  --link: #FAD564;
  --good: #A8DEC3;   --good-bg: rgba(168, 222, 195, .12);
  --bad: #FFB7A7;    --bad-bg: rgba(255, 183, 167, .12);
  --warn: #FAD564;   --warn-bg: rgba(250, 213, 100, .12);
  --info-bg: #203640;
  --side-bg: #0B1820;
  --side-text: #D6C8AE;
  --side-hover: #172A34;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 'Manrope', 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1, h2, h3 { color: var(--heading); margin: 0; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.4px; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--navy);
  display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none;
}
.brand-name { color: #F7F6F2; font-weight: 800; font-size: 16px; }
.brand-sub { font-size: 11px; opacity: .75; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--side-text);
  cursor: pointer; font-weight: 600; font-size: 13.5px;
}
.nav-item:hover { background: var(--side-hover); color: #F7F6F2; }
.nav-item.active { background: var(--accent); color: var(--navy); }
.nav-item svg { flex: none; }
.profile { border-top: 1px solid rgba(214, 200, 174, .2); padding: 12px 8px 0; margin-top: 10px; }
.profile-name { color: #F7F6F2; font-weight: 700; font-size: 13px; }
.profile-scope { font-size: 11.5px; opacity: .8; margin-bottom: 8px; }
.profile-actions { display: flex; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid rgba(214, 200, 174, .25); background: transparent; color: var(--side-text); cursor: pointer;
}
.icon-btn:hover { background: var(--side-hover); color: #F7F6F2; }
.menu-btn { display: none; margin-left: auto; }

.main { padding: 28px 36px 64px; max-width: 1240px; width: 100%; outline: none; }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.page-sub { color: var(--muted); margin-top: 6px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 26px 0 10px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--raised); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--navy); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.link { border-color: transparent; background: transparent; color: var(--link); padding-left: 0; padding-right: 0; }
.btn.link:hover { text-decoration: underline; background: transparent; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
.tab {
  border: 0; background: transparent; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--heading); border-bottom-color: var(--accent); }
[data-theme="dark"] .tab.active { color: var(--accent); }

/* ---------- forms / toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field.grow { flex: 1; min-width: 200px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=date], select, textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--text); font-size: 13.5px; font-weight: 500; min-height: 36px;
}
textarea { width: 100%; min-height: 80px; resize: vertical; }
input[type=checkbox] { accent-color: var(--navy); width: 15px; height: 15px; }
[data-theme="dark"] input[type=checkbox] { accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h2 { margin-bottom: 10px; }
.notice { background: var(--info-bg); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.notice.warn { background: var(--warn-bg); }
.notice.bad { background: var(--bad-bg); border-left-color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 800; color: var(--heading); letter-spacing: -.5px; line-height: 1.25; margin: 2px 0; }
.stat .hint { font-size: 11.5px; color: var(--faint); }
button.stat { text-align: left; cursor: pointer; font: inherit; color: inherit; width: 100%; }
button.stat:hover { border-color: var(--accent); }

/* ---------- list items ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 16px;
  cursor: pointer; box-shadow: var(--shadow);
}
.item.no-check { grid-template-columns: minmax(0, 1fr) auto; }
.item:hover { border-color: var(--sand); }
[data-theme="dark"] .item:hover { border-color: var(--line); background: var(--raised); }
.item-title { font-weight: 700; color: var(--heading); font-size: 14.5px; line-height: 1.35; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item-brief { font-size: 13px; color: var(--text); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.item-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 90px; }
.scores { display: flex; gap: 10px; font-size: 12px; color: var(--muted); }
.scores b { color: var(--heading); font-size: 15px; }
.count-line { font-size: 12.5px; color: var(--muted); margin: 4px 0 10px; }
.more { text-align: center; margin-top: 14px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700; background: var(--raised); color: var(--text); white-space: nowrap;
}
.badge.stage-new { background: var(--info-bg); }
.badge.stage-reviewed { background: var(--warn-bg); color: var(--text); }
.badge.stage-contacted, .badge.stage-qualified { background: #E1ECF1; color: #172A34; }
[data-theme="dark"] .badge.stage-contacted, [data-theme="dark"] .badge.stage-qualified { background: #2A4A58; color: #F7F6F2; }
.badge.stage-won, .badge.good { background: var(--good-bg); color: var(--good); }
.badge.stage-lost, .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.accent { background: var(--accent); color: var(--navy); }
.badge.outline { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.badge.tech { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-weight: 600; font-size: 10.5px; }

/* ---------- states ---------- */
.state { text-align: center; padding: 40px 16px; color: var(--muted); }
.state .big { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.state.small { padding: 16px; text-align: left; }
.skeleton { display: flex; flex-direction: column; gap: 8px; }
.skeleton div { height: 74px; border-radius: 12px; background: linear-gradient(90deg, var(--raised), var(--line-soft), var(--raised)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- key/value ---------- */
dl.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--muted); font-weight: 600; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- lead card ---------- */
.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.brief { background: var(--warn-bg); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; font-size: 14px; line-height: 1.6; margin-bottom: 14px; }
.block { margin-bottom: 18px; }
.block h3 { margin-bottom: 8px; }
.event { padding: 10px 0; border-top: 1px solid var(--line-soft); }
.event:first-child { border-top: 0; }
.event-meta { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.stage-track { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0 14px; }
.stage-step { flex: 1; min-width: 92px; padding: 7px 8px; border-radius: 8px; background: var(--raised); font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; }
.stage-step.done { background: var(--line-soft); color: var(--text); }
.stage-step.current { background: var(--navy); color: #F7F6F2; }
[data-theme="dark"] .stage-step.current { background: var(--accent); color: var(--navy); }
.stage-step.lost { background: var(--bad-bg); color: var(--bad); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 10px; }
.inline-form .field { flex: 1; min-width: 200px; }
.factor { display: grid; grid-template-columns: 160px minmax(0, 1fr) 50px; gap: 10px; align-items: center; font-size: 13px; margin: 6px 0; }
.bar-track { height: 8px; background: var(--raised); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
[data-theme="light"] .bar-fill { background: var(--navy); }
details summary { cursor: pointer; font-weight: 700; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: var(--raised); border-radius: 12px; padding: 10px; min-height: 160px; }
.lane-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 12.5px; margin: 2px 4px 10px; color: var(--heading); }
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.card:hover { border-color: var(--sand); }
.card .t { font-weight: 700; font-size: 13px; color: var(--heading); line-height: 1.35; }
.card .m { font-size: 11.5px; color: var(--muted); margin: 4px 0 8px; }
.card select { width: 100%; min-height: 30px; font-size: 12px; padding: 4px 6px; }

/* ---------- map ---------- */
.map { height: 520px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-soft); }
.leaflet-container { font: inherit; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--navy); color: #F7F6F2; padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: 13px; max-width: 360px; border-left: 3px solid var(--accent); }
.toast.bad { border-left-color: #FFB7A7; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 50; padding: 10px 12px; }
  .brand { padding: 0; }
  .menu-btn { display: inline-grid; }
  .nav, .profile { display: none; }
  .sidebar.open .nav { display: flex; margin-top: 10px; max-height: 70vh; }
  .sidebar.open .profile { display: block; }
  .main { padding: 20px 16px 56px; }
  h1 { font-size: 22px; }
  .grid2 { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
  .factor { grid-template-columns: 1fr 50px; }
  .factor .bar-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 560px) {
  .item { grid-template-columns: auto minmax(0, 1fr); }
  .item.no-check { grid-template-columns: minmax(0, 1fr); }
  .item-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; }
  .toolbar .field, .toolbar .field.grow { min-width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 22px; }
}

/* TRAINING: иллюстрации уроков -- аннотации рамкой по координатам (в
   процентах от размера картинки), не завязаны на CSS-селекторы живого
   интерфейса, поэтому замена скриншота не требует правки разметки. */
.lesson-image-wrap { position: relative; display: inline-block; max-width: 100%; margin-top: 10px; cursor: zoom-in; }
.lesson-image-wrap img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line-soft); display: block; }
.lesson-region { position: absolute; border: 2px solid var(--accent); border-radius: 4px; box-shadow: 0 0 0 2px rgba(0,0,0,.08); pointer-events: none; }
.lesson-image-missing {
  margin-top: 10px; padding: 32px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 10px; background: var(--line-soft);
}
.img-lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.img-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* AS_MANAGER_VIEW: drag-and-drop on the projects board */
.board .card[draggable="true"] { cursor: grab; }
.board .card.dragging { opacity: .4; }
.board .lane.drop { outline: 2px dashed var(--heading); outline-offset: -2px; }
