/* Podology MK CRM v2 — design system. Light professional theme by default. */

:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface2: #efece7;
  --border: #e3ded6;
  --accent: #8a6d3f;
  --accent-strong: #6f5530;
  --accent-dim: rgba(138, 109, 63, 0.10);
  --text: #231f1a;
  --text-dim: #6f6760;
  --text-muted: #a9a198;
  --success: #2e7d5b;
  --success-bg: #e3f2eb;
  --danger: #b3403f;
  --danger-bg: #f7e6e6;
  --warning: #b97d18;
  --warning-bg: #f8efdd;
  --info: #2f6fa7;
  --info-bg: #e5eef6;
  --owner: #5b4bb5;
  --owner-bg: #ece9f8;
  --tg: #2aabee;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(35, 31, 26, 0.06), 0 4px 16px rgba(35, 31, 26, 0.05);
  --font-display: 'Cormorant Garamond', serif;
  --font-body: 'Jost', sans-serif;
  --nav-h: 64px;
  --header-h: 56px;
}

body.dark {
  --bg: #0f0e0c;
  --surface: #1a1916;
  --surface2: #242220;
  --border: #2e2c29;
  --accent: #c9a96e;
  --accent-strong: #d9bd88;
  --accent-dim: rgba(201, 169, 110, 0.15);
  --text: #f0ebe3;
  --text-dim: #8a8278;
  --text-muted: #5a564f;
  --success: #6eb89a;
  --success-bg: rgba(110, 184, 154, 0.14);
  --danger: #c96e6e;
  --danger-bg: rgba(201, 110, 110, 0.14);
  --warning: #d49a3a;
  --warning-bg: rgba(212, 154, 58, 0.14);
  --info: #6ea3cf;
  --info-bg: rgba(110, 163, 207, 0.14);
  --owner: #9a8ce3;
  --owner-bg: rgba(154, 140, 227, 0.14);
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body.simple { font-size: 115%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-weight: 600; }
.font-display { font-family: var(--font-display); }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  height: var(--header-h); padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header .logo {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 700;
  letter-spacing: 0.02em; flex: 1; text-align: center;
}
.header .logo small { display: block; font-family: var(--font-body); font-size: 0.62rem; font-weight: 400; color: var(--text-dim); letter-spacing: 0.22em; text-transform: uppercase; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:active { background: var(--surface2); }
.role-chip {
  font-size: 0.7rem; font-weight: 500; padding: 3px 9px; border-radius: 99px;
  background: var(--accent-dim); color: var(--accent-strong); white-space: nowrap;
}
.role-chip.owner { background: var(--owner-bg); color: var(--owner); }

/* ---------- Screens & transitions ---------- */
#app { max-width: 560px; margin: 0 auto; padding: 14px 14px 0; }
.screen { display: none; animation: screenIn 0.18s ease-out; }
.screen.active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen, .sheet, .toast { animation: none !important; transition: none !important; }
}

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-muted); font-size: 0.68rem; font-weight: 500;
  transition: color 0.15s; max-width: 120px;
}
.nav-btn svg { width: 23px; height: 23px; }
.nav-btn.active { color: var(--accent-strong); }
.nav-btn.active svg { stroke-width: 2.2; }
body.dark .nav-btn.active { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); width: auto;
  transition: transform 0.08s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-strong); }
.btn-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-lg { min-height: 52px; font-size: 1.05rem; width: 100%; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 0.82rem; border-radius: var(--radius-sm); }
body.simple .btn-lg { min-height: 60px; font-size: 1.15rem; }

/* ---------- Cards & lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-title { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 500; font-size: 0.97rem; }
.list-row .sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Pills & statuses ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 500; padding: 3px 10px; border-radius: 99px;
  background: var(--surface2); color: var(--text-dim); white-space: nowrap;
}
.status-pill { font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.status-pill[data-status="new"] { background: var(--warning-bg); color: var(--warning); }
.status-pill[data-status="confirmed"] { background: var(--info-bg); color: var(--info); }
.status-pill[data-status="arrived"], .status-pill[data-status="in_progress"] { background: var(--accent-dim); color: var(--accent-strong); }
.status-pill[data-status="done"], .status-pill[data-status="paid"], .status-pill[data-status="confirmed_pay"] { background: var(--success-bg); color: var(--success); }
.status-pill[data-status="cancelled"], .status-pill[data-status="no_show"], .status-pill[data-status="reversed"], .status-pill[data-status="rejected"] { background: var(--danger-bg); color: var(--danger); }
.status-pill[data-status="accrued"], .status-pill[data-status="pending"], .status-pill[data-status="open"] { background: var(--warning-bg); color: var(--warning); }

/* ---------- Segmented control & tabs ---------- */
.seg { display: flex; background: var(--surface2); border-radius: var(--radius); padding: 4px; gap: 4px; }
.seg-btn {
  flex: 1; min-height: 38px; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 500;
  color: var(--text-dim); transition: background 0.15s, color 0.15s;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 16px; border-radius: 99px; font-size: 0.85rem; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); white-space: nowrap;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--text-dim); margin-bottom: 5px; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color 0.15s;
}
.field textarea { min-height: 70px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field .hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.field.error input, .field.error select { border-color: var(--danger); }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat-label { font-size: 0.7rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); }
.stat-value { font-size: 1.45rem; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }
.stat-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
body.simple .stat-value { font-size: 1.7rem; }

