:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667386;
  --line: #d7e2ee;
  --paper: #ffffff;
  --panel: #f2f6fa;
  --soft: #f7faff;
  --accent: #235f9f;
  --accent-dark: #174876;
  --brand-orange: #f49a21;
  --brand-green: #24856b;
  --danger: #b42318;
  --warning: #8a4b08;
  --shadow: 0 18px 50px rgba(23, 40, 64, 0.09);
}

@font-face {
  font-family: "Montserrat";
  src: url("../palabras-cruzadas/assets/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("../palabras-cruzadas/assets/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(244, 154, 33, 0.12), transparent 28rem),
    radial-gradient(circle at top right, rgba(36, 133, 107, 0.08), transparent 30rem),
    linear-gradient(180deg, #fbfdff 0%, #edf3f8 100%),
    var(--panel);
  color: var(--ink);
  font-family: "Montserrat", ui-sans-serif, system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
.admin-header nav > a,
.login-card > a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

button:hover,
.admin-header nav > a:hover,
.login-card > a:hover {
  border-color: #9eb5cc;
  background: #f7faff;
}

h1,
h2,
h3,
h4,
p,
dl,
dd {
  margin: 0;
}

.admin-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 38px;
}

.admin-header,
.panel,
.login-card {
  border: 1px solid var(--line);
  border-top: 7px solid var(--brand-orange);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 20px 24px;
}

.admin-brand {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.admin-brand img {
  width: 58px;
  height: 58px;
  padding: 6px;
  border: 1px solid #e0e8f1;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 9px 22px rgba(18, 32, 45, 0.1);
}

.kicker,
.eyebrow {
  color: var(--brand-green);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-header h1 {
  margin-top: 3px;
  font-size: clamp(1.7rem, 3vw, 2.55rem);
  line-height: 1;
}

.lead,
.panel-head p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
}

.admin-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.admin-session {
  min-height: 46px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 5px 14px;
  border-right: 1px solid var(--line);
  text-align: right;
}

.admin-session strong {
  font-size: 0.82rem;
}

.admin-session small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.notice,
.error {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #c8dbef;
  border-radius: 8px;
  background: #f4f8ff;
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.error {
  border-color: #ffd4ce;
  background: #fff5f3;
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat-card {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 25px rgba(23, 40, 64, 0.05);
}

.stat-card:nth-child(3n + 2) {
  border-top-color: var(--brand-green);
}

.stat-card:nth-child(3n) {
  border-top-color: var(--brand-orange);
}

.stat-label {
  color: #526174;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-card strong {
  color: var(--accent-dark);
  font-size: 2rem;
  line-height: 1;
}

.stat-card small {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
  line-height: 1.3;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin-top: 4px;
  font-size: 1.35rem;
}

.panel-head > span {
  min-width: max-content;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 190px auto;
  gap: 10px;
  align-items: end;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.admin-toolbar label {
  display: grid;
  gap: 6px;
}

.admin-toolbar label > span {
  color: #455468;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-toolbar input,
.admin-toolbar select,
.login-card input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  outline: none;
}

.admin-toolbar input:focus,
.admin-toolbar select:focus,
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 95, 159, 0.12);
}

.secondary-button {
  background: #fff;
}

.user-list {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #eef3f8;
}

.user-card {
  border: 1px solid #cfdae7;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(23, 40, 64, 0.04);
}

.user-card[hidden] {
  display: none;
}

.user-summary {
  display: grid;
  grid-template-columns: minmax(300px, 1.45fr) minmax(150px, 0.62fr) minmax(140px, 0.55fr) minmax(155px, 0.65fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.user-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.user-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--brand-green));
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
}

.identity-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.user-identity h3 {
  min-width: 0;
  overflow: hidden;
  color: #111827;
  font-size: 0.94rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-identity a {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--accent-dark);
  font-size: 0.77rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-identity small,
.summary-block small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
}

.role-badge,
.badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 900;
  text-transform: uppercase;
}

.role-badge {
  background: #fff3dc;
  color: #8a4b08;
}

.badge.pro {
  background: #e5f7ef;
  color: #17624e;
}

.badge.free {
  background: #eef5fb;
  color: var(--accent-dark);
}

.summary-block {
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid #e3eaf2;
}

.summary-label {
  display: block;
  margin-bottom: 6px;
  color: #69778a;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-block > strong {
  color: #17263a;
  font-size: 0.88rem;
}

.usage-block > strong {
  color: var(--accent-dark);
  font-size: 1.35rem;
  line-height: 1;
}

.user-details {
  position: static;
  grid-column: 1 / -1;
}

.user-details summary {
  width: 118px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid #cfdceb;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 900;
  list-style: none;
  margin-left: auto;
}

.user-details summary::-webkit-details-marker {
  display: none;
}

.user-details[open] summary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.detail-sheet {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 14px -16px -14px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.detail-sheet section {
  min-width: 0;
  padding: 15px;
  border: 1px solid #dce5ef;
  border-radius: 8px;
  background: #fff;
}

.detail-sheet h4 {
  margin-bottom: 12px;
  color: #16395f;
  font-size: 0.85rem;
}

.detail-sheet dl {
  display: grid;
  gap: 8px;
}

.detail-sheet dl > div {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 9px;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf1f5;
}

.detail-sheet dt {
  color: #6b788a;
  font-size: 0.68rem;
  font-weight: 800;
}

.detail-sheet dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #1c2b3f;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: right;
}

.code-value {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.66rem !important;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.mini-stats span {
  min-height: 65px;
  display: grid;
  align-content: center;
  padding: 8px;
  border-radius: 7px;
  background: #eef5fb;
  color: #526174;
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
}

.mini-stats strong {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 1rem;
}

.detail-sheet .quota-dates {
  gap: 0;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #d7e6df;
  border-radius: 7px;
  background: #f3faf7;
}

.detail-sheet .quota-dates > div {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 7px 0;
  border-bottom-color: #deebe5;
}

.detail-sheet .quota-dates > div:last-child {
  border-bottom: 0;
}

.detail-sheet .quota-dates dt {
  color: #467062;
}

.detail-sheet .quota-dates dd {
  color: #165f4b;
}

.generator-history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.generator-history > span {
  max-width: 100%;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #d8e3ee;
  border-radius: 7px;
  background: #fff;
  font-size: 0.65rem;
}

.generator-history small {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
}

.empty-copy,
.management-section > p {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.management-section {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.actions form {
  margin: 0;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.warning-button {
  border-color: #f1c27a;
  background: #fff8ed;
  color: var(--warning);
}

.no-results {
  padding: 42px 20px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.admin-login {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
}

.login-card h1 {
  font-size: 2rem;
}

.login-card form,
.login-card label {
  display: grid;
  gap: 8px;
}

.login-card label {
  color: #334155;
  font-size: 0.82rem;
  font-weight: 800;
}

.login-card button {
  min-height: 44px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

  .user-summary {
    grid-template-columns: minmax(280px, 1.4fr) repeat(3, minmax(135px, 0.65fr));
  }

  .user-details summary {
    width: 118px;
  }
}

@media (max-width: 900px) {
  .admin-header,
  .panel-head {
    display: grid;
  }

  .admin-header nav {
    justify-content: start;
  }

  .admin-session {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  .admin-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .user-summary {
    grid-template-columns: 1fr 1fr;
  }

  .user-identity,
  .user-details {
    grid-column: 1 / -1;
  }

  .detail-sheet {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .admin-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .admin-header {
    padding: 16px;
  }

  .admin-brand {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .admin-brand img {
    width: 46px;
    height: 46px;
  }

  .stats-grid,
  .admin-toolbar,
  .user-summary {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 104px;
  }

  .search-field,
  .user-identity,
  .user-details {
    grid-column: auto;
  }

  .summary-block {
    padding: 10px 0 0;
    border-top: 1px solid #e3eaf2;
    border-left: 0;
  }

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