/* Веб-чат Теи. Свои цвета (не WhatsApp); цвета ресторанов — правило Павла 12.11.2026 (тг 2543):
   «Бьёрн» — зелёный (спокойный, свой), «Бардак» на Маросейке — синий, «Бардак на Пятницкой» — красный. */
:root {
  --bg: #f5f3ef;
  --panel: #ffffff;
  --panel-2: #efece6;
  --line: #e2ddd4;
  --text: #1d1b19;
  --muted: #77716a;
  --accent: #6a4380;
  --accent-ink: #ffffff;
  --accent-soft: #efe5f1;
  --mine: #ece2ef;
  --theirs: #ffffff;
  --warn: #a8571a;
  --warn-soft: #f8eadc;
  --bad: #b23b33;
  --good: #3b7a55;
  --bjorn: #3f7d58;
  --bjorn-soft: #e3efe7;
  --bardak-m: #2f68ad;
  --bardak-m-soft: #e1eaf6;
  --bardak-p: #bf3d36;
  --bardak-p-soft: #f6e2e0;
  --shadow: 0 1px 1px rgba(40, 30, 20, .06), 0 1px 3px rgba(40, 30, 20, .06);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131315;
    --panel: #1d1d20;
    --panel-2: #26262a;
    --line: #313136;
    --text: #ecebe8;
    --muted: #9c9891;
    --accent: #c69ad8;
    --accent-ink: #1a1320;
    --accent-soft: #33263a;
    --mine: #382a40;
    --theirs: #232327;
    --warn: #e0a06a;
    --warn-soft: #3a2a1d;
    --bad: #e7776e;
    --good: #7cbf96;
    --bjorn: #72b28c;
    --bjorn-soft: #1f3328;
    --bardak-m: #79a6e3;
    --bardak-m-soft: #1d2a3d;
    --bardak-p: #e9827a;
    --bardak-p-soft: #3d2221;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; }

/* ---------- вход ---------- */
.login { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 14px; }
.login img { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow); }
.login h1 { font-size: 24px; margin: 6px 0 0; font-weight: 650; letter-spacing: -.01em; }
.login p { margin: 0; color: var(--muted); text-align: center; max-width: 320px; }
.login form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }
.field { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.field:focus { border-color: var(--accent); }
.btn { padding: 13px 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; color: var(--accent); }
.err { color: var(--bad); min-height: 1.4em; font-size: 14px; text-align: center; }

/* ---------- шапка и вкладки ---------- */
header.top {
  display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 14px 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
header.top img { width: 34px; height: 34px; border-radius: 9px; }
header.top .who { flex: 1; min-width: 0; }
header.top .name { font-weight: 650; font-size: 17px; line-height: 1.15; }
header.top .status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .status.typing { color: var(--accent); }
header.top .status.off { color: var(--warn); }
.icon-btn { width: 40px; height: 40px; border-radius: 20px; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--panel-2); }
.icon-btn svg { width: 22px; height: 22px; }

nav.tabs { display: flex; gap: 6px; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  flex: 0 0 auto; border: 0; background: var(--panel-2); color: var(--text); padding: 7px 12px; border-radius: 999px;
  font-size: 14px; display: flex; align-items: center; gap: 6px;
}
nav.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
nav.tabs button[aria-selected="true"] .count { background: var(--accent-ink); color: var(--accent); }

/* ---------- лента ---------- */
.feed { flex: 1; overflow-y: auto; padding: 12px 10px 6px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel-2); padding: 3px 10px; border-radius: 999px; margin: 8px 0 4px; }
.empty { margin: auto; color: var(--muted); text-align: center; padding: 30px 20px; max-width: 360px; }
.more { align-self: center; border: 0; background: transparent; color: var(--accent); padding: 6px 12px; font-size: 14px; }

