/* ToR — интерфейс к данным бота.
   Спокойная палитра, крупный кликабельный текст, никаких внешних зависимостей. */

:root {
  --bg:        #f6f6f4;
  --panel:     #ffffff;
  --panel-2:   #fbfbfa;
  --ink:       #1a1a1c;
  --muted:     #6c6c76;
  --line:      #e7e7e2;
  --accent:    #2f5fd0;
  --accent-bg: #ecf1fd;
  --ok:        #1c7f57;
  --ok-bg:     #e6f4ee;
  --warn:      #9a6510;
  --warn-bg:   #fbf1de;
  --bad:       #b3372a;
  --bad-bg:    #fbeae8;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(20,20,25,.05), 0 6px 18px rgba(20,20,25,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #121216;
    --panel:     #1a1a20;
    --panel-2:   #16161b;
    --ink:       #ececf1;
    --muted:     #9797a3;
    --line:      #2a2a33;
    --accent:    #7ea2f5;
    --accent-bg: #1e2740;
    --ok:        #5fc298;
    --ok-bg:     #16302a;
    --warn:      #d9ae60;
    --warn-bg:   #33290f;
    --bad:       #e78b7f;
    --bad-bg:    #35201d;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── каркас ─────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  padding: 22px 14px 56px;
  border-right: 1px solid var(--line);
  background: var(--panel-2);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand { font-weight: 650; font-size: 16px; padding: 0 10px 4px; letter-spacing: -.2px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--ink); }
.nav a.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.sidebar footer {
  position: absolute; bottom: 18px; left: 24px; right: 14px;
  font-size: 12px; color: var(--muted);
}

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { font-size: 21px; margin: 0; letter-spacing: -.3px; font-weight: 640; }
.head .sub { color: var(--muted); font-size: 13px; }

.section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin: 28px 0 10px;
}

/* ── карточки ───────────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
          padding: 14px 16px; box-shadow: var(--shadow); }
.metric .label { font-size: 12.5px; color: var(--muted); }
.metric .value { font-size: 26px; font-weight: 620; letter-spacing: -.5px; margin-top: 4px; }
.metric .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.metric.accent .value { color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── воронка ────────────────────────────────────────────────────────────── */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.stage { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.stage .name { font-size: 13.5px; }
.stage .num { font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--muted); }
.stage .num b { color: var(--ink); font-weight: 600; }
.track { grid-column: 1 / -1; height: 10px; background: var(--panel-2);
         border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.stage.final .track i { background: var(--ok); }
.drop { grid-column: 1 / -1; font-size: 12px; color: var(--bad); margin: -2px 0 2px; }

/* ── столбики по дням ───────────────────────────────────────────────────── */
.days { display: flex; align-items: flex-end; gap: 5px; height: 92px; }
.days div { flex: 1; background: var(--line); border-radius: 4px 4px 2px 2px; position: relative; opacity: .55; }
.days div i { position: absolute; inset: auto 0 0 0; background: var(--accent);
              border-radius: 4px 4px 2px 2px; display: block; min-height: 3px; }
.days div.has i { box-shadow: 0 0 0 1px var(--accent); }
.days-labels { display: flex; justify-content: space-between; font-size: 11.5px;
               color: var(--muted); margin-top: 6px; }

/* ── списки-разбивки ────────────────────────────────────────────────────── */
.breakdown { display: flex; flex-direction: column; gap: 9px; }
.breakdown .row { display: grid; grid-template-columns: 1fr 44px; gap: 10px; align-items: center; font-size: 13.5px; }
.breakdown .row .bar { grid-column: 1 / -1; height: 6px; background: var(--panel-2);
                       border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.breakdown .row .bar i { display: block; height: 100%; background: var(--accent); opacity: .75; }
.breakdown .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── таблицы ────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
     color: var(--muted); font-weight: 600; padding: 0 12px 10px; }
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--panel-2); }
.num-cell { font-variant-numeric: tabular-nums; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* ── чипы статусов ──────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; justify-content: center;
        height: 21px; padding: 0 9px; border-radius: 6px; font-size: 11.5px;
        font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.chip.new      { background: var(--accent-bg); color: var(--accent); }
.chip.in_work  { background: var(--warn-bg);   color: var(--warn); }
.chip.booked   { background: var(--ok-bg);     color: var(--ok); }
.chip.rejected { background: var(--bad-bg);    color: var(--bad); }
.chip.draft, .chip.abandoned { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

/* ── master-detail ──────────────────────────────────────────────────────── */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } .split .list { max-height: none; } }

.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); overflow: hidden; position: sticky; top: 26px;
        max-height: calc(100vh - 52px); display: flex; flex-direction: column; }
.list .items { overflow-y: auto; }
.item { display: block; padding: 13px 15px; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item:hover { background: var(--panel-2); }
.item.on { background: var(--accent-bg); }
.item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.item .who { font-weight: 570; font-size: 14.5px; letter-spacing: -.1px; }
.item .when { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.item .meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
              font-size: 13px; color: var(--muted); margin-top: 7px; }
.item .kid { color: var(--ink); }
.item .tel { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted);
             font-variant-numeric: tabular-nums; letter-spacing: .2px; }

