/* Кабинет Replikai (задача 36): сначала телефон, затем компьютер. Без внешних шрифтов — системные. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #1b1d24;
  --muted: #646a7a;
  --line: #e2e4ea;
  --accent: #3b4fd8;
  --accent-text: #ffffff;
  --alex: #e6e9ff;
  --agent: #eef0f3;
  --client: #ffffff;
  --red: #d93a3a;
  --amber: #a86400;
  --chip: #eceef3;
  --grade-a: #1f8a4c;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #1a1d24;
    --text: #e9ebf1;
    --muted: #9aa1b2;
    --line: #2b2f39;
    --accent: #7c8cff;
    --accent-text: #0e1020;
    --alex: #252b52;
    --agent: #22262f;
    --client: #1a1d24;
    --red: #ff6b6b;
    --amber: #f0b45a;
    --chip: #262a33;
    --grade-a: #4fd18b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar-title { flex: 1; margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-back { border: 0; background: none; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; color: var(--accent); }
.bar-btn { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 6px 10px; font-size: 14px; color: var(--muted); }

.view { max-width: 820px; margin: 0 auto; padding: 0 0 24px; }

/* Вход */
.login { margin: 32px 16px; padding: 20px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; }
.login h2 { margin: 0 0 4px; font-size: 20px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.login input[type=password], .login input[type=text] {
  font-size: 17px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.login .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.primary { border: 0; border-radius: 10px; padding: 12px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary:disabled { opacity: .6; }
.error { color: var(--red); margin: 0; font-size: 14px; }

/* Вкладки и список */
.tabs { position: sticky; top: calc(49px + env(safe-area-inset-top)); z-index: 4; display: flex; gap: 4px; padding: 8px 16px;
  background: var(--bg); overflow-x: auto; }
.tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px;
  font-size: 15px; }
.tabs button[aria-selected=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.count:empty { display: none; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; font-size: 13px;
  background: var(--chip); color: var(--text); text-align: center; }
.tabs button[aria-selected=true] .count { background: rgba(255, 255, 255, .25); color: inherit; }

.rows { list-style: none; margin: 0; padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.row a { display: block; padding: 12px 14px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  color: inherit; text-decoration: none; border: 1px solid transparent; }
.row a:focus-visible { outline: 2px solid var(--accent); }
.row.unread a { border-color: var(--accent); }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-head { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex: 0 0 auto; align-self: center; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 13px; color: var(--muted); align-items: center; }
.row-text { margin-top: 6px; font-size: 15px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.row-text .who { color: var(--muted); }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reason { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.reason.hot { color: var(--red); }
.grade { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; text-align: center; font-weight: 700;
  font-size: 13px; background: var(--chip); color: var(--text); }
.grade.g-A { background: var(--grade-a); color: #fff; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--chip); font-size: 13px; color: var(--muted); }
.chip.paid { color: var(--amber); }
.chip.alex { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.more { display: block; margin: 12px auto; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 16px; }

/* Диалог */
.card { margin: 12px 16px 0; padding: 12px 14px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-rows { margin: 8px 0 0; display: grid; grid-template-columns: 1fr; gap: 6px; }
.card-rows div { display: grid; grid-template-columns: 1fr; }
.card-rows dt { font-size: 12px; color: var(--muted); }
.card-rows dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.card.short .card-rows div.extra { display: none; }
.link { border: 0; background: none; color: var(--accent); padding: 6px 0 0; font-size: 14px; }
.state { margin: 10px 16px 0; font-size: 14px; color: var(--muted); }
.state.alex { color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 16px 0; }
.actions button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.actions button[aria-pressed=true] { background: var(--chip); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.actions #d-release { border-color: var(--accent); color: var(--accent); }
.contract { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 16px 0; font-size: 14px; }
.contract input { width: 8.5em; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.contract button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; }
.note { color: var(--muted); font-size: 13px; margin: 0; }
.tz { margin: 14px 16px 0; font-size: 12px; color: var(--muted); text-align: center; }

.feed { list-style: none; margin: 8px 0 0; padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px;
  border: 1px solid var(--line); }
.msg .meta { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.client { align-self: flex-start; background: var(--client); border-bottom-left-radius: 4px; }
.msg.agent { align-self: flex-end; background: var(--agent); border-bottom-right-radius: 4px; }
.msg.owner { align-self: flex-end; background: var(--alex); border-color: transparent; border-bottom-right-radius: 4px; }
.demo-title { margin: 18px 16px 0; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; color: var(--muted); }

.reply { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end;
  margin-top: 16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface);
  border-top: 1px solid var(--line); }
.reply textarea { width: 100%; resize: vertical; min-height: 44px; max-height: 40vh; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); font-size: 16px; }
.reply .note { grid-column: 1 / -1; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 14px; }

@media (min-width: 760px) {
  .view { padding-top: 8px; }
  .tabs { top: 49px; }
  .card-rows { grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .card.short .card-rows div.extra { display: grid; }
  #d-card-more { display: none; }
  .msg { max-width: 70%; }
  .reply { border: 1px solid var(--line); border-radius: 12px 12px 0 0; }
}
