/* Мини-приложение WorkFoun. Цвета — из темы Telegram (themeParams даёт
   переменные --tg-theme-*), запасные значения — для локального просмотра.
   Смысловые цвета (топ, хорошо, внимание, плохо) у Telegram своих нет:
   два набора по схеме цвета клиента (атрибут data-scheme, tg.js). */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f0f2f5);
  --text: var(--tg-theme-text-color, #0f1419);
  --hint: var(--tg-theme-hint-color, #7b8591);
  /* Подсказки темы Telegram на светлом фоне бледнее 3:1 — смесь с цветом
     текста; клиент без color-mix берёт цвет текста. */
  --hint: color-mix(in srgb, var(--tg-theme-hint-color, #7b8591) 72%, var(--tg-theme-text-color, #0f1419));
  --link: var(--tg-theme-link-color, #2f7fd8);
  --btn: var(--tg-theme-button-color, #3390ec);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --sep: var(--tg-theme-section-separator-color, #e2e6ea);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --danger: var(--tg-theme-destructive-text-color, #c83d33);

  --top: #9a6a05;
  --top-bg: #fff3d3;
  --good: #1c7a46;
  --good-bg: #e1f4e8;
  --warn: #9d5a0c;
  --warn-bg: #fdefd9;
  --bad: #b8352c;
  --bad-bg: #fde4e1;
  --chip: rgba(120, 134, 150, 0.16);
  --shadow: 0 1px 2px rgba(15, 20, 25, 0.06), 0 2px 10px rgba(15, 20, 25, 0.05);

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --gap: 12px;
  --side: 16px;
  --tabbar-h: 60px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-scheme="dark"] {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #0e1621);
  --text: var(--tg-theme-text-color, #f3f6f8);
  --hint: color-mix(in srgb, var(--tg-theme-hint-color, #7f91a4) 80%, var(--tg-theme-text-color, #f3f6f8));
  --link: var(--tg-theme-link-color, #6ab3f3);
  --btn: var(--tg-theme-button-color, #5288c1);
  --sep: var(--tg-theme-section-separator-color, #22303c);
  --top: #f0b43c;
  --top-bg: #3a2d10;
  --good: #52c585;
  --good-bg: #16342a;
  --warn: #eaa24a;
  --warn-bg: #3a2914;
  --bad: #f0706a;
  --bad-bg: #3f1d1b;
  --chip: rgba(150, 170, 190, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body { min-height: 100vh; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 680px; margin: 0 auto; min-height: 100vh; }
.app.with-tabs .view { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px); }
.view { padding-bottom: 96px; }

.screen { padding: 12px var(--side) 20px; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.screen.center { text-align: center; padding-top: 48px; }
.loading { padding: 32px var(--side); color: var(--hint); text-align: center; }

.head h1 { margin: 4px 0 0; font-size: 22px; line-height: 1.2; font-weight: 700; }
.head .sub { margin: 2px 0 0; color: var(--hint); font-size: 13px; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 17px; margin: 0 0 4px; }
.hint { color: var(--hint); font-size: 13px; margin: 0; }
.note { color: var(--hint); font-size: 13px; margin: 0; overflow-wrap: anywhere; }
.note.bad { color: var(--bad); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
small { color: var(--hint); font-size: 12px; }
b { font-weight: 600; }

/* Блоки и списки */
.blk { background: var(--card); border-radius: var(--r-lg); padding: 12px 14px; display: flex; flex-direction: column;
  gap: 8px; box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.blk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.blk-head .aside { color: var(--hint); font-size: 12px; text-align: right; }
.group-title { color: var(--head); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; margin: 8px 4px -4px; }

.list { background: var(--card); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: none;
  text-align: left; border-bottom: 1px solid var(--sep); min-width: 0; }
.row:last-child { border-bottom: 0; }
.row .grow, .grow { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.row small { display: block; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
  stroke-linejoin: round; flex: none; }
.ic.lead { color: var(--accent); }
.ic.tail { color: var(--hint); width: 18px; height: 18px; }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.items li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--sep); }
.items li:last-child { border-bottom: 0; }

.kv { display: grid; grid-template-columns: minmax(84px, 34%) 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--hint); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.banner { border-radius: var(--r-md); padding: 10px 12px; font-size: 14px; overflow-wrap: anywhere; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.good { background: var(--good-bg); color: var(--good); }
.banner.top { background: var(--top-bg); color: var(--text); }

/* Кнопки */
.btn { border: 0; border-radius: var(--r-md); padding: 10px 14px; font-weight: 600; font-size: 14px;
  background: var(--chip); color: var(--text); min-height: 40px; }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.secondary { background: var(--chip); color: var(--accent); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.ghost { background: none; color: var(--accent); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.row-btns .btn { flex: 1 1 auto; }

.mainbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px var(--side) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg); border-top: 1px solid var(--sep); z-index: 20; max-width: 680px; margin: 0 auto; }

/* Поля */
.field { width: 100%; border: 1px solid var(--sep); border-radius: var(--r-md); background: var(--bg); padding: 10px 12px;
  min-width: 0; }
textarea.field { resize: vertical; min-height: 120px; line-height: 1.45; }
.field:focus { outline: 2px solid var(--btn); outline-offset: -1px; }
.field-error { color: var(--bad); font-size: 13px; margin: 0; overflow-wrap: anywhere; }
.lbl { font-size: 13px; color: var(--hint); }
.spec { display: flex; flex-direction: column; gap: 6px; }
.spec-row { display: flex; gap: 8px; }
.spec-row .field { flex: 1 1 auto; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.copy { background: var(--bg2); border-radius: var(--r-sm); padding: 6px 8px; margin-top: 4px; user-select: all;
  overflow-wrap: anywhere; }

/* Сегменты, разделы, чипы */
.seg { display: flex; background: var(--chip); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1 1 0; border: 0; background: none; border-radius: 8px; padding: 7px 8px; font-size: 13px; font-weight: 600;
  color: var(--hint); min-width: 0; }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.seg.icons button { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 6px 10px; }

.tiers { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--side));
  padding: 0 var(--side); }
.tiers::-webkit-scrollbar { display: none; }
.tier { flex: none; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--card); color: var(--text);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap; }
.tier .n { color: var(--hint); font-weight: 500; margin-left: 4px; }
.tier[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.tier[aria-pressed="true"] .n { color: var(--bg); opacity: 0.75; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border-radius: var(--r-sm);
  padding: 3px 8px; font-size: 12px; max-width: 100%; overflow-wrap: anywhere; }
.chip.w { background: var(--warn-bg); color: var(--warn); }
.chip.b { background: var(--bad-bg); color: var(--bad); }
.chip.g { background: var(--good-bg); color: var(--good); }
.chip.l { background: none; border: 1px solid var(--sep); }
.chip.t { background: var(--top-bg); color: var(--text); }

.toolbar { display: flex; align-items: center; gap: 8px; }
.toolbar .grow { flex: 1 1 auto; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text); position: relative; flex: none; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--btn); }

/* Окна календаря */
.days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.days li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--sep); align-items: baseline; }
.days li:last-child { border-bottom: 0; }
.days b { flex: 0 0 70px; }
.spans { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.span { display: flex; flex-direction: column; }

/* Вакансии: строки списка, карточки ленты и свайпа */
.vrow { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px;
  border: 0; border-bottom: 1px solid var(--sep); background: none; width: 100%; text-align: left; min-width: 0; }
.vrow:last-child { border-bottom: 0; }
.vrow .mid { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vrow .mid b { overflow-wrap: anywhere; }
.vrow .right { text-align: right; font-size: 13px; display: flex; flex-direction: column; gap: 2px; max-width: 110px; }
.vrow.picked { background: var(--good-bg); }

.ring { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; position: relative; flex: none;
  background: conic-gradient(var(--rc, var(--hint)) calc(var(--v, 0) * 1%), var(--sep) 0); }
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--card); }
.ring span { position: relative; }
.ring.good { --rc: var(--good); }
.ring.mid { --rc: var(--warn); }

.card { background: var(--card); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.card .src { display: flex; align-items: center; gap: 8px; color: var(--hint); font-size: 12px; }
.card .src .grow { flex: 1 1 auto; }
.card h4 { margin: 0; font-size: 17px; line-height: 1.25; }
.card .co { color: var(--hint); font-size: 14px; }
.money { font-size: 18px; font-weight: 700; }
.money small { font-weight: 400; margin-left: 4px; }
.topline { background: var(--top-bg); border-radius: 10px; padding: 7px 10px; font-size: 13px; }
.markline { border-radius: 10px; padding: 7px 10px; font-size: 13px; background: var(--chip); }
.markline.bad { background: var(--bad-bg); color: var(--bad); }
.markline.warn { background: var(--warn-bg); color: var(--warn); }
.markline.good { background: var(--good-bg); color: var(--good); }
.actions { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }

.bars { display: flex; gap: 3px; height: 6px; }
.bar { background: var(--sep); border-radius: 3px; position: relative; overflow: hidden; flex: var(--w, 1) 1 0; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--f, 0) * 100%); background: var(--good); }
.bar.part i { background: var(--warn); }
.parts { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }

.stack { position: relative; height: 470px; touch-action: none; user-select: none; }
.stack .card { position: absolute; inset: 0; overflow: hidden; transition: transform 0.25s ease, opacity 0.25s ease; }
.stack .card.dragging { transition: none; cursor: grabbing; }
.stack .card.back1 { transform: translateY(10px) scale(0.96); opacity: 0.9; }
.stack .card.back2 { transform: translateY(20px) scale(0.92); opacity: 0.7; }
.stamp { position: absolute; top: 18px; padding: 4px 10px; border: 3px solid; border-radius: 8px; font-weight: 800;
  font-size: 15px; opacity: 0; pointer-events: none; background: var(--card); }
.stamp.yes { left: 16px; color: var(--good); }
.stamp.no { right: 16px; color: var(--bad); }
.stamp.fav { left: 50%; transform: translateX(-50%); color: var(--top); }
.stamp.later { left: 50%; top: auto; bottom: 18px; transform: translateX(-50%); color: var(--accent); }
.swipe-btns { display: flex; justify-content: center; align-items: center; gap: 14px; }
.round { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center; }
.round.small { width: 44px; height: 44px; }
.round.yes { color: var(--good); }
.round.no { color: var(--bad); }
.round.fav { color: var(--top); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; color: var(--hint); font-size: 12px; }

.plain { border: 0; background: none; padding: 0; margin: 0; width: 100%; text-align: left; color: inherit;
  display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.swipe { display: flex; flex-direction: column; gap: 12px; }
.hint.center { text-align: center; }
.opt.toggle { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.opt.toggle::after { content: ""; flex: none; width: 38px; height: 22px; border-radius: 11px;
  background: radial-gradient(circle at 11px 11px, #ffffff 8px, transparent 9px), var(--sep); }
.opt.toggle[aria-pressed="true"]::after {
  background: radial-gradient(circle at 27px 11px, #ffffff 8px, transparent 9px), var(--btn); }

.pickbar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; width: 100%;
  background: var(--good); color: #ffffff; border-radius: var(--r-md); padding: 12px 14px; font-weight: 600;
  box-shadow: var(--shadow); }

/* Письмо по предложениям */
.letter { line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.para { margin: 0 0 10px; }
.sent { border-radius: 4px; padding: 1px 2px; cursor: pointer; }
.sent.f { background: var(--good-bg); border-bottom: 2px solid var(--good); }
.sent.v { background: var(--chip); border-bottom: 1px dashed var(--hint); }
.sent.sel { outline: 2px solid var(--btn); }
.factpop { background: var(--bg2); border-radius: var(--r-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.issues { margin: 0; padding-left: 18px; }

/* Шторка и сообщение */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; display: flex; align-items: flex-end;
  justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 680px; border-radius: 18px 18px 0 0;
  padding: 8px var(--side) calc(18px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px;
  max-height: 85vh; overflow-y: auto; }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--sep); margin: 0 auto 6px; }
.opt { border: 0; border-radius: var(--r-md); background: var(--bg2); padding: 12px 14px; text-align: left; font-size: 15px;
  display: flex; flex-direction: column; gap: 2px; }
.opt.primary { background: var(--btn); color: var(--btn-text); text-align: center; font-weight: 600; }
.opt.danger { color: var(--bad); }
.opt.ghost { background: none; text-align: center; color: var(--accent); }

.toast { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px); z-index: 50;
  background: rgba(20, 28, 36, 0.94); color: #ffffff; border-radius: var(--r-md); padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); font-size: 14px; }
.toast-undo { border: 0; background: none; color: #8ec3ff; font-weight: 700; padding: 0; }

/* Вкладки */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg); border-top: 1px solid var(--sep); padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  max-width: 680px; margin: 0 auto; }
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--hint);
  font-size: 11px; padding: 4px 0; min-width: 0; }
.tab[aria-current="page"] { color: var(--btn); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: var(--r-md); padding: 10px; box-shadow: var(--shadow); min-width: 0;
  border: 0; text-align: left; color: inherit; }
details summary { color: var(--accent); font-size: 13px; cursor: pointer; }
.stat b { display: block; font-size: 20px; }
.stat small { display: block; }

.todo { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: none;
  text-align: left; border-bottom: 1px solid var(--sep); min-width: 0; }
.todo:last-child { border-bottom: 0; }
.todo .mark { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--chip); flex: none; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .stack .card { transition: none; }
}
