/* ZIO — кабинет. Свой интерфейс без фреймворков. */
:root {
  --bg: #F4F6FB; --surface: #FFFFFF; --surface2: #EEF1F8; --line: #DEE3EE;
  --text: #0F1530; --muted: #565E78;
  --accent: #1D38F9; --accent-hover: #142ACC; --accent-text: #FFFFFF; --accent-soft: #E6EAFF;
  --ok: #12704A; --ok-soft: #DDF3E8; --warn: #8A5300; --warn-soft: #FCEBC9;
  --bad: #B42318; --bad-soft: #FDE4E2; --off: #5B6278; --off-soft: #E9ECF3;
  --shadow: 0 1px 2px rgba(15,21,48,.06), 0 4px 16px rgba(15,21,48,.06);
  --radius: 14px; --sidebar: 248px;
  color-scheme: light;
}
html.dark {
  --bg: #0B0E1A; --surface: #141829; --surface2: #1C2135; --line: #2A3049;
  --text: #EEF1FA; --muted: #A3AAC2;
  --accent: #7B8CFF; --accent-hover: #A3AFFF; --accent-text: #0B0E1A; --accent-soft: #1F2756;
  --ok: #6FD6A6; --ok-soft: #12301F; --warn: #F3C26B; --warn-soft: #3A2C12;
  --bad: #F2A3A3; --bad-soft: #3A1616; --off: #A3AAC2; --off-soft: #22273A;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 24px; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 0; font-weight: 700; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.boot img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; transform: scale(.95); } }

/* ---------- Кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--bad); border-color: currentColor; background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 44px; padding: 0; }
.btn.icon.sm { width: 36px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 500; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 15px; }
select.input { padding-right: 32px; }
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.err { color: var(--bad); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span2 { grid-column: span 2; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--muted); }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface2); border-radius: 10px; }
.seg button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface2); color: var(--text); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--off-soft); color: var(--off); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Каркас ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; overflow-y: auto; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; color: var(--text); }
.brand img { width: 40px; height: 40px; }
.brand b { font-family: Unbounded, Inter, sans-serif; font-size: 16px; letter-spacing: 1px; display: block; }
.brand small { display: block; font-size: 12px; color: var(--muted); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .soon { margin-left: auto; font-size: 11px; color: var(--muted); }
.sb-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.sb-user .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sb-user .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.sb-user .who span { font-size: 12px; color: var(--muted); }
.trial-note { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar); padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head h1 { margin-right: auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.card.pad { padding: 18px 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi b { font-size: 22px; }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .grow { flex: 999 1 560px; min-width: 0; }
.split > .side { flex: 1 1 300px; min-width: 0; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr { cursor: pointer; }
table.t tbody tr:hover td { background: var(--surface2); }
table.t td.num, table.t th.num { text-align: right; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); flex: 0 1 320px; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 14px; min-height: 40px; }

/* ---------- Журнал ---------- */
.dayhead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dayhead .date { font-weight: 600; padding: 0 8px; }
.cal { overflow-x: auto; }
.cal-inner { min-width: 640px; }
.cal-head, .cal-body { display: grid; }
.cal-head { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.cal-head .mh { display: flex; align-items: center; gap: 10px; padding: 12px; border-left: 1px solid var(--line); min-width: 0; }
.cal-head .mh .avatar { width: 32px; height: 32px; font-size: 12px; }
.cal-head .mh b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-body { position: relative; }
.cal-hours > div { height: 60px; padding: 4px 10px 0 0; text-align: right; font-size: 12px; color: var(--muted); }
.cal-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent 60px); }
.cal-col .slot { position: absolute; left: 0; right: 0; height: 30px; border: 0; background: transparent; padding: 0; }
.cal-col .slot:hover { background: var(--accent-soft); }
.cal-col .slot:hover::after { content: "+"; color: var(--accent); font-weight: 700; }
.appt { position: absolute; left: 4px; right: 4px; padding: 6px 10px; border-radius: 10px; border: 0; text-align: left; display: flex; flex-direction: column; gap: 1px; overflow: hidden; z-index: 1; }
.appt .tm { font-size: 12px; font-weight: 600; opacity: .85; }
.appt .cl { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt .sv { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt.sel { outline: 2px solid var(--text); outline-offset: -2px; }
.st-new { background: var(--warn-soft); color: var(--warn); }
.st-confirmed { background: var(--accent-soft); color: var(--accent); }
.st-in_progress { background: var(--accent); color: var(--accent-text); }
.st-done { background: var(--ok-soft); color: var(--ok); }
.st-cancelled, .st-no_show { background: var(--off-soft); color: var(--off); text-decoration: line-through; }
.now-line { position: absolute; left: 56px; right: 0; height: 2px; background: var(--accent); z-index: 3; pointer-events: none; }
dl.kv { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
dl.kv dt { font-size: 12px; color: var(--muted); }
dl.kv dd { margin: 2px 0 0; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* ---------- Окна ---------- */
.overlay { position: fixed; inset: 0; background: rgba(11,14,26,.5); display: flex; align-items: flex-start; justify-content: center; padding: 64px 16px; z-index: 100; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.suggest { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.suggest button { display: flex; justify-content: space-between; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; }
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover { background: var(--surface2); }
.picked { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13px; }
.chip.on { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent); }

#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- Вход и регистрация ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 16px 48px; }
.auth-head { width: 100%; max-width: 720px; display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-head .brand { margin-right: auto; padding: 0; }
.auth-card { width: 100%; max-width: 720px; padding: 32px; display: flex; flex-direction: column; gap: 22px; }
.auth-card.narrow { max-width: 440px; }
.progress { display: flex; gap: 6px; }
.progress div { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.progress div.on { background: var(--accent); }
.typecards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.typecard { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 20px; min-height: 180px; text-align: left; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.typecard svg.i { width: 28px; height: 28px; }
.typecard b { font-size: 18px; }
.typecard span { color: var(--muted); }
.typecard em { font-style: normal; color: var(--accent); font-weight: 600; font-size: 13px; }
.typecard.on { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent); }
.group-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.note { padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); line-height: 1.5; }

/* ---------- Адаптив ---------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .shell.menu-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 16px 16px 40px; }
  .topbar { display: flex; align-items: center; gap: 10px; }
  .topbar img { width: 32px; height: 32px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid2, .typecards { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .auth-card { padding: 22px; }
}

/* ---------- Выпадающий список ZIO ---------- */
.zsel { position: relative; width: 100%; }
.zsel-native { position: absolute !important; inset: 0; opacity: 0; pointer-events: none; width: 100%; height: 100%; }
.zsel-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; cursor: pointer; font: inherit; font-size: 15px; }
.zsel-btn:disabled { opacity: .6; cursor: default; }
.zsel-btn[aria-expanded="true"] { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.zsel-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.zsel-chev { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.zsel-btn[aria-expanded="true"] .zsel-chev { transform: rotate(180deg); stroke: var(--accent); }
.zsel-list { position: fixed; z-index: 10000; max-width: calc(100vw - 16px); overflow-y: auto; padding: 6px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(10, 20, 60, .18); font-size: 15px; animation: zsel-in .12s ease-out; }
@keyframes zsel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.zsel-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.zsel-opt.act { background: var(--surface2); }
.zsel-opt.on { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.zsel-opt.off { opacity: .45; cursor: default; }
.zsel-opt svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.zsel-group { padding: 10px 10px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .zsel-list { animation: none; } .zsel-chev { transition: none; } }

/* ---------- Напоминания ---------- */
.rem, .rule { display: flex; flex-direction: column; gap: 12px; }
.rule { cursor: pointer; }
.rule:hover { border-color: var(--accent); }
.rem-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.rem-name { font-size: 16px; }
.rem-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.rem-msg { white-space: pre-wrap; padding: 12px 14px; border-radius: 12px; background: var(--surface2); font-size: 14px; line-height: 1.5; }
.filters { gap: 10px; }
.filters .field { width: auto; min-width: 200px; }
.t.compact th, .t.compact td { padding: 8px 10px; }
.note code, .muted code { font-size: 12px; padding: 1px 5px; border-radius: 5px; background: var(--surface2); color: var(--text); }
.row.between { justify-content: space-between; }
