:root {
  --bg: #f7f6f2;
  --surface: #fffdf9;
  --surface-2: #f3f0ea;
  --text: #28251d;
  --muted: #6f6b63;
  --border: #d8d2c8;
  --primary: #0d7a7b;
  --primary-hover: #0a6667;
  --danger: #b42318;
  --success: #217a43;
  --warning: #a46210;
  --shadow: 0 10px 30px rgba(30, 24, 16, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(13, 122, 123, 0.08), transparent 30%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: "Source Serif 4", serif;
  margin: 0 0 10px;
}

p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-weight: 700;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
}

.menu-more {
  position: relative;
}

.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: grid;
  gap: 4px;
  z-index: 40;
}

.more-menu__item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.more-menu__item:hover {
  background: var(--surface-2);
}

@media (max-width: 680px) {
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .menu-more {
    flex: 0 0 auto;
  }

  .more-menu {
    left: 0;
    right: auto;
    min-width: 200px;
  }
}

.auth-title {
  font-size: 18px;
}

.auth-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 18px;
}

.auth-error {
  display: none;
  margin-bottom: 14px;
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f3c7c2;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 122, 123, 0.12);
}

.field-help {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: #667085;
}

.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.switch {
  text-align: center;
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}

.switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.app-shell {
  padding: 24px;
}

.topbar {
  max-width: 1180px;
  margin: 0 auto 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-inline {
  width: auto;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  transition: 0.18s ease;
}

.btn-inline:hover {
  background: var(--surface-2);
}

.btn-inline.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-inline.primary:hover {
  background: var(--primary-hover);
}

.btn-inline.btn-danger {
  color: var(--danger);
  border-color: #f3c7c2;
}

.btn-inline.btn-danger:hover {
  background: #fdecea;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.card .label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.card .value {
  font-size: 28px;
  font-weight: 800;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel-title {
  font-size: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.9fr;
  gap: 12px;
  margin-bottom: 16px;
}

.subs-list {
  display: grid;
  gap: 12px;
}

.sub-item {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.sub-main h3 {
  font-family: Inter, system-ui, sans-serif;
  font-size: 16px;
  margin: 0 0 4px;
}

.sub-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.sub-price {
  font-weight: 800;
  font-size: 18px;
  text-align: right;
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  width: max-content;
}

.badge.active {
  background: #e5f6ef;
  color: var(--success);
}

.badge.trial {
  background: #fff3e5;
  color: var(--warning);
}

.badge.cancelled {
  background: #fdecea;
  color: var(--danger);
}

.badge.inactive {
  background: #ece9e3;
  color: var(--muted);
}

.badge-cat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* Avisos */

.alerts-panel {
  margin-bottom: 0;
}

.alerts-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.alert-item__left {
  min-width: 0;
}

.alert-item__title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.alert-item__meta {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.alert-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.alert-badge--danger {
  background: #fee2e2;
  color: #b91c1c;
}

.alert-badge--warn {
  background: #fef3c7;
  color: #92400e;
}

.alert-empty {
  padding: 12px 0;
  font-size: 14px;
  color: var(--muted);
}

/* Info box */

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
}

.info-box__icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.info-box__content {
  min-width: 0;
}

.info-box__content strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.info-box__content p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.info-box--blue {
  background: linear-gradient(180deg, #f4f8ff 0%, #eaf2ff 100%);
  border: 1px solid #cfe0ff;
  color: #114185;
  box-shadow: 0 1px 2px rgba(17, 65, 133, 0.06);
}

.info-box--blue .info-box__icon {
  background: #2f6fed;
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

/* Modales */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop:not(.hidden) {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  max-height: 92vh;
  overflow: auto;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.full {
  grid-column: 1 / -1;
}

/* Admin */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--surface-2);
}

.badge-admin {
  background: #e8f0fe;
  color: #1a56db;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge-user {
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.cats-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #1f2937;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  display: none;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: 320px;
}

@media (max-width: 800px) {
  .toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .sub-item {
    grid-template-columns: 1fr;
  }

  .sub-price {
    text-align: left;
  }

  .cats-list {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
  }

  .alert-item {
    flex-direction: column;
    align-items: flex-start;
  }
}