/* ---------- Empty state, skeleton ---------- */
.empty { text-align: center; padding: 38px 20px; color: var(--text-muted); }
.empty .emoji { font-size: 2.2rem; margin-bottom: 10px; }
.empty .text { font-size: 0.9rem; }
.skeleton {
  border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; min-height: 18px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Bottom sheet (modal) ---------- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(20, 16, 10, 0.45); animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 14px; }
.sheet h3 { font-size: 1.1rem; margin-bottom: 14px; }
@media (min-width: 560px) { .sheet { border-radius: 22px; margin-bottom: 5vh; } .sheet-overlay { align-items: center; } }

/* ---------- Toast & success banner ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 22px); transform: translateX(-50%) translateY(16px);
  z-index: 200; max-width: 90vw; padding: 11px 20px; border-radius: 99px;
  background: var(--text); color: var(--bg); font-size: 0.88rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.celebrate-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 12px;
  background: var(--success-bg); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
  border-radius: var(--radius); color: var(--success); font-weight: 500;
  animation: bannerPop 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes bannerPop { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
.celebrate-banner .check {
  width: 30px; height: 30px; border-radius: 50%; background: var(--success); color: #fff; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}

/* ---------- Booking widgets ---------- */
.date-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.date-strip::-webkit-scrollbar { display: none; }
.date-item {
  flex: 0 0 56px; text-align: center; padding: 9px 0; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); transition: background 0.12s;
}
.date-item .dow { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.date-item .num { font-size: 1.12rem; font-weight: 600; margin-top: 2px; }
.date-item.selected { background: var(--accent); border-color: var(--accent); }
.date-item.selected .dow, .date-item.selected .num { color: #fff; }
.date-item.weekend .dow { color: var(--danger); }
.time-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.time-slot {
  min-height: 42px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.time-slot.booked { color: var(--text-muted); text-decoration: line-through; background: var(--surface2); pointer-events: none; }
.time-slot.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-steps { display: flex; gap: 5px; margin-bottom: 14px; }
.wizard-steps .step { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.wizard-steps .step.done { background: var(--accent); }

/* ---------- Chat (Aigerim) ---------- */
.chat-shell { position: relative; }
.chat-hero {
  position: relative; overflow: hidden; border-radius: var(--radius);
  padding: 18px 16px; margin-bottom: 12px; border: 1px solid var(--border);
}
.chat-hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chat-hero .inner { position: relative; }
.chat-log { display: flex; flex-direction: column; gap: 8px; min-height: 200px; padding-bottom: 8px; }
.chat-bubble {
  max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: 0.93rem; line-height: 1.42;
  white-space: pre-wrap; word-wrap: break-word; animation: screenIn 0.15s ease-out;
}
.chat-bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.chat-bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.chat-bubble.typing { color: var(--text-muted); font-style: italic; }
.chat-input-bar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 6px);
  display: flex; gap: 8px; padding: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
}
.chat-input-bar input { flex: 1; border: none; outline: none; background: transparent; padding: 8px 6px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 14px; border-radius: 99px; font-size: 0.8rem; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); }

/* ---------- Charts (dependency-free bars) ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bar-chart .bar .fill { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--accent); min-height: 2px; transition: height 0.4s ease; }
.bar-chart .bar .lbl { font-size: 0.62rem; color: var(--text-muted); }
.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface2); }
.split-bar .a { background: var(--accent); }
.split-bar .b { background: var(--info); }
.progress { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.progress .fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s ease; }

/* ---------- Formula rows (owner P&L) ---------- */
.formula-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.formula-row:last-child { border-bottom: none; }
.formula-row .name { color: var(--text-dim); font-size: 0.88rem; }
.formula-row .val { font-weight: 500; }
.formula-row.total { border-top: 2px solid var(--text); padding-top: 10px; }
.formula-row.total .name, .formula-row.total .val { font-weight: 600; font-size: 1.05rem; color: var(--text); }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.muted { color: var(--text-dim); font-size: 0.85rem; }
.small { font-size: 0.78rem; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.right { text-align: right; }
.center { text-align: center; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 22px); z-index: 55;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 1.6rem; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(35, 31, 26, 0.25);
}
body.simple .advanced { display: none !important; }
.consent-backdrop { z-index: 300; }

/* Burger menu sheet items */
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 6px; border-bottom: 1px solid var(--border); font-size: 0.97rem; text-align: left; }
.menu-item:last-child { border-bottom: none; }
.menu-item .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--surface2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
