:root {
  --rose: #b5646f;
  --rose-dark: #8f4750;
  --blush: #f7e9e8;
  --blush2: #f0dcda;
  --paper: #fffaf8;
  --charcoal: #2c2422;
  --ink-soft: #74645f;
  --ink-faint: #a8938d;
  --line: #ecdedb;
  --good: #3f8f5f;
  --good-bg: #e3f1e8;
  --bad: #b23b3b;
  --bad-bg: #f3e4e4;
  --gold: #b3862f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fdf5f2;
  color: var(--charcoal);
}

h1, h2 { font-family: 'Playfair Display', Georgia, serif; margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 38px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.topbar h1 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--rose-dark);
}
.brand-sub {
  font-size: 10.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.lang-toggle { display: flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 2px; }
.lang-opt {
  background: transparent; color: var(--ink-soft); padding: 5px 11px; font-size: 11px;
  font-weight: 700; border-radius: 999px; letter-spacing: 0.3px;
}
.lang-opt.active { background: var(--rose-dark); color: #fff; }

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 4px 18px rgba(143, 71, 80, 0.06);
}
.auth-card { max-width: 380px; margin: 60px auto; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}
.tab.active { background: var(--rose-dark); color: #fff; border-color: var(--rose-dark); }

form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
input {
  font-size: 14px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--charcoal);
}
input:focus { outline: none; border-color: var(--rose); }

button {
  font-size: 14px;
  font-weight: 700;
  padding: 11px;
  border-radius: 10px;
  border: none;
  background: var(--rose-dark);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.ghost {
  background: transparent;
  color: var(--rose-dark);
  border: 1.5px solid var(--rose-dark);
}
button.ghost.small { padding: 6px 12px; font-size: 12px; }
button.filter {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
}
button.filter.active { background: var(--blush); color: var(--rose-dark); border-color: var(--rose); }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px;
  text-align: center;
  box-shadow: 0 4px 18px rgba(143, 71, 80, 0.05);
}
.stat-value { display: block; font-family: 'Playfair Display', Georgia, serif; font-size: 26px; font-weight: 700; color: var(--rose-dark); }
.stat-label { display: block; font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }

/* Layout */
.dash-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) {
  .dash-layout { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

.sidebar { position: sticky; top: 20px; }
.calendar-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 18px rgba(143, 71, 80, 0.06);
}
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-month-label { font-weight: 700; font-size: 13.5px; }
.icon-btn {
  background: var(--blush);
  color: var(--rose-dark);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 10px; color: var(--ink-soft); font-weight: 700; padding-bottom: 4px; }
.cal-day {
  position: relative;
  aspect-ratio: 1;
  border: none;
  background: var(--paper);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--charcoal);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  overflow: hidden;
  min-width: 0;
}
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.today { border: 1.5px solid var(--rose); font-weight: 700; }
.cal-day.selected { background: var(--rose-dark); color: #fff; }
.cal-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: var(--rose);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  border-radius: 6px;
  min-width: 12px;
  padding: 0 2px;
  line-height: 12px;
}
.cal-day.selected .cal-dot { background: #fff; color: var(--rose-dark); }
.cal-today-btn { width: 100%; margin-top: 10px; }

.main-col { min-width: 0; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.search-input { flex: 1; min-width: 180px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }

.selected-date-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--blush);
  color: var(--rose-dark);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

.error { color: var(--bad); font-size: 12.5px; margin: 4px 0 0; }
.muted { color: var(--ink-soft); font-size: 13px; text-align: center; padding: 30px 0; }
.hidden { display: none !important; }

.day-group { margin-bottom: 22px; }
.day-heading { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); margin-bottom: 8px; }

