:root {
  --cream: #F8F4EE;
  --sand: #EDE6DA;
  --white: #FFFFFF;
  --gold: #9A6F35;
  --gold-light: #C9A96E;
  --gold-soft: #E8DCC4;
  --text-primary: #111111;
  --text-secondary: #555555;
  --text-muted: #8A8A8A;
  --border: #E5DED1;
  --bg: #F8F4EE;
  --surface: #FFFFFF;
  --surface-2: #FAF6EF;
  --success: #4A7C59;
  --warning: #C9802E;
  --danger: #B0413E;
  --info: #4A6FA5;
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Jost', 'Helvetica Neue', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(60, 40, 10, 0.06);
  --shadow-lg: 0 12px 32px rgba(60, 40, 10, 0.12);
  --sidebar-w: 240px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --cream: #1a1714;
  --sand: #221d18;
  --white: #2a241e;
  --bg: #1a1714;
  --surface: #221d18;
  --surface-2: #2a241e;
  --border: #3a322a;
  --text-primary: #F2EAD8;
  --text-secondary: #C8BFAE;
  --text-muted: #8A8073;
  --gold-soft: #4a3a22;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 500; line-height: 1.2; letter-spacing: 0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; font-family: var(--font-body); font-weight: 600; }

a { color: var(--gold); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(154, 111, 53, 0.12); }

#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
  transition: transform 0.25s;
}
.brand {
  padding: 20px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: var(--font-heading); font-size: 1.3rem; font-weight: 600;
  box-shadow: var(--shadow);
}
.brand-name { font-family: var(--font-heading); font-size: 1.4rem; font-weight: 600; line-height: 1; color: var(--gold); }
.brand-sub { font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }

.nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section { font-size: 0.65rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-muted); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.nav-item .ico { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; }
.nav-item .count { margin-left: auto; font-size: 0.7rem; background: var(--border); padding: 2px 6px; border-radius: 10px; color: var(--text-secondary); }
.nav-item.active .count { background: var(--gold); color: white; }

.user { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem;
}
.user-name { font-weight: 600; font-size: 0.85rem; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ── Main ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.search { flex: 1; max-width: 420px; }
.search input { background: var(--surface-2); border-color: transparent; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); position: relative; font-size: 1rem;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--danger); color: white;
  font-size: 0.6rem; padding: 1px 5px; border-radius: 8px; font-weight: 600;
}
.date-chip { padding: 6px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 0.8rem; color: var(--text-secondary); }

.view { flex: 1; padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── Page header ── */
.page-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-head h1 { color: var(--text-primary); }
.page-head .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 500;
  font-size: 0.85rem; letter-spacing: 0.02em;
  border: 1px solid transparent; transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--gold); color: white; }
.btn-primary:hover { background: #876030; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--gold-light); }
.btn-ghost { color: var(--text-secondary); padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }

/* ── Cards & grid ── */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 500; color: var(--text-primary); }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); }
.kpi-value { font-family: var(--font-heading); font-size: 2.1rem; font-weight: 500; color: var(--text-primary); line-height: 1.1; }
.kpi-trend { font-size: 0.8rem; display: inline-flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}

/* ── Table ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface-2); padding: 12px 16px;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); font-weight: 600; text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-2); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; }
.pill-success { background: rgba(74, 124, 89, 0.15); color: var(--success); }
.pill-warning { background: rgba(201, 128, 46, 0.15); color: var(--warning); }
.pill-danger { background: rgba(176, 65, 62, 0.15); color: var(--danger); }
.pill-info { background: rgba(74, 111, 165, 0.15); color: var(--info); }
.pill-neutral { background: var(--surface-2); color: var(--text-secondary); }
.pill-gold { background: var(--gold-soft); color: var(--gold); }

.row { display: flex; gap: 12px; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); color: var(--text-secondary); }

/* ── Forms ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-row.single { grid-template-columns: 1fr; }
label { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }

/* ── Modal ── */
.modal-root { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 15, 10, 0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; pointer-events: all;
  animation: fadeIn 0.18s;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  max-width: 540px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s;
}
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ── Toast ── */
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold);
  padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: 0.85rem; pointer-events: all; min-width: 240px;
  animation: slideIn 0.25s;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Calendar/schedule ── */
.schedule-grid {
  display: grid;
  grid-template-columns: 80px repeat(var(--staff-count, 4), 1fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.sched-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 40px; padding: 4px; font-size: 0.8rem; position: relative; }
.sched-cell:last-child { border-right: none; }
.sched-header { background: var(--surface-2); font-weight: 600; padding: 10px 6px; text-align: center; border-bottom: 1px solid var(--border); }
.sched-time { background: var(--surface-2); padding: 6px 8px; font-size: 0.75rem; color: var(--text-muted); text-align: right; }
.appointment {
  background: var(--gold-soft); color: var(--gold);
  padding: 4px 6px; border-radius: 4px; font-size: 0.72rem; font-weight: 600;
  border-left: 3px solid var(--gold); margin-bottom: 2px; cursor: pointer;
}
.appointment.medspa { background: rgba(74, 111, 165, 0.12); color: var(--info); border-left-color: var(--info); }
.appointment.hair { background: rgba(74, 124, 89, 0.12); color: var(--success); border-left-color: var(--success); }
.appointment.complete { opacity: 0.6; }

/* ── Service browse ── */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.service-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: transform 0.15s, box-shadow 0.15s; cursor: pointer; }
.service-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--gold-light); }
.service-card .price { font-family: var(--font-heading); font-size: 1.6rem; color: var(--gold); font-weight: 500; }
.service-card .duration { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: all 0.15s; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── Progress ── */
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--gold); transition: width 0.4s; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ── Activity feed ── */
.activity { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.9rem; }
.activity-text { flex: 1; font-size: 0.85rem; }
.activity-time { font-size: 0.72rem; color: var(--text-muted); }

/* ── Loyalty tier visual ── */
.tier-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; }
.tier-bronze { background: rgba(180, 100, 50, 0.15); color: #B46432; }
.tier-silver { background: rgba(150, 150, 160, 0.15); color: #808088; }
.tier-gold { background: var(--gold-soft); color: var(--gold); }
.tier-platinum { background: linear-gradient(135deg, #e5e4e2, #c8c8c8); color: #333; }

/* ── Compose ── */
.compose-area { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.compose-area textarea { min-height: 100px; border: none; padding: 0; resize: vertical; }
.compose-area textarea:focus { box-shadow: none; }

.platform-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; background: var(--surface-2); cursor: pointer; user-select: none; border: 1px solid var(--border); }
.platform-pill.selected { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-light); }

/* ── Drawer / client detail ── */
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); }

/* Stock level visual */
.stock-level { display: flex; align-items: center; gap: 8px; }
.stock-level .bar { width: 60px; }

/* Empty state */
.empty {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }

/* Chart container */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }

/* Responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  :root { --sidebar-w: 220px; }
  .sidebar { position: fixed; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .view { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .date-chip { display: none; }
}
