:root {
  --bg: #11100e;
  --bg-2: #171512;
  --surface: #1f1c18;
  --surface-2: #29251f;
  --surface-3: #343028;
  --ink: #f7f2ea;
  --muted: #b7ab9b;
  --soft: #7f7467;
  --line: rgba(247, 242, 234, 0.12);
  --line-strong: rgba(247, 242, 234, 0.22);
  --gold: #d7a85b;
  --gold-2: #f0c879;
  --teal: #4fb7a2;
  --green: #70bf7a;
  --blue: #6f8ed7;
  --wine: #c35c67;
  --danger: #e66f63;
  --warn: #d99b45;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --font-body: "Aptos", "Segoe UI", system-ui, sans-serif;
  --font-display: "Bahnschrift", "Aptos Display", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    linear-gradient(90deg, rgba(247, 242, 234, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(247, 242, 234, 0.025) 1px, transparent 1px),
    linear-gradient(145deg, #11100e 0%, #171512 46%, #201b16 100%);
  background-size: 36px 36px, 36px 36px, 100% 100%;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--gold-2); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(247, 242, 234, 0.22); border-radius: 8px; }

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.88);
  box-shadow: var(--shadow);
}

.brand { text-align: center; margin-bottom: 22px; }
.brand .logo { font-size: 42px; line-height: 1; }
.brand h1, .brand-lockup h1, .section-title h2, .panel h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0;
}
.brand h1 { margin-top: 8px; font-size: 26px; }
.brand small, .muted { color: var(--muted); }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
}
.tabs button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px;
  font-weight: 750;
}
.tabs button.active {
  background: var(--gold);
  color: #24190a;
}

label {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #14120f;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 168, 91, 0.18);
}
input::placeholder, textarea::placeholder { color: var(--soft); }

