:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece6da;
  --border: #e2dbcc;
  --text: #211d17;
  --muted: #7c7364;
  --brand: #2a251e;
  --brand-ink: #f5edda;
  --gold: #a6813f;
  --ok: #5c7355;
  --warn: #a9793a;
  --danger: #9c4a30;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(40, 32, 20, .05), 0 10px 30px rgba(40, 32, 20, .07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110c;
    --surface: #1e1a13;
    --surface-2: #282016;
    --border: #33291c;
    --text: #efe7d6e6;
    --muted: #a89d87;
    --brand: #ece0c6;
    --brand-ink: #191510;
    --gold: #c9a05f;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 14px 34px rgba(0,0,0,.4);
  }
}
/* Explicit theme override (data-theme wins over prefers-color-scheme) */
:root[data-theme="light"] {
  --bg: #f4f1ea; --surface: #fffdf8; --surface-2: #ece6da; --border: #e2dbcc; --text: #211d17;
  --muted: #7c7364; --brand: #2a251e; --brand-ink: #f5edda; --gold: #a6813f;
  --shadow: 0 1px 2px rgba(40,32,20,.05), 0 10px 30px rgba(40,32,20,.07);
}
:root[data-theme="dark"] {
  --bg: #14110c; --surface: #1e1a13; --surface-2: #282016; --border: #33291c; --text: #efe7d6e6;
  --muted: #a89d87; --brand: #ece0c6; --brand-ink: #191510; --gold: #c9a05f;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 14px 34px rgba(0,0,0,.4);
}

