/* Theralight CRM — «кнопочный телефон»: выпуклые клавиши с подписью, одна зелёная клавиша
   следующего шага на экран, ЖК-дисплей для фактов. Основной текст 20 px, клавиша «Крупнее»
   масштабирует весь интерфейс через font-size корня (всё в rem). */

:root {
  --font: "Golos Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --body: #d9dbd8;        /* серый пластик корпуса */
  --body-2: #cdd0cc;      /* панель клавиатуры */
  --key: #ffffff;         /* белая клавиша */
  --key-hover: #f0f1ee;
  --key-edge: #a9ada6;
  --ink: #161816;
  --ink-2: #3c403b;       /* 7.4:1 на корпусе */
  --line: #a3a79f;
  --field-edge: #7d8279;

  --lcd: #d9e2c5;
  --lcd-ink: #15200f;
  --lcd-label: #3d4a2c;   /* 7:1 на дисплее */
  --lcd-edge: #a9b58f;

  --go: #1d7a3a;          /* единственная зелёная клавиша экрана */
  --go-hover: #186a32;
  --go-edge: #135a29;
  --stop: #a3221b;
  --stop-soft: #f6dad7;
  --call: #f4b400;        /* звонок и напоминание */
  --call-edge: #c99400;
  --focus: #2357a6;

  /* этапы: янтарный отдан звонкам, чёрный — «выбрано», поэтому у «Новой» свой ржавый, у «Забрал» — оливка дисплея */
  --st-new: #b4441a;  --st-new-ink: #ffffff;
  --st-paid: #0e6e6a; --st-shipped: #2357a6; --st-arrived: #6a44b0; --st-picked: #4e5b2e;

  --r: 14px;
  --r-in: 10px;           /* концентрично: внутреннее = внешнее − отступ */
  --lift: 0 1px 0 rgba(255, 255, 255, .85) inset, 0 2px 0 rgba(26, 25, 23, .07),
          0 5px 12px -4px rgba(26, 25, 23, .22);
  --press: 0 1px 2px rgba(26, 25, 23, .22);

  font-size: 20px;
  color-scheme: light;
  accent-color: var(--go);
}
html[data-size="2"] { font-size: 23px; }
html[data-size="3"] { font-size: 26px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--body);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #b9c99a; color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
a { color: var(--focus); text-underline-offset: .18em; text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.3; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; font-weight: 700; margin: 2.2rem 0 .8rem; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 1.4rem 0 .5rem; }
p { margin: 0 0 .8rem; max-width: 70ch; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg.i { width: 1.3em; height: 1.3em; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; }

/* ── корпус: клавиатура разделов + экран ─────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh;
         background: linear-gradient(to right, var(--body-2) 15.5rem, var(--body) 0); }
.hint-line { display: flex; gap: .6rem; align-items: center; margin: 1rem 0 0; }
.pad {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: .6rem;
  padding: 1.2rem 1rem;
  background: var(--body-2);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: .35rem; padding: .2rem .4rem 1rem;
         color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.brand span { color: var(--ink-2); font-weight: 500; font-size: .9rem; }
.pad .spacer { flex: 1; }
main { padding: 1.6rem 2.4rem 5rem; max-width: 64rem; width: 100%; }
.mob { display: none !important; }

/* ── клавиша ─────────────────────────────────────────────────────────────────────── */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 3rem; padding: .55rem 1.1rem;
  font: 600 1.05rem/1.3 var(--font); color: var(--ink);
  background: var(--key); border: 1px solid var(--key-edge); border-radius: var(--r);
  box-shadow: var(--lift);
  text-decoration: none; cursor: pointer; user-select: none;
  transition: transform 110ms cubic-bezier(.2, .8, .2, 1), box-shadow 110ms, background-color 110ms;
}
.key:hover { background: var(--key-hover); }
.key:active { transform: translateY(2px); box-shadow: var(--press); }
.key[disabled] { opacity: .5; box-shadow: none; cursor: not-allowed; transform: none; }
.key.go {
  background: var(--go); color: #fff; border-color: var(--go-edge);
  font-size: 1.15rem; min-height: 3.6rem; padding-inline: 1.5rem;
}
.key.go:hover { background: var(--go-hover); }
.key.call { background: var(--call); border-color: var(--call-edge); }
.key.call:hover { background: #e7aa00; }
.key.stop { color: var(--stop); }
.key.stop:hover { background: var(--stop-soft); }
.key.wide { width: 100%; }
.callkey { justify-content: flex-start; text-align: left; padding-block: .45rem; }
.callkey-text { display: flex; flex-direction: column; line-height: 1.25; }
.callkey-text > span { font-size: .9rem; font-weight: 600; }
.callkey-text > b { font-size: 1.1rem; font-weight: 700; white-space: nowrap; letter-spacing: .01em; }
.key.small { min-height: 2.8rem; font-size: .95rem; padding: .4rem .9rem; }
.key-label { text-wrap: balance; }

/* редко нужное спрятано за клавишей, а не за синей ссылкой */
details > summary {
  display: inline-flex; align-items: center; gap: .55rem; list-style: none;
  min-height: 2.8rem; padding: .45rem 1.1rem;
  font-weight: 600; color: var(--ink); cursor: pointer;
  background: var(--key); border: 1px solid var(--key-edge); border-radius: var(--r); box-shadow: var(--lift);
}
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: var(--press); }
details:not([open]) > summary .i-minus, details[open] > summary .i-plus { display: none; }
details[open] > summary + * { margin-top: 1rem; }

