:root {
  --bg: #0f1117;
  --panel: #1a1d29;
  --panel-2: #232735;
  --border: #2c3142;
  --text: #e7e9f0;
  --muted: #9aa0b4;
  --accent: #a855f7;
  --accent-2: #7c3aed;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #241a3a 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button { font-family: inherit; }
.btn {
  background: var(--accent-2); color: #fff; border: none; padding: 10px 16px;
  border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 14px;
  transition: transform .05s ease, background .15s ease;
}
.btn:hover { background: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: var(--bad); }
.btn.good { background: var(--good); }
input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: transparent; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 600; letter-spacing: .02em; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.booked { background: #1e3a8a33; color: #93c5fd; }
.pill.completed { background: #14532d44; color: #86efac; }
.pill.cancelled { background: #44141433; color: #fca5a5; }
.pill.no_show { background: #78350f44; color: #fcd34d; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }

/* ---- Auth ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; }

/* ---- App shell ---- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: rgba(16,18,26,.7); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-2); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; }
.main { padding: 24px 28px; overflow: auto; max-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: var(--panel-2); }
.clickable { cursor: pointer; }

/* ---- Calendar ---- */
.cal-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stylist-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stylist-col h3 { margin: 0; padding: 12px 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.appt { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.appt:hover { background: var(--panel-2); }
.appt .t { font-weight: 700; font-size: 14px; }
.appt .who { font-size: 13px; }
.appt .svc { font-size: 12px; color: var(--muted); }
.empty { padding: 18px 14px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---- Stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 6px; }

/* ---- Modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; }
.toast.err { border-color: var(--bad); }
.toast.ok { border-color: var(--good); }

.hide { display: none !important; }
.slot-btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.slot-btn:hover { background: var(--accent-2); border-color: transparent; }
.slot-btn.active { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 0 0 2px var(--accent-2) inset; }
#m_slots { max-height: 168px; overflow-y: auto; padding: 2px; }

/* ---- month calendar ---- */
.cal { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 8px; font-size: 15px; }
.cal-nav { background: none; border: none; color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 12px; border-radius: 8px; }
.cal-nav:hover { background: var(--panel); }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-dow div { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; font-size: 13px; cursor: pointer; border: 1px solid transparent; }
.cal-cell:hover:not(.empty) { background: var(--panel); }
.cal-cell.empty { cursor: default; }
.cal-cell.past { color: var(--muted); }
.cal-cell.today { border-color: var(--accent-2); font-weight: 700; }
.cal-cell.sel { background: var(--accent); color: #fff; font-weight: 700; }
.cal-cell.sel.today { border-color: #fff; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px,1fr)); gap: 8px; }

@media (max-width: 720px) {
  body { background: var(--bg); }
  .app { grid-template-columns: 1fr; }

  /* Sidebar becomes a fixed bottom tab bar */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    flex-direction: row; gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: none; border-top: 1px solid var(--border);
    background: rgba(16, 18, 26, .97); backdrop-filter: blur(10px);
    overflow-x: auto; -webkit-overflow-scrolling: touch; z-index: 40;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand, .sidebar .spacer { display: none; }
  .nav-item {
    flex: 0 0 auto; flex-direction: column; gap: 3px;
    padding: 6px 12px; border-radius: 10px; white-space: nowrap;
  }
  .nav-item .ico { width: auto; font-size: 19px; }
  .nav-item span.lbl { display: inline; font-size: 10px; font-weight: 600; }

  /* Main content scrolls with the page; clear the bottom bar */
  .main { max-height: none; overflow: visible; padding: 14px 14px 88px; }
  .topbar { margin-bottom: 16px; }
  .topbar h1 { font-size: 20px; }

  /* Stack form rows; let tables scroll sideways inside their card */
  .row { flex-direction: column; gap: 0; }
  .main .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 10px; white-space: nowrap; }

  /* Modals act like bottom sheets */
  .modal-bg { place-items: end center; padding: 0; }
  .modal {
    max-width: 100%; max-height: 92vh; width: 100%;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .auth-card { max-width: 100%; }

  /* Bigger tap targets */
  .slot-btn { padding: 11px 8px; }
  .cal-cell { font-size: 15px; }
  input, select, textarea { font-size: 16px; }  /* avoids iOS zoom-on-focus */
}
