:root {
  --ink: #16181d;
  --ink-2: #2a2d36;
  --ink-text: #d3d6df;
  --ground: #f4f5f8;
  --paper: #ffffff;
  --line: #e6e8ee;
  --text: #16181d;
  --muted: #5b6170;
  --accent: #5b3fd9;
  --accent-soft: #ece8ff;
  --accent-bar: #c9beff;
  --ok: #157347;
  --ok-soft: #e6f4ec;
  --warn: #9a4a07;
  --warn-soft: #fff3e0;
  --bad: #b42318;
  --bad-soft: #fdeded;
  --radius: 14px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.boot { padding: 40px; color: var(--muted); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── вхід ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); }
.login-card { width: 100%; max-width: 400px; background: var(--paper); border-radius: 20px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.login-card p { margin: 0; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); padding: 7px; }
.brand b { font-size: 17px; letter-spacing: .04em; }
.brand span { display: block; font-size: 12px; color: #a9adba; }
.login-card .brand span { color: var(--muted); }
.btn.tg { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 48px; background: #2481cc; border-color: #2481cc; color: #fff; font-size: 16px; }
.btn.tg:hover { background: #1f72b4; }
.login-err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* ── каркас ── */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: var(--ink-text); padding: 22px 14px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 8px; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; color: var(--ink-text); text-decoration: none; font-size: 14px; }
.nav a:hover { background: #22252d; }
.nav a[aria-current="page"] { background: var(--ink-2); color: #fff; font-weight: 600; }
.badge { min-width: 22px; text-align: center; border-radius: 999px; padding: 1px 7px; font-size: 12px; font-weight: 700; background: #f87171; color: var(--ink); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; font-size: 13px; color: #a9adba; }
.linkbtn { background: none; border: 0; padding: 0; color: #c9beff; cursor: pointer; text-align: left; text-decoration: underline; }

main { padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 22px; min-width: 0; max-width: 1280px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.head h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }

/* ── головні числа ── */
.lead { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lead .panel { padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; }
.lead .big { font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.lead .label { font-size: 15px; font-weight: 600; }
.lead .note { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 24px; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--muted); }

/* ── графік ── */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; border-bottom: 1px solid var(--line); }
.chart i { flex: 1 1 0; min-width: 0; background: var(--accent-bar); border-radius: 4px 4px 1px 1px; min-height: 2px; position: relative; }
.chart i.today { background: var(--accent); }
.chart-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend { font-size: 13px; color: var(--muted); }

/* ── увага ── */
.att { display: flex; flex-direction: column; gap: 10px; }
.att-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--ground); }
.att-item .n { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; background: #d5d8e1; }
.att-item.warn { background: var(--warn-soft); } .att-item.warn .n { background: #f5b04b; }
.att-item.bad { background: var(--bad-soft); } .att-item.bad .n { background: #f8a1a1; }
.att-item strong { display: block; font-size: 14px; }
.att-item span { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ── фільтри ── */
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1px solid #dcdfe6; border-radius: 10px; padding: 0 12px; height: 44px; flex: 1 1 220px; max-width: 340px; }
.search input { border: 0; outline: none; background: transparent; width: 100%; height: 100%; }
.search:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; }
select { height: 44px; border: 1px solid #dcdfe6; border-radius: 10px; background: var(--paper); padding: 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #dcdfe6; background: var(--paper); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .c { opacity: .7; margin-left: 4px; }

/* ── список майстрів ── */
.mlist { display: flex; flex-direction: column; }
.mrow { display: grid; grid-template-columns: minmax(180px, 2.2fr) minmax(150px, 1.6fr) 104px 84px minmax(130px, 1.1fr) 96px; gap: 14px; align-items: center; padding: 12px 8px; border-top: 1px solid #eef0f4; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; cursor: pointer; color: inherit; }
.mrow:hover { background: #fafafc; }
.mrow.th span { white-space: nowrap; }
.mrow.th { cursor: default; border-top: 0; font-size: 13px; color: var(--muted); padding-top: 0; }
.mrow.th:hover { background: none; }
.mrow .who b { display: block; font-size: 15px; }
.mrow .who span { font-size: 13px; color: var(--muted); }
.cl { display: flex; align-items: center; gap: 10px; }
.cl b { font-size: 20px; min-width: 2.2ch; }
.cl .bar { flex: 1; height: 8px; background: #eef0f4; border-radius: 99px; overflow: hidden; }
.cl .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.cl small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tag { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.trial { background: var(--accent-soft); color: #4a32c8; }
.tag.paid { background: var(--ok-soft); color: var(--ok); }
.tag.ended { background: var(--warn-soft); color: var(--warn); }
.tag.off { background: var(--bad-soft); color: var(--bad); }
.tag.grey { background: #eef0f4; color: #3a3f4b; }
.cell-k { display: none; }

/* ── таблиці ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 0 10px 10px 0; white-space: nowrap; }
td { padding: 11px 10px 11px 0; border-top: 1px solid #eef0f4; vertical-align: top; }
td.nowrap { white-space: nowrap; }
.st-pending { color: var(--warn); font-weight: 600; }
.st-confirmed, .st-completed, .st-sent { color: var(--ok); font-weight: 600; }
.st-cancelled, .st-declined, .st-no_show, .st-failed { color: var(--bad); font-weight: 600; }
.st-expired, .st-skipped, .st-silent { color: var(--muted); font-weight: 600; }

/* ── картка майстра ── */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); color: var(--text); }
dialog::backdrop { background: rgba(22, 24, 29, .55); }
.dlg { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.dlg-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dlg-head h2 { margin: 0; font-size: 21px; }
.x { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 20px; line-height: 1; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.facts div { background: var(--ground); border-radius: 10px; padding: 10px 12px; }
.facts b { display: block; font-size: 22px; }
.facts span { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.box h3 { margin: 0; font-size: 15px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #dcdfe6; background: var(--paper); cursor: pointer; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f1b4b0; }
.btn[disabled] { opacity: .5; cursor: default; }
.days { width: 90px; height: 44px; border: 1px solid #dcdfe6; border-radius: 10px; padding: 0 10px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 10; }
#toast.err { background: var(--bad); }

/* ── телефон ── */
@media (max-width: 980px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .mrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; padding: 14px 4px; }
  .mrow .who { grid-column: 1 / -1; }
  .mrow.th { display: none; }
  .cell-k { display: block; font-size: 12px; color: var(--muted); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 14px 16px; gap: 12px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .nav a { white-space: nowrap; flex: none; }
  .side-foot { flex-direction: row; justify-content: space-between; margin: 0; padding: 0; }
  main { padding: 20px 16px 40px; }
  .head h1 { font-size: 24px; }
  .lead { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .lead .panel { padding: 16px; }
  .lead .big { font-size: 40px; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .search { max-width: none; }
  .facts b { font-size: 18px; }
  .mrow:not(.th) > :nth-child(4), .mrow:not(.th) > :nth-child(6) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