.navkey { justify-content: flex-start; width: 100%; min-height: 3.4rem; }
.navkey .count {
  margin-left: auto; min-width: 1.7rem; padding: 0 .4rem; border-radius: 99px;
  background: var(--ink); color: #fff; font-size: .9rem; line-height: 1.7rem; text-align: center;
}
/* текущий раздел — клавиша «утоплена»: инверсия вместо цвета */
.navkey.on { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: var(--press); }
.navkey.on .count { background: #fff; color: var(--ink); }

/* ── дисплей ─────────────────────────────────────────────────────────────────────── */
.lcd {
  background: var(--lcd); color: var(--lcd-ink);
  border: 2px solid var(--lcd-edge); border-radius: var(--r);
  box-shadow: inset 0 2px 7px rgba(21, 32, 15, .2);
  padding: 1rem 1.25rem;
  font-variant-numeric: tabular-nums;
}
.lcd dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1.4rem; margin: 0; }
.lcd dt { color: var(--lcd-label); font-size: .9rem; padding-top: .12rem; }
.lcd dd { margin: 0; font-weight: 600; font-size: 1.1rem; overflow-wrap: anywhere; }
.lcd dd a { color: inherit; }
.lcd .big { font-size: 1.35rem; font-weight: 700; }
.lcd dd.muted-dd { font-weight: 500; }
.screen-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
               gap: .8rem 1.2rem; margin-bottom: 1.2rem; }
.screen-head .sub { color: var(--ink-2); margin: .3rem 0 0; }
.lcd-bar { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; align-items: baseline; }
.lcd-bar b { font-size: 1.3rem; }

.flash { display: flex; gap: .6rem; align-items: center; margin-bottom: 1.2rem; padding: .8rem 1.1rem;
         border-radius: var(--r); background: var(--lcd); border: 2px solid var(--lcd-edge); font-weight: 600; }
