/* Палитра из брифа. Спокойная бумага, приглушённая зелень, один синий акцент.
   Светлая по умолчанию; тёмная — при data-theme="dark" на <html>. */
:root {
    --paper:   #EDF0EC;
    --surface: #FFFFFF;
    --surface-2: #F5F7F4;
    --ink:     #12211C;
    --muted:   #6B7A73;
    --lake:    #1F5F8B;   /* акцент */
    --lake-soft: #E4EDF3;
    --moss:    #4E7A48;   /* забронировал */
    --ochre:   #C7861F;   /* думает */
    --rust:    #A8432F;   /* отказ, пропущенный, тревога */
    --line:    #D6DCD5;
    --alert-bg: #F6E7E3;
    --miss-bg:  #FAF0DC;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(18, 33, 28, .05), 0 4px 16px rgba(18, 33, 28, .04);
    --shadow-lg: 0 2px 6px rgba(18, 33, 28, .06), 0 12px 40px rgba(18, 33, 28, .08);
}

:root[data-theme="dark"] {
    /* нейтральная тёмная гамма — угольная, без цветного оттенка */
    --paper:   #121316;
    --surface: #1B1D21;
    --surface-2: #24272C;
    --ink:     #ECEDEF;
    --muted:   #9A9DA5;
    --lake:    #5AA6D8;
    --lake-soft: #1E3140;
    --moss:    #6FB268;
    --ochre:   #E0A542;
    --rust:    #E07A63;
    --line:    #2E3138;
    --alert-bg: #3A2521;
    --miss-bg:  #332A1A;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 14px 44px rgba(0, 0, 0, .4);
}

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

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Onest, "Golos Text", -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    /* именно background-color, а не сокращённое background: последнее содержит
       неанимируемые части, и переход на нём в паре с var() глючит */
    transition: background-color .25s ease, color .25s ease;
}

.card, .call, .tile, .chip, .top, .login,
.filters input[type=search], .speed button {
    transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

h1, h2, h3, .numeric {
    font-family: Unbounded, Onest, sans-serif;
    font-weight: 600;
    letter-spacing: -.02em;
}

.mono {
    font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

a { color: var(--lake); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------ каркас */

.top {
    position: sticky; top: 0; z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 20px;
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.top .brand { font-family: Unbounded, sans-serif; font-weight: 600; font-size: 16px; }
.top .brand span { color: var(--muted); font-weight: 400; }
.top .spacer { flex: 1; }
.top .who { color: var(--muted); font-size: 13px; }
.top .nav { display: flex; gap: 4px; }
.top .nav a {
    padding: 6px 14px; border-radius: 999px; font-size: 14px; color: var(--muted);
}
.top .nav a:hover { color: var(--ink); text-decoration: none; background: var(--surface-2); }
.top .nav a.on { color: var(--ink); background: var(--surface-2); font-weight: 500; }
.theme-toggle { padding: 6px 11px; font-size: 15px; line-height: 1; }
:root[data-theme="dark"] .theme-toggle .t-dark,
:root:not([data-theme="dark"]) .theme-toggle .t-light { display: none; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px; }

/* ------------------------------------------------------------ числа сверху */

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.tile {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px 16px;
}
.tile .n { font-family: Unbounded, sans-serif; font-size: 26px; font-weight: 600; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tile.moss .n { color: var(--moss); }
.tile.rust .n { color: var(--rust); }
.tile.ochre .n { color: var(--ochre); }

/* ------------------------------------------------------------ вкладки */

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs .tab {
    padding: 10px 16px; color: var(--muted); font-size: 15px; font-weight: 500;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--ink); text-decoration: none; }
.tabs .tab.on { color: var(--ink); border-bottom-color: var(--lake); }
.tabs .cnt {
    display: inline-block; font-size: 12px; margin-left: 5px;
    background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 8px;
}
.tabs .tab.on .cnt { background: var(--lake); color: #fff; }

/* --------------------------------------------------- аналитика спроса */

.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.bar-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 12px;
           align-items: center; padding: 7px 0; }
.bar-row:has(.bar-num:only-of-type) { grid-template-columns: 1fr auto; }
.bar-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-fill.rust { background: var(--rust); }
.bar-fill.lake { background: var(--lake); }
.bar-num { color: var(--muted); font-size: 13px; text-align: right; min-width: 34px; }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; line-height: 1.5; }

.cal { display: flex; gap: 4px; overflow-x: auto; padding: 8px 0 4px; }
.cal-cell {
    flex: 0 0 42px; display: flex; flex-direction: column; align-items: center;
    gap: 3px; position: relative;
}
.cal-bar {
    width: 26px; height: 70px; border-radius: 6px;
    background: var(--surface-2); position: relative; overflow: hidden;
}
.cal-bar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0;
    height: var(--fill); background: var(--lake); opacity: .85;
}
.cal-refuse { position: absolute; top: 0; width: 26px; height: 4px;
              background: var(--rust); border-radius: 2px; }
.cal-date { font-size: 10px; color: var(--muted); }
.cal-req { font-size: 12px; font-weight: 500; }

/* ------------------------------------------------------------ фильтры */

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters input[type=search] {
    flex: 1; min-width: 200px;
    padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); color: var(--ink); font: inherit;
}
.filters input[type=search]:focus { outline: 2px solid var(--lake); outline-offset: -1px; }

.chip {
    padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--muted);
    font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--lake); color: var(--lake); text-decoration: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ------------------------------------------------------------ лента */