/* Barber selection in the booking flow */
.barbers { display: flex; flex-direction: column; gap: 10px; }
.barber { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: .12s; }
.barber:hover { border-color: var(--gold); transform: translateY(-1px); }
.barber.sel { border-color: var(--gold); box-shadow: 0 0 0 1.5px var(--gold); }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; flex: 0 0 auto; letter-spacing: -.02em; }
.barber .bn { font-weight: 700; }
.barber .bt { color: var(--muted); font-size: 13px; margin-top: 1px; }
.barber .qm { margin-left: auto; position: relative; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.barber .qm .tip { position: absolute; bottom: 130%; right: -6px; width: 210px; background: var(--brand); color: var(--brand-ink); font-weight: 500; font-size: 12.5px; line-height: 1.45; padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(4px); transition: .14s; z-index: 5; text-align: left; }
.barber .qm:hover .tip { opacity: 1; transform: translateY(0); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.brandmark { font-weight: 800; letter-spacing: .01em; font-size: 20px; white-space: nowrap; }
.brandmark .wm > span { color: var(--gold); }
.brand-ico { width: 1.05em; height: 1.05em; color: var(--gold); vertical-align: -0.16em; margin-right: 7px; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.side .logo { padding: 6px 10px 18px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: var(--muted);
  font-weight: 600; font-size: 14px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand); color: var(--brand-ink); }
.side .spacer { flex: 1; }
.side .salon-tag { font-size: 12px; color: var(--muted); padding: 8px 12px; }
.side .salon-tag b { color: var(--text); display: block; font-size: 14px; }

.main { padding: 26px 30px; overflow: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Cards + stats */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card .k { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.card .v { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.card .v small { font-size: 15px; color: var(--muted); font-weight: 600; }

/* Buttons */
.btn { background: var(--brand); color: var(--brand-ink); border: none; padding: 9px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn:hover { filter: brightness(1.05); }

/* Agenda */
.agenda-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.agenda-head input[type=date] { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.agenda {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.agenda-grid { display: grid; }
.agenda-colhead { display: grid; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 3; }
.agenda-colhead .cell { padding: 12px 10px; font-weight: 700; font-size: 13.5px; border-left: 1px solid var(--border); }
.agenda-colhead .cell:first-child { border-left: none; }
.agenda-colhead .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.agenda-body { position: relative; display: grid; }
.time-col { border-right: 1px solid var(--border); }
.time-slot { height: 28px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; position: relative; }
.time-slot span { position: absolute; top: -7px; right: 8px; background: var(--surface); padding: 0 2px; }
.emp-col { border-left: 1px solid var(--border); position: relative; }
.emp-col .row-line { height: 28px; border-bottom: 1px dashed var(--border); }
.appt {
  position: absolute; left: 4px; right: 4px; border-radius: 9px; padding: 6px 9px; color: #fff;
  font-size: 12.5px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.18); cursor: pointer;
}
.appt .t { font-weight: 800; }
.appt .c { opacity: .95; }
.appt.done { opacity: .55; }
.appt .badge-online { position: absolute; top: 5px; right: 6px; font-size: 9px; background: rgba(255,255,255,.28); padding: 1px 5px; border-radius: 20px; font-weight: 700; }

/* Employee selector (mobile agenda: one employee at a time) */
.emp-tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; }
.emp-tab { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 8px 14px; border-radius: 22px; font-weight: 600; font-size: 13px; }
.emp-tab.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.emp-tab .dot { margin-right: 0; }

/* Table */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
th:first-child, td:first-child { white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.tablewrap { overflow-x: auto; border-radius: var(--radius); }
.daytoggle { display: flex; gap: 6px; flex-wrap: wrap; }
.daybtn { width: 40px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer; }
.daybtn.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.pill.online { background: rgba(166,129,63,.16); color: var(--gold); }
.pill.staff { background: var(--surface-2); color: var(--muted); }

/* Forms + modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,10,25,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: 420px; max-width: 92vw; box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal h3 { margin: 0 0 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 34px; width: 380px; box-shadow: var(--shadow); }
.login-card h2 { margin: 6px 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 20px; padding: 12px; }
.err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }
.demo-hint { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

.empty { color: var(--muted); text-align: center; padding: 40px; }
.hidden { display: none !important; }

/* Sidebar head + collapse toggle */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 18px; }
.side-head .logo { font-size: 17px; }
.side-head .mark-mini { display: none; font-size: 20px; text-align: center; }
.side-head .mark-mini .brand-ico { color: var(--gold); margin-right: 0; vertical-align: middle; }
.collapse-btn { background: none; border: none; color: var(--muted); padding: 6px; border-radius: 8px; display: flex; }
.collapse-btn:hover { background: var(--surface-2); color: var(--text); }
.collapse-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.nav-item .lbl { white-space: nowrap; }

.app.collapsed { grid-template-columns: 66px 1fr; }
.app.collapsed .side { padding: 20px 8px; }
.app.collapsed .lbl { display: none; }
.app.collapsed .salon-tag { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.app.collapsed .side-head { flex-direction: column; gap: 14px; padding: 6px 0 16px; }
.app.collapsed .side-head .logo { display: none; }
.app.collapsed .side-head .mark-mini { display: block; }

/* Charts + analytics */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card h3 { margin: 0 0 14px; font-size: 15px; letter-spacing: -.01em; }
.muted-p { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }

.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.hbar-l { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-t { background: var(--surface-2); border-radius: 6px; height: 12px; overflow: hidden; }
.hbar-t i { display: block; height: 100%; border-radius: 6px; }
.hbar-n { text-align: right; font-weight: 700; }

.vbars { display: flex; align-items: flex-end; gap: 12px; height: 170px; padding-top: 10px; }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.vbar-t { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.vbar-t i { display: block; width: 100%; background: var(--gold); border-radius: 6px 6px 0 0; min-height: 3px; opacity: .9; }
.vbar-l { font-size: 11px; color: var(--muted); margin-top: 8px; }

.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut { width: 150px; height: 150px; flex: 0 0 auto; }
.donut-c { fill: var(--text); font-size: 22px; font-weight: 800; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.legend .lg { display: flex; align-items: center; gap: 8px; text-transform: capitalize; }
.legend .lg i { width: 11px; height: 11px; border-radius: 3px; }
.legend b { color: var(--muted); font-weight: 600; }

@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* Mobile: force the icon rail, tighten spacing */
@media (max-width: 720px) {
  .app { grid-template-columns: 58px 1fr; }
  .app .lbl, .app .salon-tag { display: none; }
  .app .nav-item { justify-content: center; padding: 11px 0; }
  .app .side { padding: 16px 5px; }
  .app .side-head { flex-direction: column; gap: 12px; padding: 4px 0 14px; }
  .app .side-head .logo { display: none; }
  .app .side-head .mark-mini { display: block; }
  .main { padding: 16px 14px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar h1 { font-size: 20px; }

  /* Compact stat cards (2 across) */
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 13px 14px; }
  .card .v { font-size: 22px; }
  .donut-wrap { flex-direction: column; align-items: flex-start; gap: 14px; }
  .hbar { grid-template-columns: 96px 1fr 28px; }

  /* Tables scroll horizontally instead of squeezing/wrapping */
  .tablewrap table { min-width: 520px; }
  th, td { padding: 10px 12px; }

  /* Slide-out drawer: hamburger opens the labelled menu */
  .app.mobile-open { grid-template-columns: 212px 1fr; }
  .app.mobile-open .lbl { display: inline; }
  .app.mobile-open .salon-tag { display: block; }
  .app.mobile-open .nav-item { justify-content: flex-start; padding: 11px 12px; }
  .app.mobile-open .side { padding: 20px 14px; z-index: 40; }
  .app.mobile-open .side-head { flex-direction: row; gap: 8px; padding: 6px 4px 16px; }
  .app.mobile-open .side-head .logo { display: inline; }
  .app.mobile-open .side-head .mark-mini { display: none; }

  /* Agenda fits narrow columns without overlap */
  .agenda-head { flex-wrap: wrap; }
  .agenda-head input[type=date] { flex: 1 1 140px; min-width: 130px; }
  .agenda-colhead .cell { font-size: 12px; padding: 10px 6px; }
  .appt { font-size: 11.5px; padding: 5px 7px; }
  .appt .t { padding-right: 13px; }
  .appt .c { padding-right: 13px; }
  .appt .badge-online { font-size: 0; width: 9px; height: 9px; min-width: 0; padding: 0; line-height: 0; border-radius: 50%; top: 6px; right: 6px; background: rgba(255,255,255,.55); }
}