.flash.bad { background: var(--stop-soft); border-color: #d9a29d; color: #6e1611; }

/* ── строки-клавиши (списки) ─────────────────────────────────────────────────────── */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.row {
  display: flex; align-items: center; gap: 1rem;
  background: var(--key); border: 1px solid var(--key-edge); border-radius: var(--r);
  box-shadow: var(--lift);
}
.row-main {
  flex: 1; min-width: 0; display: block; padding: .9rem 1.2rem;
  color: var(--ink); text-decoration: none; border-radius: var(--r);
  transition: background-color 110ms;
}
.row:has(> .row-main:hover) { background: var(--key-hover); }
.row:has(> .row-main:active) { background: #e6e8e4; }
.row .key { margin-right: .7rem; flex: none; }
.row-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; }
.row-name { font-size: 1.2rem; font-weight: 700; }
.row-meta { color: var(--ink-2); margin-top: .2rem; }
.row-meta b { color: var(--ink); font-weight: 600; }
.row.late { border-color: var(--call-edge); box-shadow: var(--lift), 0 0 0 2px var(--call) inset; }
/* самое срочное дело дня — инверсия, как утопленная клавиша */
.row.top { background: var(--ink); border-color: var(--ink); box-shadow: var(--press), 0 0 0 3px var(--call); }
.row.top .row-main, .row.top .row-meta b { color: #fff; }
.row.top .row-meta { color: #d9dbd8; }
.row.top .tag { color: #fff; border-color: #8c918a; }
.row.top:has(> .row-main:hover) { background: #262926; }

.plate {
  display: inline-block; padding: .12rem .6rem; border-radius: 8px;
  font-size: .9rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
  color: #fff; background: var(--st-picked);
}
.plate.new { background: var(--st-new); color: var(--st-new-ink); }
.plate.paid { background: var(--st-paid); }
.plate.shipped { background: var(--st-shipped); }
.plate.arrived { background: var(--st-arrived); }
.plate.picked { background: var(--st-picked); }
.plate.refused, .plate.returned { background: var(--stop-soft); color: #6e1611; }
.tag { display: inline-block; padding: .05rem .5rem; border: 1.5px solid var(--line); border-radius: 8px;
       font-size: .9rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tag.repeat { border-color: var(--st-paid); color: var(--st-paid); }

.empty { padding: 1.2rem 1.3rem; border: 2px dashed var(--line); border-radius: var(--r); color: var(--ink-2); }

/* ── фильтры этапов — ряд клавиш ─────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters .key { min-height: 2.8rem; font-size: 1rem; }
.filters .key small { font-weight: 500; color: var(--ink-2); font-size: .9rem; }
.filters .key.on { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: var(--press); }
.filters .key.on small { color: #d9dbd8; }
.search { display: flex; gap: .6rem; margin-bottom: 1.4rem; }
.filters.sorts { margin-top: -.3rem; margin-bottom: 1.4rem; align-items: center; }
.filters-label { font-weight: 600; color: var(--ink-2); margin-right: .2rem; }
.search input { flex: 1; }

/* ── этапы заказа ─────────────────────────────────────────────────────────────────── */
.steps { list-style: none; margin: 1.4rem 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; }
.steps li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3rem; }
.steps li::before {   /* провод между лампочками */
  content: ""; position: absolute; top: 1.05rem; left: -50%; width: 100%; height: 4px;
  background: var(--line); z-index: 0;
}
.steps li:first-child::before { display: none; }
.steps li.done::before, .steps li.now::before { background: var(--ink); }
.steps .dot {
  position: relative; z-index: 1; display: grid; place-items: center;
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--key); border: 3px solid var(--line); color: #fff;
}
.steps li.done .dot { background: var(--ink); border-color: var(--ink); }
.steps li.now .dot { border: 5px solid var(--ink); box-shadow: 0 0 0 4px var(--lcd-edge); background: var(--key); }
.steps b { font-size: .95rem; line-height: 1.3; }
.steps small { color: var(--ink-2); font-size: .9rem; min-height: 1.3em; }
.steps li.future b { color: var(--ink-2); font-weight: 500; }
/* лампочки — кнопки статуса */
.steps-form { margin-top: 1.4rem; }
.steps-hint { margin: 0 0 .4rem; font-weight: 600; }
.steps-form .steps { margin: 0 0 1rem; }
.steps .step {
  all: unset; box-sizing: border-box; position: relative; z-index: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3rem;
  padding: .3rem .2rem .5rem; border-radius: var(--r); cursor: pointer;
  transition: background-color 110ms, box-shadow 110ms;
}
.steps .step:hover { background: var(--key); box-shadow: var(--lift); }
.steps .step:active { box-shadow: var(--press); }
.steps .step:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.steps .step[disabled] { cursor: default; background: transparent; box-shadow: none; }
.steps-form .steps li::before { top: 1.35rem; }

/* ── блок главного действия ───────────────────────────────────────────────────────── */
.action {
  margin: 1.2rem 0 .6rem; padding: 1.1rem 1.2rem;
  background: var(--body-2); border: 1px solid var(--line); border-radius: var(--r);
}
.action form { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: flex-end; }
.action .field { flex: 1 1 12rem; }
.action .hint { color: var(--ink-2); margin: .6rem 0 0; }
.side-keys { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0 0; }

/* ── формы ───────────────────────────────────────────────────────────────────────── */
label, .label { display: block; font-weight: 600; margin: 0 0 .35rem; }
.field { margin-bottom: 1rem; }
.field .help { color: var(--ink-2); font-size: .9rem; margin-top: .3rem; }
input, select, textarea {
  font: inherit; font-size: 1.05rem; color: var(--ink);
  width: 100%; min-height: 3rem; padding: .55rem .8rem;
  background: #fff; border: 2px solid var(--field-edge); border-radius: var(--r-in);
  transition: border-color 110ms, box-shadow 110ms;
}
textarea { min-height: 6rem; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px rgba(35, 87, 166, .22); }
input::placeholder, textarea::placeholder { color: #61665f; }
input[type="date"] { max-width: 13rem; }
.field.date { flex: 0 1 13rem; }
/* «Свой день» нужен только при выборе «В свой день» */
.call-form .field.date { display: none; }
.call-form fieldset:has(input[value="date"]:checked) .field.date { display: block; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, .8fr) minmax(0, 1.2fr); gap: 0 .8rem; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
legend { font-weight: 700; font-size: 1.1rem; padding: 0; margin-bottom: .6rem; }
details { margin: 1.2rem 0; }
.choice { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice label {
  display: inline-flex; align-items: center; gap: .5rem; margin: 0;
  min-height: 3rem; padding: .4rem 1rem; font-weight: 600;
  background: var(--key); border: 1px solid var(--key-edge); border-radius: var(--r); box-shadow: var(--lift); cursor: pointer;
}
.choice input { width: 1.3rem; min-height: 0; height: 1.3rem; margin: 0; }
.choice label:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: var(--press); }

/* ── журнал заказа ───────────────────────────────────────────────────────────────── */
.log { list-style: none; margin: 1rem 0 0; padding: 0; position: relative; }
.log::before { content: ""; position: absolute; left: 0; top: .3rem; bottom: .3rem; width: 3px; background: var(--line); border-radius: 2px; }
.log li { padding: .2rem 0 1rem 1.1rem; position: relative; }
.log li::before { content: ""; position: absolute; left: -.2rem; top: .55rem; width: .7rem; height: .7rem;
                  border-radius: 50%; background: var(--line); }
.log li.comment::before, .log li.call::before { background: var(--ink); }
.log .when { color: var(--ink-2); font-size: .9rem; }
.log .text { white-space: pre-line; overflow-wrap: anywhere; }
.log li.system .text, .log li.stage .text { color: var(--ink-2); }

.call-box { margin: .8rem 0; padding: 1rem 1.2rem; border-radius: var(--r);
            background: var(--key); border: 1px solid var(--key-edge); box-shadow: var(--lift); }
.call-box.due { border: 2px solid var(--call-edge); box-shadow: var(--lift), 0 0 0 3px var(--call); }
.call-box.done { background: transparent; box-shadow: none; }
.call-box h3 { margin: 0 0 .2rem; }

/* ── таблицы аналитики ───────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
.table th { font-size: .9rem; color: var(--ink-2); font-weight: 600; }
.table td.n, .table th.n { text-align: right; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.stat-block { margin-top: 1.4rem; }
.lcd + .table { margin-top: .6rem; }

/* ── вход ────────────────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.login-box { width: min(26rem, 100%); }
.login-box h1 { margin-bottom: .3rem; }
.login-box .sub { color: var(--ink-2); margin-bottom: 1.4rem; }

.sizes { display: flex; gap: .5rem; flex-wrap: wrap; }
.sizes .key.on { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: var(--press); }
.pad .bigger { width: 100%; justify-content: flex-start; }

/* ── телефон: клавиатура разделов уезжает вниз ───────────────────────────────────── */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--body); }
  .pad {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10;
    flex-direction: row; gap: .4rem; padding: .5rem .5rem calc(.5rem + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .brand, .pad .spacer, .desk { display: none !important; }
  .mob { display: flex !important; }
  .navkey { flex: 1 1 0; flex-direction: column; justify-content: center; gap: .15rem;
            min-height: 3.8rem; padding: .35rem .2rem; font-size: .9rem; }
  .navkey .count { position: absolute; transform: translate(1.1rem, -1.2rem); margin: 0; }
  .navkey { position: relative; }
  main { padding: 1.1rem 1rem calc(6.5rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.4rem; }
  .steps { grid-template-columns: minmax(0, 1fr); gap: .2rem; }
  .steps li { flex-direction: row; text-align: left; gap: .8rem; }
  .steps li::before { top: -50%; left: 1.05rem; width: 4px; height: 100%; }
  .steps small { margin-left: auto; min-height: 0; }
  .steps .step { flex-direction: row; text-align: left; gap: .8rem; padding: .4rem .2rem; min-height: 3rem; }
  .steps-form .steps li::before { top: -50%; left: 1.25rem; }
  .row { flex-wrap: wrap; gap: 0; }
  .row .key { margin: 0 .7rem .7rem; flex: 1 1 100%; }
  .row > form { flex: 1 1 100%; padding: 0 .7rem .7rem; }
  .row > form .key { width: 100%; margin: 0 !important; }
  /* формы и клавиши — сетка одинаковых ячеек на всю ширину, а не рваный столбик */
  .search { flex-direction: column; }
  .search .key { width: 100%; }
  .action form { flex-direction: column; align-items: stretch; }
  .action .field { flex: none; width: 100%; }
  .action input[type="date"], input[type="date"] { max-width: none; }
  .side-keys { display: grid; grid-template-columns: minmax(0, 1fr); }
  .side-keys .key, .side-keys form, .side-keys form .key { width: 100%; }
  .choice { display: grid; grid-template-columns: minmax(0, 1fr); }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-label { grid-column: 1 / -1; }
  .filters .key { width: 100%; justify-content: space-between; }
  details > summary { width: 100%; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .grid3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid3 .field:first-child { grid-column: 1 / -1; }
  .lcd dl { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .lcd dd { margin-bottom: .45rem; }
  .table th, .table td { padding: .55rem .4rem; }
  .action .key.go, .key.go { width: 100%; padding-inline: .8rem; text-wrap: balance; }
  .key.go svg { display: none; }  /* на узком экране галочка отрывалась от подписи — подпись важнее */
}

@media (prefers-reduced-motion: reduce) {
  .key, .row-main { transition: none; }
}

@media print {
  .pad, .action, .side-keys, form { display: none !important; }
  .shell { display: block; }
}