.msg { max-width: min(86%, 640px); display: flex; flex-direction: column; position: relative; transition: transform .15s; }
.msg.in { align-self: flex-end; }
.msg.out { align-self: flex-start; }
.bubble { padding: 8px 12px 6px; border-radius: var(--radius); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.msg.in .bubble { background: var(--mine); border-bottom-right-radius: 6px; }
.msg.out .bubble { background: var(--theirs); border-bottom-left-radius: 6px; }
.msg.flash .bubble { outline: 2px solid var(--accent); }
.msg.ask .bubble { border-left: 3px solid var(--warn); }
.msg.important .bubble { border-left: 3px solid var(--accent); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-bottom: 4px; }
.badge.ask { background: var(--warn-soft); color: var(--warn); }
.badge.important { background: var(--accent-soft); color: var(--accent); }
.badge.done { background: var(--panel-2); color: var(--muted); }

.quote { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); padding: 4px 8px; border-radius: 6px; margin-bottom: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.quote .qt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.quote b { color: var(--accent); font-weight: 600; display: block; font-size: 13px; }

.text p { margin: 0 0 6px; }
.text p:last-child { margin-bottom: 0; }
.text h3, .text h4 { margin: 4px 0 6px; font-size: 16px; }
.text ul, .text ol { margin: 2px 0 6px; padding-left: 22px; }
.text li { margin: 2px 0; }
.text code { font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 1px 4px; border-radius: 4px; }
.text pre { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 8px; border-radius: 8px; overflow-x: auto; margin: 4px 0 6px; white-space: pre; }
.text blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.text a { color: var(--accent); }
.collapsible { position: relative; max-height: 15.5em; overflow: hidden; }
.collapsible::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3em; background: linear-gradient(transparent, var(--theirs)); }
.msg.in .collapsible::after { background: linear-gradient(transparent, var(--mine)); }
.toggle { border: 0; background: transparent; color: var(--accent); padding: 4px 0 0; font-size: 14px; font-weight: 600; }

.meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.meta .qid { margin-right: auto; font-weight: 600; }
.meta .tick.delivered, .meta .tick.answered { color: var(--accent); }
.react { position: absolute; bottom: -10px; right: 8px; background: var(--panel); border-radius: 12px; padding: 0 5px; font-size: 15px; box-shadow: var(--shadow); }
.msg.out .react { right: auto; left: 8px; }

.options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.options button { border: 1px solid var(--accent); background: transparent; color: var(--accent); padding: 8px 12px; border-radius: 12px; font-size: 15px; text-align: left; }
.options button:active { background: var(--accent-soft); }
.options button.own { border-style: dashed; }
.options button.chosen { background: var(--accent); color: var(--accent-ink); }
.options.closed button:not(.chosen) { opacity: .45; }

.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.files img { max-width: 240px; max-height: 240px; border-radius: 10px; display: block; cursor: zoom-in; background: var(--panel-2); }
.chip-file { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); color: var(--text); text-decoration: none; font-size: 14px; }