.call {
    display: grid;
    grid-template-columns: 92px 168px 1fr 92px;
    gap: 14px; align-items: center;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
    color: inherit;
}
.call:hover { border-color: var(--lake); text-decoration: none; }
.call.missed { border-left: 3px solid var(--rust); }

.call .time { color: var(--muted); font-size: 13px; }
.call .who .num { font-size: 14px; }
.call .who .nm { color: var(--muted); font-size: 12px; }
.call .body { min-width: 0; }
.call .sum {
    font-size: 14px; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.call .sum.none { color: var(--muted); font-style: italic; }
.call .right { text-align: right; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot.moss { background: var(--moss); }
.dot.ochre { background: var(--ochre); }
.dot.rust { background: var(--rust); }
.dot.lake { background: var(--lake); }
.dot.muted { background: var(--line); }

.tag {
    display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); margin-left: 6px;
}
.tag.alert { background: var(--alert-bg); color: var(--rust); }
.tag.miss { background: var(--miss-bg); color: var(--ochre); }

/* ------------------------------------------------- полоса разговора */

.stripe { position: relative; height: 16px; margin: 6px 0 4px; }
.stripe .track { position: absolute; left: 0; right: 0; height: 5px; border-radius: 3px; background: var(--paper); }
.stripe .track.op { top: 1px; }
.stripe .track.cl { top: 10px; }
.stripe i { position: absolute; height: 5px; border-radius: 3px; display: block; }
.stripe i.op { top: 1px;  background: var(--muted); opacity: .55; }
.stripe i.cl { top: 10px; background: var(--lake); }
.stripe b { position: absolute; top: -2px; width: 2px; height: 20px; border-radius: 1px; }
.stripe b.price   { background: var(--ochre); }
.stripe b.dates   { background: var(--moss); }
.stripe b.refusal { background: var(--rust); }
.stripe.silent::after {
    content: "недозвон"; position: absolute; left: 0; top: 0;
    font-size: 11px; color: var(--rust);
}

/* ------------------------------------------------------------ карточка */

.card { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
        box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 15px; }

/* Плашка разбора крупнее расшифровки — это главное на карточке */
.cols { display: grid; grid-template-columns: 1fr 420px; gap: 16px; align-items: start; }

.player { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.player audio { flex: 1; min-width: 220px; height: 40px; }
.speed { display: flex; gap: 4px; }
.speed button {
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.speed button:hover { border-color: var(--lake); color: var(--lake); }
.speed button.on { background: var(--lake); border-color: var(--lake); color: #fff; }

/* полоса разговора на карточке — кликабельная дорожка плеера */
.player-stripe { margin-top: 14px; cursor: pointer; }
.player-stripe .stripe { height: 26px; }
.player-stripe .stripe .track { height: 8px; border-radius: 4px; }
.player-stripe .stripe .track.op { top: 2px; }
.player-stripe .stripe .track.cl { top: 15px; }
.player-stripe .stripe i { height: 8px; border-radius: 4px; }
.player-stripe .stripe i.op { top: 2px; }
.player-stripe .stripe i.cl { top: 15px; }
.player-stripe .stripe b { top: -1px; height: 28px; }
.player-stripe .played {
    position: absolute; top: 0; bottom: 0; left: 0; width: 0;
    background: var(--lake); opacity: .1; border-radius: 4px; pointer-events: none;
}
.player-stripe .cursor {
    position: absolute; top: -2px; width: 2px; height: 30px;
    background: var(--ink); opacity: .5; pointer-events: none;
}

.lines { max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.line {
    display: grid; grid-template-columns: 52px 1fr; gap: 10px;
    padding: 7px 9px; border-radius: 8px; cursor: pointer;
    border-left: 2px solid transparent;
}
.line:hover { background: var(--surface-2); }
.line.on { background: var(--lake-soft); border-left-color: var(--lake); }
.line .t { color: var(--muted); font-size: 12px; padding-top: 2px; }
.line.op .x { color: var(--muted); }
.line.cl .x { color: var(--ink); font-weight: 500; }

/* --- красивая плашка разбора --- */
.analysis { padding: 0; overflow: hidden; }
.analysis .head {
    padding: 18px 20px; color: #fff;
    background: linear-gradient(135deg, var(--lake), #16496b);
}
.analysis .head.moss  { background: linear-gradient(135deg, var(--moss), #3a5d36); }
.analysis .head.ochre { background: linear-gradient(135deg, var(--ochre), #9c6816); }
.analysis .head.rust  { background: linear-gradient(135deg, var(--rust), #7f3223); }
.analysis .head.muted { background: linear-gradient(135deg, #5a6a62, #3f4b45); }
.analysis .head .outcome {
    font-family: Unbounded, sans-serif; font-size: 21px; font-weight: 600;
    text-transform: capitalize; line-height: 1.1;
}
.analysis .head .reason { font-size: 13px; opacity: .9; margin-top: 4px; }
.analysis .body { padding: 6px 20px 18px; }

.facts { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.facts li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.facts li:last-child { border-bottom: none; }
.facts .k { color: var(--muted); flex: 0 0 136px; font-size: 13px; }
.facts .v { flex: 1; }

.analysis .summary {
    background: var(--surface-2); border-radius: 10px;
    padding: 13px 15px; margin: 14px 0 0; font-size: 14px; line-height: 1.55;
}
.analysis .promises { margin-top: 14px; }
.analysis .promises .h { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.analysis .promise {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--line);
}
.analysis .promise:last-child { border-bottom: none; }
.analysis .promise::before { content: "✓"; color: var(--moss); font-weight: 700; }

.chiplist { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
    display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px;
    background: var(--surface-2); color: var(--ink);
}

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); }

/* ------------------------------------------------------------ вход */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login {
    width: 100%; max-width: 340px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 26px; box-shadow: var(--shadow);
}
.login h1 { font-size: 19px; margin: 0 0 4px; }
.login p.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.login input {
    width: 100%; padding: 10px 12px; margin-bottom: 14px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--paper); color: var(--ink); font: inherit;
}
.login input:focus { outline: 2px solid var(--lake); outline-offset: -1px; background: var(--surface); }
.login button {
    width: 100%; padding: 11px; border: none; border-radius: var(--radius);
    background: var(--lake); color: #fff; font: inherit; font-weight: 500; cursor: pointer;
}
.login button:hover { background: #1a5478; }
.login .err { background: #F6E7E3; color: var(--rust); padding: 9px 12px;
              border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }

/* ------------------------------------------------------------ телефон */

@media (max-width: 760px) {
    .wrap { padding: 12px; }
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .cols { grid-template-columns: 1fr; }
    .call {
        grid-template-columns: 1fr auto;
        grid-template-areas: "who right" "body body";
        row-gap: 8px;
    }
    .call .time { display: none; }
    .call .who { grid-area: who; }
    .call .right { grid-area: right; }
    .call .body { grid-area: body; }
    .call .sum { white-space: normal; }
    .cols { grid-template-columns: 1fr; }
    .facts .k { flex: 0 0 118px; }
    .analysis .head .outcome { font-size: 19px; }
    .dgrid { grid-template-columns: 1fr; }
    .top .nav a { padding: 6px 10px; }
}