.appt-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(143, 71, 80, 0.04);
}
.appt-time { font-weight: 700; font-size: 14px; width: 78px; flex-shrink: 0; }
.appt-main { flex: 1; }
.appt-service { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.appt-customer { font-size: 12.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.wa-link { text-decoration: none; font-size: 13px; }
.appt-addons { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }

.status-pill { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 3px 8px; border-radius: 20px; }
.status-upcoming { background: var(--blush); color: var(--rose-dark); }
.status-done { background: var(--good-bg); color: var(--good); }
.status-cancelled { background: var(--bad-bg); color: var(--bad); }

.appt-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.appt-actions button { font-size: 11.5px; padding: 6px 10px; }
.appt-actions button.done { background: var(--good); }
.appt-actions button.cancel { background: var(--bad); }

/* Dashboard section tabs */
.dtabs-nav { display: flex; gap: 8px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.dtab {
  background: transparent; color: var(--ink-soft); border: none; border-radius: 0;
  padding: 10px 4px; margin-right: 20px; font-size: 13.5px; font-weight: 600;
  border-bottom: 2.5px solid transparent;
}
.dtab.active { color: var(--rose-dark); border-bottom-color: var(--rose-dark); }

/* Charts */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
@media (max-width: 760px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 4px 18px rgba(143, 71, 80, 0.05);
}
.chart-card h3 { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin: 0 0 14px; text-transform: uppercase; letter-spacing: 0.4px; }
.chart-svg-wrap { width: 100%; }
.chart-bar { fill: var(--rose); }
.chart-bar:hover { fill: var(--rose-dark); }
.chart-gridline { stroke: var(--line); stroke-width: 1; }
.chart-tooltip {
  position: absolute; background: var(--charcoal); color: #fff; font-size: 11px; font-weight: 600;
  padding: 5px 9px; border-radius: 7px; pointer-events: none; white-space: nowrap; opacity: 0;
  transition: opacity 0.1s; transform: translate(-50%, -110%);
}
.chart-svg-wrap { position: relative; }

.rank-chart { display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 88px 1fr 28px; align-items: center; gap: 10px; }
.rank-label { font-size: 12px; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar-track { background: var(--blush); border-radius: 6px; height: 10px; overflow: hidden; }
.rank-bar-fill { background: var(--rose); height: 100%; border-radius: 6px; min-width: 4px; }
.rank-value { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }
.rank-empty { font-size: 12.5px; color: var(--ink-faint); }

/* Discounts / messages panels */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.panel-head h2 { font-size: 20px; margin-bottom: 4px; }
.panel-sub { font-size: 12.5px; color: var(--ink-soft); margin: 0; max-width: 52ch; line-height: 1.5; }

.discounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.discount-card {
  border-radius: 16px; padding: 16px; color: #fff; cursor: pointer; border: none;
  text-align: left; position: relative; min-height: 132px; display: flex; flex-direction: column;
}
.discount-card.inactive { opacity: 0.5; }
.discount-pct { font-family: 'Playfair Display', Georgia, serif; font-size: 26px; font-weight: 700; }
.discount-title { font-size: 13px; font-weight: 700; margin: 2px 0 3px; }
.discount-sub { font-size: 11.5px; opacity: 0.92; line-height: 1.4; flex: 1; }
.discount-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.discount-code { background: rgba(255,255,255,0.2); padding: 4px 9px; border-radius: 7px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.discount-exp { font-size: 10.5px; opacity: 0.85; }
.discount-add-card {
  border: 1.5px dashed var(--line); background: transparent; border-radius: 16px; min-height: 132px;
  display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.discount-add-card:hover { border-color: var(--rose); color: var(--rose-dark); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,14,12,0.5); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 20;
}
.modal { background: #fff; border-radius: 18px; padding: 24px; max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }
.w-sm { max-width: 100px; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-row input { width: 16px; height: 16px; padding: 0; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.modal-actions-right { display: flex; gap: 8px; }
.danger-ghost { color: var(--bad); border-color: var(--bad); }

/* Messages / WhatsApp tool */
.msg-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .msg-layout { grid-template-columns: 1fr; } }
.msg-compose h3, .msg-recipients h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); margin: 0 0 10px; }
.audience-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.audience-opt {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px;
  text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.audience-opt.active { background: var(--blush); border-color: var(--rose); }
.audience-name { font-size: 12px; font-weight: 700; color: var(--charcoal); }
.audience-count { font-size: 16px; font-weight: 700; color: var(--rose-dark); font-variant-numeric: tabular-nums; }
.tmpl-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tmpl-chip {
  background: var(--paper); border: 1.5px solid var(--line); color: var(--ink-soft);
  font-size: 11.5px; font-weight: 600; padding: 7px 12px; border-radius: 999px;
}
.msg-textarea {
  width: 100%; min-height: 96px; font-size: 13.5px; padding: 11px; border-radius: 11px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--charcoal);
  font-family: inherit; resize: vertical;
}
.hint { font-size: 11px; color: var(--ink-faint); margin: 6px 0 0; }
.recipients-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.recipient-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px;
}
.recipient-info { min-width: 0; }
.recipient-name { font-size: 13px; font-weight: 700; color: var(--charcoal); }
.recipient-meta { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }
.recipient-send {
  background: #25d366; color: #fff; font-size: 11.5px; padding: 7px 12px; flex-shrink: 0;
  display: flex; align-items: center; gap: 5px; text-decoration: none; border-radius: 999px;
}
