:root {
  --bg: #f6f5fb;
  --sidebar-bg: #1f1832;
  --sidebar-text: #cfc8e8;
  --primary: #7c5cff;
  --primary-dark: #5f3dfa;
  --accent: #22b8cf;
  --card-bg: #ffffff;
  --border: #e8e5f3;
  --text: #2b2640;
  --text-muted: #837c9c;
  --success: #2f9e44;
  --warn: #e8590c;
  --danger: #e03131;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(60, 40, 130, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Arial, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: ltr;
}
#app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; padding: 0 6px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
}
.brand-title { font-weight: 700; font-size: 16px; color: #fff; }
.brand-sub { font-size: 11px; color: #a89bd6; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; min-height: 0; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none; font-size: 14px;
  transition: background .15s;
}
.nav-link .ic { font-size: 16px; width: 20px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,0.06); }
.nav-link.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); }
.branch-selector-top { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.branch-selector label { font-size: 11px; color: #a89bd6; display:block; margin-bottom: 4px; }
.branch-selector select {
  width: 100%; padding: 8px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.08); color: #fff; font-size: 13px;
}
.content { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
#pageTitle { font-size: 20px; font-weight: 700; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-warn { background: #fff3e0; color: var(--warn); }
.badge-ok { background: #e6fcf0; color: var(--success); }
.view { padding: 24px 28px 60px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }

.card {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid var(--border);
}
.kpi-card { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--text-muted); }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text); }
.kpi-icon { font-size: 22px; }

.section-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; display:flex; align-items:center; justify-content:space-between; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: none; font-size: 13.5px; font-weight: 600;
  cursor: pointer; background: var(--primary); color: #fff; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.97); }

/* Disabled buttons had NO styling at all: a disabled "Complete Sale" looked identical
   to an enabled one, still brightened on hover, and simply did nothing when clicked.
   Staff reasonably read that as "the system won't let me make a sale". Make the state
   unmistakable, and stop hover/active from implying the button is live. */