/* ── поиск и фильтры ────────────────────────────────────────────────────── */
.toolbar { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 9px; }
input[type=search], input[type=text] {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font: inherit; font-size: 14px;
}
input:focus { outline: 2px solid var(--accent-bg); border-color: var(--accent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tabs a {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 14px; box-sizing: border-box;
  font-size: 13px; line-height: 1; font-weight: 500; white-space: nowrap;
  border-radius: 8px; color: var(--muted);
  border: 1px solid var(--line); background: var(--panel);
  transition: background .12s, color .12s, border-color .12s;
}
.tabs a:hover { background: var(--panel-2); color: var(--ink); }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 550; }
@media (prefers-color-scheme: dark) { .tabs a.on { color: #0f1420; } }
.tabs input[type=search] { height: 32px; padding: 0 12px; }

/* ── карточка клиента ───────────────────────────────────────────────────── */
.person { display: flex; gap: 14px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--accent-bg);
          color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 18px; }
.person h2 { margin: 0; font-size: 18px; font-weight: 620; }
.person .id { color: var(--muted); font-size: 13px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
         gap: 12px; margin-top: 16px; }
.fact .k { font-size: 12px; color: var(--muted); }
.fact .v { font-size: 14.5px; margin-top: 2px; }
code, .copy { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px;
              background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px;
              border-radius: 6px; }

.steps { display: flex; flex-wrap: wrap; gap: 6px; }
.step { font-size: 12px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line);
        color: var(--muted); }
.step.done { background: var(--ok-bg); color: var(--ok); border-color: transparent; font-weight: 550; }
.step.stuck { background: var(--bad-bg); color: var(--bad); border-color: transparent; font-weight: 600; }

/* ── таймлайн ───────────────────────────────────────────────────────────── */
.timeline { position: relative; margin: 6px 0 0; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
                    width: 2px; background: var(--line); border-radius: 2px; }
.tl { position: relative; padding: 7px 0; }
.tl::before { content: ""; position: absolute; left: -19px; top: 13px; width: 8px; height: 8px;
              border-radius: 50%; background: var(--line); border: 2px solid var(--panel); }
.tl.in::before  { background: var(--accent); }
.tl.out::before { background: var(--ok); }
.tl.lead::before{ background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.tl .t { font-size: 11.5px; color: var(--muted); }
.tl .txt { font-size: 14px; margin-top: 1px; }
.tl.in .txt, .tl.out .txt { background: var(--panel-2); border: 1px solid var(--line);
                            border-radius: 10px; padding: 7px 11px; display: inline-block;
                            max-width: 100%; word-break: break-word; }
.tl.out .txt { background: var(--ok-bg); border-color: transparent; }

.empty { color: var(--muted); font-size: 14px; padding: 28px 0; text-align: center; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
       background: var(--panel); font-size: 13.5px; font-weight: 550; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 16px; }


/* ── страница входа ──────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
              background: radial-gradient(120% 90% at 50% 0%, var(--panel) 0%, var(--bg) 55%); }

.login-card { width: 100%; max-width: 380px; background: var(--panel);
              border: 1px solid var(--line); border-radius: 16px; padding: 32px 30px 24px;
              box-shadow: 0 1px 2px rgba(20,20,25,.05), 0 18px 50px rgba(20,20,25,.08); }
@media (prefers-color-scheme: dark) {
  .login-card { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 18px 50px rgba(0,0,0,.45); }
}

.login-brand { text-align: center; margin-bottom: 24px; }
.login-mark { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
              background: var(--accent); color: #fff; display: grid; place-items: center;
              font-weight: 700; font-size: 17px; letter-spacing: -.3px; }
.login-brand h1 { font-size: 19px; margin: 0; font-weight: 620; letter-spacing: -.3px; }
.login-brand p { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); }

.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; }
.login-card label span { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.login-card input { height: 42px; padding: 0 13px; border-radius: 10px;
                    border: 1px solid var(--line); background: var(--panel-2);
                    color: var(--ink); font: inherit; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--accent);
                          box-shadow: 0 0 0 3px var(--accent-bg); }
.login-card button { height: 44px; margin-top: 4px; border: none; border-radius: 10px;
                     background: var(--accent); color: #fff; font: inherit; font-size: 15px;
                     font-weight: 600; cursor: pointer; transition: filter .12s; }
.login-card button:hover { filter: brightness(1.08); }
.login-card button:active { filter: brightness(.94); }

.login-card footer { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
                     text-align: center; font-size: 12px; color: var(--muted); }

.alert { background: var(--bad-bg); color: var(--bad); border-radius: 10px;
         padding: 11px 13px; font-size: 13.5px; margin-bottom: 16px; text-align: center; }
.alert span { display: block; margin-top: 3px; font-size: 12px; opacity: .85; }

/* выход в боковом меню */
.logout { margin-top: auto; }
.logout button { width: 100%; text-align: left; padding: 9px 10px; border-radius: 9px;
                 border: none; background: none; color: var(--muted); font: inherit;
                 font-weight: 500; cursor: pointer; }
.logout button:hover { background: var(--panel); color: var(--ink); }


/* метка площадки: Telegram или MAX */
.pf { display: inline-flex; align-items: center; height: 19px; padding: 0 7px;
      border-radius: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
      text-transform: uppercase; border: 1px solid var(--line); color: var(--muted); }
.pf.tg  { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.pf.max { background: var(--ok-bg);     color: var(--ok);     border-color: transparent; }
