html,
body {
  overflow-x: hidden;
}

:root {
  --bg: #111315;
  --surface: #1a1d20;
  --surface-2: #22272b;
  --surface-3: #15181a;

  --text: #f5f1e8;
  --muted: #aaa29a;
  --muted-soft: #8f8a84;

  --line: #343a40;

  --primary: #d7a84f;
  --primary-dark: #b8872d;
  --primary-soft: rgba(215, 168, 79, 0.14);

  --accent: #6ea8fe;

  --success: #49c27f;
  --success-soft: rgba(73, 194, 127, 0.14);

  --warning: #d7a84f;
  --warning-soft: rgba(215, 168, 79, 0.14);

  --danger: #f06b61;
  --danger-soft: rgba(240, 107, 97, 0.14);

  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(215, 168, 79, 0.12), transparent 32%),
    radial-gradient(circle at top right, rgba(110, 168, 254, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;

  border: 1px solid var(--line);
  background: rgba(26, 29, 32, 0.92);
  border-radius: 8px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.1;
}

.header-copy {
  display: block;
  max-width: 660px;
  margin-top: 8px;
  color: var(--muted);
}

.header-actions,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  border: none;
  color: inherit;
  font-weight: 900;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
  opacity: 0.92;
}

.btn-primary {
  background: var(--primary);
  color: #17120a;
}

.btn-secondary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.btn-whatsapp {
  background: var(--success);
  color: #ffffff;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 29, 32, 0.92);
  padding: 18px;
}

.metric-card span {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.search-box {
  display: grid;
  width: min(460px, 100%);
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 16px;
  outline: none;
}

.search-box input::placeholder {
  color: var(--muted-soft);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(215, 168, 79, 0.14);
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter-btn,
.tab-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 13px;
  font-weight: 800;
  transition: 0.15s ease;
}

.filter-btn:hover,
.tab-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.filter-btn.active,
.tab-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #17120a;
}

.table-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 29, 32, 0.92);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.section-title-row h2 {
  font-size: 1rem;
}

.section-title-row p {
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

.clients-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.clients-table th,
.clients-table td {
  border-bottom: 1px solid var(--line);
  padding: 15px 18px;
  text-align: left;
  vertical-align: middle;
}

.clients-table th {
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.clients-table tbody tr {
  transition: background 160ms ease;
}

.clients-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.client-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
}

.small-avatar,
.avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
  border: 1px solid rgba(215, 168, 79, 0.2);
}

.small-avatar {
  width: 36px;
  height: 36px;
  font-size: 0.78rem;
}

.avatar {
  width: 58px;
  height: 58px;
  font-size: 1rem;
}

.client-email {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
  border: 1px solid transparent;
}

.status-active,
.status-vip {
  background: var(--success-soft);
  color: var(--success);
}

.status-new {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-inactive {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-cell,
.muted {
  color: var(--muted);
}

.empty-cell {
  padding: 36px 18px;
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.drawer.open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 180ms ease;
}

.drawer.open .drawer-backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(720px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
  transform: translateX(100%);
  transition: transform 220ms ease;
}

.drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding-right: 42px;
}

.drawer-header h2 {
  margin-bottom: 10px;
  font-size: 1.6rem;
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions {
  margin-bottom: 22px;
}

.drawer-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.info-grid,
.loyalty-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-grid > div,
.loyalty-grid > article,
.note-box,
.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 15px;
}

.info-grid span,
.loyalty-grid span,
.note-box span,
.history-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.info-grid strong,
.loyalty-grid strong {
  overflow-wrap: anywhere;
}

.note-box {
  margin-top: 12px;
}

.note-box p {
  color: var(--text);
  line-height: 1.55;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.history-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.history-item p {
  color: var(--muted);
  font-size: 0.9rem;
}

.history-price {
  font-weight: 900;
  white-space: nowrap;
  color: var(--primary);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .page-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .status-filter {
    justify-content: flex-start;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .metrics-grid,
  .info-grid,
  .loyalty-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 96px;
  }

  .drawer-panel {
    padding: 22px 16px;
  }

  .quick-actions .btn {
    width: 100%;
  }

  .page-header,
  .table-section,
  .metric-card {
    padding: 14px;
  }
}