.btn:disabled,
.btn[disabled] {
  background: #d8d4e8;
  color: #8b86a3;
  cursor: not-allowed;
  opacity: 0.75;
}
.btn:disabled:hover,
.btn[disabled]:hover { background: #d8d4e8; }
.btn:disabled:active,
.btn[disabled]:active { transform: none; }
.btn-outline:disabled,
.btn-outline[disabled] {
  background: transparent;
  color: #a9a4bd;
  border-color: var(--border);
}
.btn-secondary { background: #efeaff; color: var(--primary-dark); }
.btn-secondary:hover { background: #e1d8ff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fff0f0; color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 9px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
table td { padding: 11px 8px; border-bottom: 1px solid var(--border); }
table tr:hover td { background: #faf9ff; }

.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border);
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-row label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 10px; flex-wrap: wrap; }
.search-box { display:flex; align-items:center; gap:8px; background:#fff; border:1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 240px; }
.search-box input { border: none; outline: none; flex:1; font-size: 13.5px; }

.pill { display:inline-flex; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.pill-active { background:#e6fcf0; color:var(--success); }
.pill-expired { background:#fff0f0; color:var(--danger); }
.pill-confirmed { background:#e7f3ff; color:#1971c2; }
.pill-done { background:#e6fcf0; color:var(--success); }
.pill-cancelled { background:#f1f1f1; color:#868e96; }

.client-row { display:flex; align-items:center; gap:12px; cursor:pointer; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; flex-shrink:0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,15,40,0.45); display:flex; align-items:center; justify-content:center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 16px; padding: 26px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 12px 50px rgba(0,0,0,0.25);
}
.modal.modal-wide { max-width: 880px; }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom: 18px; }
.modal-header h3 { margin:0; font-size: 18px; }
.modal-close { background:none; border:none; font-size: 20px; cursor:pointer; color: var(--text-muted); }

.tabs { display:flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 16px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-color: var(--primary); }

.photo-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.photo-card { border-radius: 10px; overflow:hidden; border:1px solid var(--border); position:relative; }
.photo-card img { width:100%; height: 130px; object-fit: cover; display:block; }
.photo-card .photo-tag { position:absolute; top:6px; left:6px; background:rgba(0,0,0,0.6); color:#fff; font-size:10.5px; padding:2px 7px; border-radius: 12px; }
.photo-card .photo-del { position:absolute; top:6px; right:6px; background:rgba(255,255,255,0.85); border:none; border-radius:50%; width:22px;height:22px; cursor:pointer; }

.timeline-item { display:flex; gap:12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline-dot { width:10px; height:10px; border-radius:50%; background: var(--primary); margin-top:5px; flex-shrink:0; }

.toast {
  position: fixed; bottom: 24px; left: 24px; background: #2b2640; color:#fff; padding: 12px 18px;
  border-radius: 10px; font-size: 13.5px; box-shadow: 0 6px 24px rgba(0,0,0,0.25); z-index: 200; transition: opacity .2s, transform .2s;
}
.toast.hidden { opacity: 0; transform: translateY(10px); pointer-events:none; }
.toast.error { background: #5c1a1a; }

.empty-state { text-align:center; padding: 40px 20px; color: var(--text-muted); }

.calendar-day-col { background:#fff; border-radius: var(--radius); border:1px solid var(--border); min-height: 500px; padding: 10px; }
.calendar-appt {
  background: #efeaff; border-left: 3px solid var(--primary); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 8px; font-size: 12.5px; cursor: pointer;
}
.calendar-appt:hover { background: #e1d8ff; }
.calendar-appt .time { font-weight: 700; }

.muted { color: var(--text-muted); }
.flex { display:flex; align-items:center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-10 { margin-bottom: 10px; }
.w-100 { width: 100%; }
a { color: var(--primary); }


                        /* Fix: native select dropdown options were rendering white-on-white (unreadable) in some browsers because the sidebar's dark/white styling only applies to the closed control, not the OS-rendered open list. Force readable colors on the options themselves. */
.branch-selector select option {
    color: #2b2640;
    background: #ffffff;
}
.input option, select.input option {
    color: #2b2640;
    background: #ffffff;
}
.user-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 12px; color: #a89bd6; }
.btn-link { background: none; border: none; color: #cdbfff; font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; }
.btn-link:hover { color: #fff; }

/* Package-finishing alerts */
.alert-dot-red {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  background: #e02020; box-shadow: 0 0 0 0 rgba(224,32,32,0.7);
  animation: alert-pulse-red 1.4s infinite;
}
.alert-dot-warning {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: #e0a000;
}
@keyframes alert-pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(224,32,32,0.7); }
  70% { box-shadow: 0 0 0 7px rgba(224,32,32,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,32,32,0); }
}
.pill-alert-red {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fde8e8; color: #c01818; border: 1px solid #f3b8b8;
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700;
}
.pill-alert-warning {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fff3d6; color: #8a5a00; border: 1px solid #f0d28a;
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700;
}
.calendar-appt.appt-alert-red { border-left-color: #e02020 !important; background: #fde8e8 !important; }
.calendar-appt.appt-alert-warning { border-left-color: #e0a000 !important; background: #fff3d6 !important; }
/* Cancelled by staff */
.calendar-appt.appt-cancelled { border-left-color: #aaa !important; background: #f4f4f4 !important; opacity: 0.78; }
.calendar-appt.appt-cancelled:hover { background: #ebebeb !important; opacity: 1; }
/* Manually confirmed by staff (client hasn't clicked email link yet) */
.calendar-appt.appt-staff-confirmed { border-left-color: #1a73e8 !important; background: #e8f0fe !important; }
.calendar-appt.appt-staff-confirmed:hover { background: #d2e3fc !important; }

/* Point of Sale */
.pos-layout { display: flex; gap: 18px; align-items: flex-start; }
.pos-catalog { flex: 1; min-width: 0; }
.pos-cart { width: 340px; flex-shrink: 0; position: sticky; top: 18px; }
.pos-catalog-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.pos-catalog-row:last-child { border-bottom: none; }
.pos-cart-item { padding: 9px 0; border-bottom: 1px solid var(--border); }
.pos-cart-item:last-child { border-bottom: none; }
/* ── PRINTING A RECEIPT ────────────────────────────────────────────────────────
   Print CSS must be opt-IN, not opt-out. This used to name a handful of things to
   hide (.sidebar, .topbar, .pos-catalog...), which meant anything NOT on that list —
   the cart, the page heading, the modal chrome, any future element — still printed.
   Hide everything, then reveal only the receipt. That way nothing new can leak onto
   a customer's receipt by default. */
@media print {
  /* visibility (not display) keeps the receipt's layout intact while blanking the
     rest of the tree; display:none on ancestors would take the receipt with it. */
  body * { visibility: hidden !important; }
  #posReceiptPrintable,
  #posReceiptPrintable * { visibility: visible !important; }

  /* Lift the receipt out of the modal and onto the page itself, so it starts at the
     top-left of the paper instead of wherever the dialog happened to float. */
  #posReceiptPrintable {
    visibility: visible !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    color: #000 !important;
  }

  /* Never print the controls, and never let the modal backdrop tint the paper. */
  .modal-backdrop { position: static !important; background: none !important; }
  .modal { box-shadow: none !important; border: 0 !important; }
  #posPrintReceiptBtn, #posEmailReceiptBtn, .modal-header, .modal-close { display: none !important; }

  /* Don't break a receipt across two pages mid-line. */
  #posReceiptPrintable * { page-break-inside: avoid; }

  /* Thermal rolls are continuous: `auto` height stops a short receipt from ejecting a
     full page of blank paper. Works on a normal A4/Letter printer too. */
  @page { margin: 6mm; size: auto; }
}
