/* Klikoni Panel — work tool for salon / clinic owners, used mostly on a phone between clients.
   Charcoal sidebar carries the Klikoni brand; content surfaces stay calm so status colours do the talking. */
:root {
  --bg: #F4F6F9; --surface: #FFFFFF; --surface-2: #F8F9FB; --ink: #0D1117; --muted: #5A6372; --line: #E1E5EB;
  --accent: #2563EB; --accent-ink: #FFFFFF; --accent-soft: #E7EEFD;
  --brand-ink: #0D1117; --brand-cyan: #00C0D1; --side-ink: #C9D1DD; --side-muted: #7D8899; --side-hover: #1A212C;
  --pending: #B45309; --pending-soft: #FDF0DC;
  --confirmed: #2563EB; --confirmed-soft: #E7EEFD;
  --completed: #15803D; --completed-soft: #E2F3E7;
  --noshow: #B91C1C; --noshow-soft: #FBE6E6;
  --cancelled: #6B7280; --cancelled-soft: #EEF0F3;
  --danger: #B91C1C;
  --shadow: 0 1px 2px rgba(13,17,23,.06), 0 8px 24px rgba(13,17,23,.06);
  --display: "Syne", "Avenir Next", system-ui, sans-serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0F15; --surface: #141A22; --surface-2: #10151C; --ink: #E6EAF0; --muted: #98A2B2; --line: #252D39;
    --accent: #5B8DF6; --accent-ink: #0B0F15; --accent-soft: #172442;
    --brand-ink: #070A0F; --side-hover: #141A23;
    --pending: #F2A93B; --pending-soft: #33260F;
    --confirmed: #6E9BF8; --confirmed-soft: #172442;
    --completed: #4ADE80; --completed-soft: #11301D;
    --noshow: #F87171; --noshow-soft: #3A1616;
    --cancelled: #8C95A3; --cancelled-soft: #1C222B;
    --danger: #F87171;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0B0F15; --surface: #141A22; --surface-2: #10151C; --ink: #E6EAF0; --muted: #98A2B2; --line: #252D39;
    --accent: #5B8DF6; --accent-ink: #0B0F15; --accent-soft: #172442;
    --brand-ink: #070A0F; --side-hover: #141A23;
    --pending: #F2A93B; --pending-soft: #33260F;
    --confirmed: #6E9BF8; --confirmed-soft: #172442;
    --completed: #4ADE80; --completed-soft: #11301D;
    --noshow: #F87171; --noshow-soft: #3A1616;
    --cancelled: #8C95A3; --cancelled-soft: #1C222B;
    --danger: #F87171;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.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: 13px; }
.boot { display: grid; place-items: center; min-height: 100vh; font-family: var(--display); font-weight: 800; color: var(--muted); }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
.ic { width: 20px; height: 20px; flex: none; }
.ic.inline { width: 16px; height: 16px; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn.sm .ic { width: 17px; height: 17px; }
.btn.block { width: 100%; }
.btn.armed { background: var(--noshow-soft); border-color: var(--noshow); color: var(--noshow); }
.btn:disabled { opacity: .6; cursor: progress; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn.sm { width: 34px; height: 34px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { background: var(--surface-2); color: var(--ink); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 6px 0; font-weight: 500; }
.link-strong { background: none; border: 0; padding: 0; font-weight: 600; cursor: pointer; color: var(--ink); text-align: left; }
.link-strong:hover { color: var(--accent); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .search input, .inline-form input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 16px; }
.field textarea { min-height: 72px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.code { letter-spacing: .4em; font-size: 24px !important; text-align: center; font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.grid-off { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; align-items: end; margin-block: 12px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--noshow-soft); color: var(--noshow); font-size: 14px; }
.form-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font-size: 14px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px));
  background: radial-gradient(120% 60% at 50% 0%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.auth-card h1 { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -.01em; }
.auth-card .muted { margin: 0; }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 17px; font-weight: 700; }
.brand b { font-weight: 800; color: var(--brand-cyan); }
.auth .brand b { color: var(--accent); }
.logo { width: 32px; height: 32px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.steps b { color: var(--ink); }
.qr { display: grid; justify-items: center; gap: 8px; padding: 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line); color: #0D1117; }
.qr .muted { color: #5A6372; }
.secret { font-size: 13px; word-break: break-all; text-align: center; letter-spacing: .08em; }

/* ---------- Layout ---------- */
.demo-bar { background: var(--pending-soft); color: var(--pending); text-align: center; font-size: 13px; font-weight: 600; padding: 6px 16px; }
.layout { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.side { display: none; }
.main { padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); max-width: 1200px; width: 100%; margin: 0 auto; outline: none; min-width: 0; }
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); }
.tabbar button { display: grid; justify-items: center; gap: 2px; min-height: 56px; padding: 6px 2px; border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; cursor: pointer; border-radius: 10px; }
.tabbar button[aria-current="page"] { color: var(--accent); }
.tabbar button[aria-current="page"] .ic { stroke-width: 2.2; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 240px 1fr; }
  .side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--brand-ink); color: var(--side-ink); }
  .side .brand { color: #fff; padding: 0 8px; }
  .tabbar { display: none; }
  .main { padding: 32px 40px 48px; }
}
.biz-name { padding: 10px 12px; border-radius: 10px; background: var(--side-hover); color: #fff; font-weight: 600; font-size: 14px; }
.biz-switch select { width: 100%; min-height: 42px; padding: 0 10px; border-radius: 10px; border: 1px solid #2A3341; background: var(--side-hover); color: #fff; }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 0;
  background: none; color: var(--side-ink); font-weight: 500; cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item[aria-current="page"], .nav-item[aria-current="true"] { background: var(--side-hover); color: #fff; box-shadow: inset 3px 0 0 var(--brand-cyan); }
.side-foot { margin-top: auto; display: grid; gap: 4px; border-top: 1px solid #1E2631; padding-top: 12px; }
.who { font-size: 12px; color: var(--side-muted); padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { font-family: var(--display); font-weight: 800; font-size: clamp(26px, 4vw, 32px); letter-spacing: -.015em; }
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.block { margin-top: 24px; display: grid; gap: 12px; min-width: 0; }
.card-pad { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.block-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.block-title .count { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--pending-soft); color: var(--pending); }
.loading { padding: 40px 0; color: var(--muted); }
.empty { display: grid; justify-items: start; gap: 10px; padding: 22px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty p { margin: 0; }
.actions-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi b { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi b.kpi-text { font-size: 16px; line-height: 1.35; padding-top: 4px; overflow-wrap: anywhere; }
.kpi.warn { border-color: var(--pending); background: var(--pending-soft); }
.kpi.warn span, .kpi.warn b { color: var(--pending); }
.delta { font-size: 12px; color: var(--muted); }
.delta.up { color: var(--completed); }
.delta.down { color: var(--noshow); }

/* Status pills */
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.st-pending   { --c: var(--pending);   --cs: var(--pending-soft); }
.st-confirmed { --c: var(--confirmed); --cs: var(--confirmed-soft); }
.st-completed { --c: var(--completed); --cs: var(--completed-soft); }
.st-noshow    { --c: var(--noshow);    --cs: var(--noshow-soft); }
.st-cancelled { --c: var(--cancelled); --cs: var(--cancelled-soft); }
.pill { background: var(--cs); color: var(--c); }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }

/* Booking cards */
.cards { display: grid; gap: 10px; }
.bcard { display: grid; grid-template-columns: 64px 1fr; gap: 6px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.bcard.is-muted { opacity: .62; }
.bcard-time { display: grid; align-content: start; font-variant-numeric: tabular-nums; }
.bcard-time b { font-size: 18px; }
.bcard-time span { font-size: 12px; color: var(--muted); }
.bcard-time .bdate { color: var(--pending); font-weight: 700; }
.bcard-main { min-width: 0; }
.bcard-name { background: none; border: 0; padding: 0; font-weight: 700; font-size: 16px; cursor: pointer; text-align: left; color: var(--ink); }
.bcard-name:hover { color: var(--accent); }
.bcard-meta { color: var(--muted); font-size: 14px; }
.bcard-note { margin-top: 4px; font-size: 13px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.bcard-side { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.bcard-actions { display: flex; flex-wrap: wrap; gap: 6px; }
@media (min-width: 720px) {
  .bcard { grid-template-columns: 72px 1fr auto; align-items: center; }
  .bcard-side { grid-column: auto; justify-content: flex-end; }
}

/* Week */
.week { display: grid; gap: 10px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-width: 0; }
.day.is-today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dname { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dnum { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.day.is-today .dnum { color: var(--accent); }
.dcount { font-size: 12px; color: var(--muted); margin-left: auto; }
.day-items { display: grid; gap: 6px; }
.day-empty { margin: 0; font-size: 13px; color: var(--muted); }
.slot { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; text-align: left; padding: 8px 10px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--cs); color: var(--ink); min-height: 44px; }
.slot-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c); font-size: 13px; }
.slot-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-svc { grid-column: 2; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.st-cancelled { text-decoration: line-through; opacity: .7; }
@media (min-width: 1100px) {
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
  .day { padding: 8px; min-height: 340px; }
  .slot { grid-template-columns: 1fr; padding: 7px 8px; }
  .slot-svc { grid-column: 1; }
}
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.lg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 6px; vertical-align: -1px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table thead th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table .num { text-align: right; }
.table tr.is-muted td { color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; position: relative; margin-bottom: 12px; }
.search .ic { position: absolute; left: 12px; color: var(--muted); }
.search input { padding-left: 40px; }
.inline-form { display: flex; gap: 6px; min-width: 240px; }
.inline-form input { min-height: 40px; font-size: 14px; }

/* Hours */
.hours { display: grid; }
.hrow { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hrow:last-child { border-bottom: 0; }
.day-toggle span { font-weight: 600; }
.ranges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.range { display: flex; align-items: center; gap: 6px; }
.range select { min-height: 42px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-variant-numeric: tabular-nums; }
@media (min-width: 720px) { .hrow { grid-template-columns: 180px 1fr; align-items: center; } }

/* Stats chart */
.chart-wrap { overflow-x: auto; }
.chart-wrap svg { width: 100%; min-width: 520px; height: auto; display: block; }
.chart-wrap .grid { stroke: var(--line); }
.chart-wrap .axis { font-size: 11px; fill: var(--muted); font-family: var(--body); }
.chart-wrap .val { font-size: 11px; fill: var(--ink); font-weight: 700; font-family: var(--body); }
.chart-wrap .bar { fill: var(--muted); opacity: .45; }
.chart-wrap .bar.today { fill: var(--accent); opacity: 1; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Settings, lists */
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.copy-row code { flex: 1 1 260px; min-width: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; display: grid; }
.history li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.history li > span:first-child { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 130px; }
.block > .history { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; }
.sub { font-size: 14px; font-weight: 700; margin-top: 8px; }
.menu-list { display: grid; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; }
.menu-item span { flex: 1; display: grid; }
.menu-item small { color: var(--muted); font-size: 13px; }
.menu-item > .ic:first-child { color: var(--accent); }

/* Modal */
.modal { width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(0,0,0,.25); }
.modal.wide { width: min(760px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(9,12,17,.55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 0 20px; position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 12px 20px 20px; display: grid; gap: 14px; }
.detail-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; }
.big { font-size: 20px; font-weight: 700; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.mini-stats b { color: var(--ink); }
@media (max-width: 600px) {
  .modal { width: 100%; max-width: 100%; max-height: 92%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); transition: opacity .3s, transform .3s; }
.toast.err { background: var(--noshow); color: #fff; }
.toast.out { opacity: 0; transform: translate(-50%, 8px); }
@media (min-width: 900px) { .toast { bottom: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.nowrap { white-space: nowrap; }
@media (max-width: 700px) {
  .table .hide-sm { display: none; }
  .table th, .table td { padding: 12px 10px; }
}
