:root {
  --brand: #7c3aed;
  --brand-dark: #5b21b6;
  --brand-soft: #f3e8ff;
  --sidebar-w: 250px;
  --bs-primary: #7c3aed;
  --bs-primary-rgb: 124, 58, 237;
  --bs-link-color: #7c3aed;
  --bs-link-color-rgb: 124, 58, 237;
  --bs-link-hover-color: #5b21b6;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-bg: #f6f5fb;
}
body { font-size: .925rem; -webkit-tap-highlight-color: transparent; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.text-primary { color: var(--brand) !important; }
.bg-primary { background-color: var(--brand) !important; }
.text-bg-primary { background-color: var(--brand) !important; }
.bg-primary-subtle { background-color: var(--brand-soft) !important; }
.form-control:focus, .form-select:focus { border-color: #c4b5fd; box-shadow: 0 0 0 .2rem rgba(124, 58, 237, .15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.nav-pills .nav-link.active { background: var(--brand); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.card { border: 0; border-radius: 14px; box-shadow: 0 1px 3px rgba(17, 12, 46, .06); }
.card-header { background: transparent; border-bottom: 1px solid #eee; font-weight: 600; padding: .85rem 1rem; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .75rem; vertical-align: middle; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; font-weight: 600; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.cursor-pointer { cursor: pointer; }

/* ---------- Sidebar layout ---------- */
.sidebar { background: linear-gradient(180deg, #2e1065, #4c1d95); color: #ddd6fe; width: var(--sidebar-w); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand a { color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.sidebar-nav { padding: .5rem .6rem 1rem; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: .9rem .75rem .3rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: #ddd6fe; padding: .55rem .75rem; border-radius: 10px; font-size: .9rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: #fff; color: var(--brand-dark); font-weight: 600; }
.sidebar-plan { padding: .9rem 1.1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1030; }
  .main { margin-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; --bs-offcanvas-bg: #3b0f7a; }
  .sidebar .offcanvas-body, .sidebar { display: flex; flex-direction: column; }
}
.topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid #ece9f5; display: flex; align-items: center; padding: .6rem 1rem; min-height: 58px; }
.topbar-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.content { padding: 1.25rem; max-width: 1600px; }
@media (max-width: 575.98px) { .content { padding: .85rem; } }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; flex-shrink: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

/* ---------- Components ---------- */
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-label { font-size: .78rem; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.35rem; font-weight: 700; }
.empty-state { text-align: center; color: #9ca3af; padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .form-control, .toolbar .form-select { width: auto; flex: 1 1 160px; max-width: 260px; }
@media (max-width: 575.98px) { .toolbar .form-control, .toolbar .form-select { max-width: none; flex-basis: 100%; } .toolbar .btn { flex: 1 1 auto; } }
.pipeline { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; }
.pipeline-col { flex: 0 0 270px; scroll-snap-align: start; background: #efecf8; border-radius: 12px; padding: .6rem; }
.pipeline-col h6 { font-size: .8rem; text-transform: uppercase; display: flex; justify-content: space-between; margin: .25rem .25rem .6rem; }
.pipeline-card { background: #fff; border-radius: 10px; padding: .65rem .75rem; margin-bottom: .5rem; box-shadow: 0 1px 2px rgba(0,0,0,.05); display: block; color: inherit; text-decoration: none; }
.status-steps { display: flex; flex-wrap: wrap; gap: .35rem; }
.status-steps .step { font-size: .75rem; padding: .25rem .6rem; border-radius: 20px; background: #eee; color: #666; }
.status-steps .step.done { background: #dcfce7; color: #166534; }
.status-steps .step.current { background: var(--brand); color: #fff; }
.map-box { height: 320px; border-radius: 12px; overflow: hidden; z-index: 0; }
@media (max-width: 575.98px) { .map-box { height: 260px; } }
.sig-pad { width: 100%; height: 180px; border: 2px dashed #c4b5fd; border-radius: 12px; background: #fff; touch-action: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .5rem; }
.slot-grid .btn { font-size: .85rem; padding: .45rem .25rem; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Staff calendar grid */
.cal-wrap { overflow: auto; max-height: 75vh; border-radius: 12px; background: #fff; }
.cal-grid { display: grid; min-width: max-content; position: relative; }
.cal-head { position: sticky; top: 0; z-index: 3; background: #faf9ff; border-bottom: 1px solid #eee; padding: .5rem; font-weight: 600; font-size: .85rem; text-align: center; min-width: 150px; }
.cal-time { position: sticky; left: 0; z-index: 2; background: #faf9ff; font-size: .72rem; color: #888; padding: 0 .4rem; border-right: 1px solid #eee; width: 62px; }
.cal-col { position: relative; border-right: 1px solid #f1f1f1; min-width: 150px; }
.cal-slot { border-bottom: 1px dashed #f0f0f0; }
.cal-event { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 3px 6px; font-size: .72rem; color: #fff; overflow: hidden; line-height: 1.25; text-decoration: none; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.cal-event:hover { color: #fff; filter: brightness(1.08); }
.cal-off { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #f8f8f8, #f8f8f8 8px, #f0f0f0 8px, #f0f0f0 16px); display: flex; align-items: center; justify-content: center; color: #999; font-size: .8rem; }

/* ---------- Responsive tables -> cards ---------- */
@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { background: #fff; border-radius: 12px; margin-bottom: .65rem; padding: .5rem .25rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); border: 0; }
  .table-cards td { border: 0 !important; padding: .3rem .75rem !important; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table-cards td::before { content: attr(data-label); font-weight: 600; color: #6b7280; font-size: .78rem; text-align: left; flex-shrink: 0; }
  .table-cards td[data-label=""]::before, .table-cards td:not([data-label])::before { content: none; }
  .table-cards td.td-actions { justify-content: flex-end; }
  .card:has(> .table-responsive > .table-cards), .card:has(> .table-cards) { background: transparent; box-shadow: none; }
  .table-responsive:has(.table-cards) { overflow: visible; }
}

/* ---------- Mobile app shell (staff & customer) ---------- */
.layout-mobile { background: #f6f5fb; }
.m-wrap { max-width: 720px; margin: 0 auto; width: 100%; }
.m-topbar { position: sticky; top: 0; z-index: 1020; background: var(--brand); color: #fff; padding: .7rem 1rem; padding-top: calc(.7rem + env(safe-area-inset-top)); }
.theme-customer .m-topbar { background: linear-gradient(135deg, #7c3aed, #db2777); }
.m-brand { font-size: .72rem; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.m-title { font-weight: 700; font-size: 1.1rem; }
.m-icon-btn { color: #fff; font-size: 1.3rem; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; text-decoration: none; }
.m-icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.m-content { padding: 1rem; }
.has-tabs .m-content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.m-tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: #fff; border-top: 1px solid #eee; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(0,0,0,.04); }
.m-tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: .5rem 0 .45rem; font-size: .7rem; color: #8b8b9a; text-decoration: none; }
.m-tabbar a i { font-size: 1.3rem; line-height: 1.1; }
.m-tabbar a.active { color: var(--brand); font-weight: 600; }
.m-card { background: #fff; border-radius: 14px; padding: 1rem; margin-bottom: .85rem; box-shadow: 0 1px 3px rgba(17,12,46,.06); }
.m-list-item { display: flex; gap: .75rem; align-items: center; background: #fff; border-radius: 14px; padding: .85rem; margin-bottom: .6rem; color: inherit; text-decoration: none; box-shadow: 0 1px 3px rgba(17,12,46,.06); }
.m-list-item:hover { color: inherit; }
.time-pill { background: var(--brand-soft); color: var(--brand-dark); border-radius: 10px; padding: .4rem .55rem; text-align: center; font-weight: 700; font-size: .85rem; min-width: 64px; line-height: 1.2; }
.btn-xl { padding: .85rem 1rem; font-size: 1rem; border-radius: 12px; font-weight: 600; }
.service-pick { display: flex; gap: .75rem; align-items: flex-start; background: #fff; border: 2px solid transparent; border-radius: 12px; padding: .8rem; margin-bottom: .5rem; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.service-pick:has(input:checked) { border-color: var(--brand); background: #faf5ff; }
.sticky-cta { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 10; }
.no-tabs-cta { bottom: 12px; }

/* ---------- Auth & landing ---------- */
.layout-auth { background: linear-gradient(135deg, #ede9fe, #fce7f3); min-height: 100vh; }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 2.5rem 1rem; }
.auth-brand { display: block; text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--brand-dark); text-decoration: none; margin-bottom: 1.25rem; }
.auth-card { border-radius: 18px; }
.hero { background: radial-gradient(circle at 20% 20%, #a78bfa 0, transparent 40%), linear-gradient(135deg, #4c1d95, #7c3aed 55%, #db2777); color: #fff; padding: 5rem 0 6rem; }
.hero h1 { font-weight: 800; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.1; }
.feature-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.price-card { border-radius: 18px; transition: transform .15s; }
.price-card:hover { transform: translateY(-4px); }
.price-card.popular { border: 2px solid var(--brand); }
.price { font-size: 2.4rem; font-weight: 800; }

@media print {
  .sidebar, .topbar, .no-print, .m-topbar, .m-tabbar { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; }
  body { background: #fff !important; }
}

/* PWA install banner */
.pwa-install { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 1040; max-width: 520px; margin: 0 auto;
  background: var(--brand-dark); color: #fff; border-radius: 14px; padding: .65rem .8rem; display: flex; align-items: center; gap: .6rem; font-size: .88rem; }
.pwa-install span { flex: 1; }