button.primary, .btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}
button.primary {
  width: 100%;
  margin-top: 18px;
  background: var(--gold);
  color: #24190a;
}
.btn:hover, button.primary:hover { transform: translateY(-1px); }
.btn:disabled, button.primary:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary { background: var(--gold); color: #211607; }
.btn-secondary { background: #2f2a22; border-color: var(--line-strong); color: var(--ink); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-danger { background: var(--danger); color: #250706; }
.btn-small { min-height: 32px; padding: 7px 10px; font-size: 12px; }
.btn.square { width: 42px; padding-inline: 0; }
.danger-text { color: #ffafa8; }

.msg, .toast {
  display: none;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 12px 13px;
}
.msg { margin-top: 16px; font-size: 13px; }
.msg.show, .toast.show { display: block; }
.msg.ok, .toast.ok { background: rgba(112, 191, 122, 0.14); border-color: rgba(112, 191, 122, 0.28); color: #bbf0c1; }
.msg.err, .toast.err { background: rgba(230, 111, 99, 0.14); border-color: rgba(230, 111, 99, 0.28); color: #ffc0ba; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  width: min(360px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

.panel-body { overflow-x: hidden; }
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 16, 14, 0.9);
  backdrop-filter: blur(14px);
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--gold);
  color: #231709;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.14);
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-2);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}
.brand-lockup h1 {
  max-width: 48vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 19px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.shop-pulse {
  max-width: 260px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 18px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 2.6vw, 32px) 56px;
}
.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.78);
  box-shadow: var(--shadow);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 9px 10px;
  text-align: left;
  font-weight: 800;
}
.nav-item span { width: 18px; color: var(--gold); }
.nav-item:hover { background: rgba(247, 242, 234, 0.05); color: var(--ink); }
.nav-item.active { background: var(--gold); color: #211607; }
.nav-item.active span { color: #211607; }

.content-shell { min-width: 0; }
.view { display: none; animation: rise 0.22s ease; }
.view.active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 0 16px;
}
.section-title h2 { font-size: clamp(24px, 4vw, 38px); line-height: 1.03; }
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.center-toolbar { justify-content: center; }
.surface-toolbar {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.72);
}
.surface-toolbar input { flex: 1 1 260px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.metric-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card {
  min-height: 118px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(247, 242, 234, 0.055), transparent),
    var(--surface);
}
.metric-card span, .metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.metric-card b {
  display: block;
  margin: 10px 0 5px;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 32px);
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.span-2 { grid-column: span 2; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.86);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.panel h3 { font-size: 18px; }
.stack { display: grid; gap: 8px; }
.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
}
.line-item strong, .line-item span { display: block; min-width: 0; overflow-wrap: anywhere; }
.line-item span { color: var(--muted); font-size: 12px; }
.line-item > b { font-size: 14px; }
.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.filter-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.76);
}
.filter-line label { margin: 0; }
.filter-line select { max-width: 260px; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.day-pill {
  position: relative;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  padding: 8px;
  text-align: left;
}
.day-pill span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.day-pill b { display: block; margin-top: 6px; font-size: 24px; }
.day-pill i {
  position: absolute;
  right: 8px;
  top: 8px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--teal);
  color: #06231e;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 20px;
  text-align: center;
}
.day-pill.today { border-color: var(--gold); }
.day-pill.active { background: var(--gold); color: #211607; border-color: var(--gold); }
.day-pill.active span { color: #3a270f; }

.agenda-grid-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 28, 24, 0.86);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.agenda-inner { width: 100%; }
.agenda-head-row {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line-strong);
  background: #211e1a;
}
.barber-head {
  min-height: 54px;
  padding: 10px;
  border-left: 1px solid var(--line);
  text-align: center;
  font-weight: 900;
}
.barber-head small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.agenda-body-grid { display: grid; }
.time-gutter {
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.08);
}
.time-gutter div {
  height: var(--slot-h, 46px);
  padding: 0 8px 0 0;
  color: var(--soft);
  font-size: 11px;
  line-height: 1;
  text-align: right;
  transform: translateY(-5px);
}
.agenda-col {
  position: relative;
  border-right: 1px solid var(--line);
}
.agenda-slot {
  display: block;
  width: 100%;
  height: var(--slot-h, 46px);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.agenda-slot.hour { border-bottom-color: var(--line-strong); }
.agenda-slot:hover { background: rgba(215, 168, 91, 0.08); }
.agenda-appt, .agenda-block {
  position: absolute;
  left: 5px;
  right: 5px;
  z-index: 3;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 7px;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}
.agenda-appt {
  background: var(--appt);
  color: #16110a;
}
.agenda-block {
  z-index: 2;
  background:
    repeating-linear-gradient(135deg, rgba(247, 242, 234, 0.16) 0 8px, rgba(247, 242, 234, 0.04) 8px 16px),
    #3a332a;
  color: var(--ink);
}
.agenda-appt b, .agenda-block b,
.agenda-appt span, .agenda-block span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-appt b, .agenda-block b { font-size: 12px; }
.agenda-appt span, .agenda-block span { font-size: 11px; opacity: 0.82; }
.agenda-appt.is-canceled {
  background: #696055;
  color: #211d18;
  opacity: 0.7;
  text-decoration: line-through;
}
.agenda-blocks-panel { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.form-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .btn, .form-grid button.primary { align-self: end; }
.modal-form { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.modal-toolbar { margin-bottom: 8px; }
.slot-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}
.slot-chip {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #171512;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 800;
}
.slot-chip.active, .slot-chip:hover { background: var(--gold); color: #211607; }
.form-error { color: #ffb4ad; font-size: 13px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.data-table th, .data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  color: var(--soft);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}
.data-table td > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.data-table tr:hover td { background: rgba(247, 242, 234, 0.035); }
.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid transparent;
  margin-right: 4px;
}
.tag.ok { background: rgba(112, 191, 122, 0.14); color: #bdf2c4; border-color: rgba(112, 191, 122, 0.24); }
.tag.info { background: rgba(79, 183, 162, 0.14); color: #bcefe6; border-color: rgba(79, 183, 162, 0.24); }
.tag.warn { background: rgba(217, 155, 69, 0.14); color: #ffdca4; border-color: rgba(217, 155, 69, 0.24); }
.tag.off { background: rgba(247, 242, 234, 0.09); color: var(--muted); border-color: var(--line); }

.queue-list { display: grid; gap: 10px; }
.queue-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.12);
}
.queue-rank {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--gold-2);
  font-weight: 900;
}
.queue-item strong, .queue-item span { display: block; overflow-wrap: anywhere; }
.queue-item span { color: var(--muted); font-size: 12px; }

.empty-state {
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.wa-panel { text-align: center; }
.wa-state {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  margin-bottom: 16px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(79, 183, 162, 0.14);
  color: #c4f2e9;
  font-weight: 900;
}
.qr-zone img {
  width: min(320px, 100%);
  padding: 14px;
  border-radius: var(--radius);
  background: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
}
.modal-overlay.show { display: grid; }
.modal {
  position: relative;
  width: min(620px, 100%);
  max-height: min(86vh, 820px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  padding: 20px;
}
.modal h3 { margin: 0 38px 16px 0; font-family: var(--font-display); font-size: 22px; }
.modal-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.detail-list { display: grid; gap: 8px; }
.modal-subtitle { margin: 18px 0 10px; font-size: 14px; color: var(--muted); }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 940px) {
  .app-layout { display: block; padding-top: 12px; }
  .sidebar {
    position: sticky;
    top: 73px;
    z-index: 20;
    display: flex;
    overflow-x: auto;
    margin-bottom: 14px;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .dashboard-grid, .two-col { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}

@media (max-width: 720px) {
  .app-topbar { align-items: flex-start; }
  .topbar-actions {
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 48vw;
  }
  .shop-pulse { display: none; }
  .brand-lockup h1 { max-width: 42vw; font-size: 16px; }
  .brand-mark { width: 40px; height: 40px; }
  .metric-grid, .metric-grid.compact, .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 104px; padding: 13px; }
  .week-strip { grid-template-columns: repeat(7, minmax(48px, 1fr)); gap: 5px; overflow-x: auto; }
  .day-pill { min-height: 64px; padding: 6px; }
  .day-pill b { font-size: 20px; }
  .filter-line { align-items: stretch; flex-direction: column; }
  .filter-line select { max-width: none; }
  .form-grid, .form-grid.wide, .modal-form { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  input, select, textarea { font-size: 16px; }
  .line-item { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .queue-item { grid-template-columns: 42px minmax(0, 1fr); }
  .queue-item .actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
}

@media (max-width: 460px) {
  .metric-grid, .metric-grid.compact, .insight-grid { grid-template-columns: 1fr; }
  .app-topbar { gap: 10px; }
  .topbar-actions .btn-primary { display: none; }
  .section-title h2 { font-size: 25px; }
  .toolbar { width: 100%; }
  .toolbar input[type="date"] { flex: 1 1 160px; }
}