/* ---------- блоки ---------- */
.block { margin-top: 8px; }
.block .btitle { font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 4px; text-transform: none; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
table.tbl th, table.tbl td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.tbl th { background: var(--panel-2); font-weight: 600; font-size: 13px; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl .r { text-align: right; }
table.tbl .c { text-align: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.kpi { background: var(--panel-2); border-radius: 12px; padding: 8px 10px; border-top: 3px solid transparent; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .d { font-size: 12.5px; font-weight: 600; }
.kpi .d.good { color: var(--good); } .kpi .d.bad { color: var(--bad); } .kpi .d.neutral { color: var(--muted); }
.diff { display: flex; flex-direction: column; gap: 4px; }
.diff .row { display: grid; grid-template-columns: minmax(80px, 1fr) auto; gap: 2px 10px; padding: 6px 9px; background: var(--panel-2); border-radius: 10px; font-size: 14px; }
.diff .row .lab { font-weight: 600; }
.diff .row .ch { font-variant-numeric: tabular-nums; text-align: right; }
.diff .old { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff .arrow { color: var(--muted); padding: 0 4px; }
.diff .new { font-weight: 650; }

/* метки ресторанов */
.place { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px 1px 6px; border-radius: 999px; white-space: nowrap; vertical-align: 1px; max-width: 100%; }
.kpi .place { white-space: normal; line-height: 1.25; } /* «Бардак на Пятницкой» в узкой карточке — в две строки, а не за край */
.place::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.place.bjorn { color: var(--bjorn); background: var(--bjorn-soft); }
.place.bardak-m { color: var(--bardak-m); background: var(--bardak-m-soft); }
.place.bardak-p { color: var(--bardak-p); background: var(--bardak-p-soft); }
.place.bardak { color: var(--text); background: var(--panel-2); }
.place.bardak::before { background: linear-gradient(90deg, var(--bardak-m) 50%, var(--bardak-p) 50%); }
.kpi.bjorn { border-top-color: var(--bjorn); } .kpi.bardak-m { border-top-color: var(--bardak-m); } .kpi.bardak-p { border-top-color: var(--bardak-p); }
.diff .row.bjorn { box-shadow: inset 3px 0 var(--bjorn); } .diff .row.bardak-m { box-shadow: inset 3px 0 var(--bardak-m); } .diff .row.bardak-p { box-shadow: inset 3px 0 var(--bardak-p); }
tr.bjorn td:first-child { box-shadow: inset 3px 0 var(--bjorn); } tr.bardak-m td:first-child { box-shadow: inset 3px 0 var(--bardak-m); } tr.bardak-p td:first-child { box-shadow: inset 3px 0 var(--bardak-p); }

.typing-row { align-self: flex-start; color: var(--muted); font-size: 14px; padding: 4px 6px; display: flex; gap: 6px; align-items: center; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- поле ввода ---------- */
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 8px calc(8px + var(--safe-b)); }
.replying { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px 8px; }
.replying .q { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replying .q b { color: var(--accent); font-weight: 600; margin-right: 4px; }
.attached { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 4px 8px; }
.attached span { font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 4px 8px; display: inline-flex; gap: 6px; align-items: center; }
.attached button { border: 0; background: transparent; color: var(--muted); padding: 0; }
.row-in { display: flex; align-items: flex-end; gap: 6px; }
.row-in textarea {
  flex: 1; min-height: 42px; max-height: 40vh; resize: none; border-radius: 21px; border: 1px solid var(--line);
  background: var(--bg); padding: 10px 14px; outline: none; line-height: 1.35;
}
.row-in textarea:focus { border-color: var(--accent); }
.row-in textarea.live { border-color: var(--bad); }
.round { width: 42px; height: 42px; border-radius: 21px; border: 0; display: grid; place-items: center; flex: 0 0 auto; background: transparent; color: var(--muted); }
.round svg { width: 23px; height: 23px; }
.round.send { background: var(--accent); color: var(--accent-ink); }
.round.rec { background: var(--bad); color: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.recbar { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--bad); padding: 0 8px 6px; }
.recbar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.recbar .hint { color: var(--muted); flex: 1; }
.recbar button { border: 0; background: transparent; color: var(--muted); font-size: 13px; }

/* ---------- поручения ---------- */
.tasks { flex: 1; overflow-y: auto; padding: 12px 10px calc(16px + var(--safe-b)); }
.sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.sum button { border: 0; border-radius: 12px; padding: 8px 10px; background: var(--panel); box-shadow: var(--shadow); text-align: left; }
.sum button[aria-pressed="true"] { outline: 2px solid var(--accent); }
.sum .n { font-size: 22px; font-weight: 650; display: block; font-variant-numeric: tabular-nums; }
.sum .l { font-size: 12.5px; color: var(--muted); }
.sum .overdue .n { color: var(--bad); }
.group { background: var(--panel); border-radius: 14px; margin-bottom: 8px; box-shadow: var(--shadow); overflow: hidden; }
.group > button { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 8px; padding: 11px 12px; text-align: left; }
.group > button .gname { flex: 1; font-weight: 650; }
.group > button .gc { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group > button .gc b { color: var(--bad); font-weight: 650; }
.task { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 9px 12px; border-top: 1px solid var(--line); }
.task .tt { font-size: 15px; }
.task .tt .num { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.task .tm { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.st { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.st.overdue { background: var(--bardak-p-soft); color: var(--bad); }
.st.open { background: var(--panel-2); color: var(--text); }
.st.done { background: var(--bjorn-soft); color: var(--good); }
.task .done-btn { grid-column: 2; grid-row: 1 / span 2; align-self: center; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 6px 10px; font-size: 13px; color: var(--text); }
.task .done-btn.sure { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.task .done-btn[disabled] { opacity: .5; }

/* ---------- лист настроек и картинки ---------- */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet .card { background: var(--panel); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.sheet .card h2 { margin: 0 0 4px; font-size: 17px; }
.sheet .card p { margin: 0; color: var(--muted); font-size: 14px; }
.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); display: grid; place-items: center; z-index: 11; }
.viewer img { max-width: 100vw; max-height: 100dvh; }
.banner { margin: 8px 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.banner span { flex: 1; }
.banner button { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 6px 10px; font-weight: 600; }
.banner button.x { background: transparent; color: var(--muted); padding: 6px; }

@media (min-width: 700px) {
  .feed { padding: 16px 18px 8px; }
  .msg { max-width: min(72%, 640px); }
}
