:root {
  color-scheme: light;
  --blue: #004b93;
  --deep: #00356b;
  --yellow: #ffd32a;
  --ink: #102033;
  --muted: #607086;
  --line: #cfdae7;
  --paper: #fffdf4;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: #eef4fa; color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { min-height: 2.8rem; padding: .65rem .9rem; border: 0; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 850; cursor: pointer; }
button:active { transform: translateY(1px); }
button.danger { background: #a51919; color: #fff; }
main { width: 100%; min-height: 100vh; margin: auto; padding: max(1rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
.login-card { max-width: 26rem; display: grid; gap: .85rem; margin: 10vh auto 0; padding: 1.2rem; border-radius: 12px; background: #fff; box-shadow: 0 16px 40px #00356b22; }
.brand-mark { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 9px; background: var(--yellow); color: var(--deep); font-weight: 950; }
h1, h2, p { margin: 0; }
h1 { color: var(--deep); font-size: 1.65rem; }
h2 { color: var(--deep); font-size: 1.15rem; }
.login-card p { color: var(--muted); }
form { display: grid; gap: .8rem; }
label { min-width: 0; display: grid; gap: .3rem; color: var(--deep); font-size: .78rem; font-weight: 850; text-transform: uppercase; }
input, textarea, select { width: 100%; min-height: 2.75rem; padding: .65rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); outline: none; text-transform: none; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #004b931c; }
.error { min-height: 1.3rem; color: #9b1c1c !important; font-weight: 750; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: 1rem; border-radius: 10px; background: linear-gradient(145deg, var(--blue), var(--deep)); color: #fff; }
.admin-head h1 { color: #fff; }
.admin-head small { color: var(--yellow); font-weight: 900; text-transform: uppercase; }
.ghost { border: 1px solid #ffffff99; background: transparent; }
.status { position: sticky; top: .5rem; z-index: 5; margin-bottom: .8rem; padding: .7rem .8rem; border-radius: 8px; background: var(--yellow); color: var(--deep); font-weight: 850; box-shadow: 0 8px 20px #10203322; }
.status.error { background: #ffe1e1; color: #8a1515 !important; }
.admin-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; margin-bottom: 1rem; padding: .3rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.admin-tabs button { background: transparent; color: var(--blue); }
.admin-tabs button.active { background: var(--blue); color: #fff; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .7rem; }
.section-head span { color: var(--muted); font-size: .82rem; font-weight: 750; }
.card-list { display: grid; gap: .55rem; }
.record { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .8rem; border: 1px solid var(--line); background: #fff; color: var(--ink); text-align: left; box-shadow: 0 4px 12px #1020330a; }
.record div { min-width: 0; display: grid; gap: .15rem; }
.record strong { overflow: hidden; color: var(--deep); text-overflow: ellipsis; white-space: nowrap; }
.record small { color: var(--muted); }
.record > span { flex: 0 0 auto; color: var(--blue); font-weight: 900; }
.record.inactive { opacity: .62; }
.record.published { border-left: 6px solid #16834b; }
.record.pending { border-left: 6px solid #e49b00; opacity: 1; background: #fffaf0; }
.record.published > span, .record.pending > span { padding: .3rem .5rem; border-radius: 999px; font-size: .7rem; letter-spacing: .03em; }
.record.published > span { background: #ccefdc; color: #075b32; }
.record.pending > span { background: #fff0a8; color: #6d5100; }
.back { margin-bottom: .8rem; padding-left: 0; background: transparent; color: var(--blue); }
.editor-form { padding: .9rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .65rem; }
.publication-status { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .85rem; border: 2px solid var(--line); border-radius: 9px; }
.publication-status > div { display: grid; gap: .2rem; }
.publication-status strong { color: var(--deep); font-size: .9rem; }
.publication-status span { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.publication-status.published { border-color: #16834b; background: #e5f7ed; }
.publication-status.published strong { color: #075b32; }
.publication-status.pending { border-color: #e49b00; background: #fff6cf; }
.publication-status.pending strong { color: #6d5100; }
.publication-status.new { background: #edf5fc; }
.publication-check { padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc; }
.language-fields { display: grid; gap: .75rem; margin: 0; padding: .9rem; border: 1px solid #b9cbe0; border-radius: 10px; background: #f5f9ff; }
.language-fields legend { padding: 0 .4rem; color: var(--blue); font-weight: 900; }
.language-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; padding: .75rem .85rem; border: 2px solid var(--yellow); border-radius: 10px; background: #fff8d5; }
.language-toolbar > div { display: grid; gap: .1rem; }
.language-toolbar strong { color: var(--deep); }
.language-toolbar small { color: var(--muted); }
.content-language { display: flex; align-items: center; gap: .4rem; margin: 0; color: var(--deep); font-size: .78rem; font-weight: 800; }
.content-language select { width: auto; min-width: 8.5rem; background: #fff; color: var(--ink); }
body[data-content-language="es"] [data-language="en"],
body[data-content-language="es"] [data-language="fr"],
body[data-content-language="en"] [data-language="es"],
body[data-content-language="en"] [data-language="fr"],
body[data-content-language="fr"] [data-language="es"],
body[data-content-language="fr"] [data-language="en"] { display: none !important; }
.form-grid { display: grid; gap: .8rem; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 2rem; text-transform: none; }
.check input { width: 1.25rem; min-height: 1.25rem; accent-color: var(--blue); }
.menu-editor { display: grid; gap: .5rem; margin-top: 1.2rem; }
.compact .record { padding: .65rem .75rem; }
.category-box { margin-top: .5rem; padding: .75rem; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.category-box summary { color: var(--deep); font-weight: 850; cursor: pointer; }
.category-form { margin-top: .75rem; }
.category-form label { width: 100%; }
.category-form button { justify-self: start; }
dialog { width: min(calc(100% - 1rem), 36rem); max-height: calc(100vh - 1rem); padding: 0; border: 0; border-radius: 12px; background: transparent; }
dialog::backdrop { background: #001d3caa; backdrop-filter: blur(2px); }
dialog .editor-form { max-height: calc(100vh - 1rem); overflow: auto; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.close { width: 2.5rem; min-height: 2.5rem; padding: 0; background: #e7eef6; color: var(--deep); font-size: 1.5rem; }
fieldset { margin: 0; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; }
legend { color: var(--deep); font-size: .78rem; font-weight: 850; text-transform: uppercase; }
.checks { display: flex; flex-wrap: wrap; gap: .7rem 1rem; }
.realtime-note { margin-bottom: .8rem; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.realtime-summary { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.realtime-summary span { padding: .35rem .55rem; border-radius: 999px; background: #dfeaf6; color: var(--deep); font-size: .78rem; font-weight: 800; }
.realtime-grid { display: grid; align-items: start; gap: 1rem; }
#notification-form, #webpush-notification-form { align-self: start; }
.connection-list { display: grid; align-content: start; gap: .55rem; }
.connection-ip-group { display: grid; gap: .55rem; padding: .65rem; border: 2px solid #9bbbd6; border-radius: 11px; background: #edf5fc; }
.connection-ip-group > h3 { margin: 0; color: var(--deep); font-size: .84rem; overflow-wrap: anywhere; }
.connection-record { display: grid; gap: .45rem; padding: .8rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 4px 12px #1020330a; }
.connection-record div { display: grid; gap: .15rem; }
.connection-record .connection-head { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .75rem; }
.connection-age { justify-self: end; color: var(--deep); font-size: .8rem; font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }
.connection-record strong { color: var(--deep); overflow-wrap: anywhere; }
.connection-record small, .connection-record p, .realtime-empty { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.connection-ip-button { display: inline; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--blue); font: inherit; font-weight: 900; text-decoration: underline; text-underline-offset: .14rem; }
.connection-ip-button:hover, .connection-ip-button:focus-visible { color: var(--deep); }
.connection-record .connection-actions { display: flex; justify-content: flex-end; }
.connection-record button, button.secondary { min-height: 2.2rem; padding: .4rem .65rem; background: #dfeaf6; color: var(--deep); font-size: .78rem; }
.connection-record .connection-actions .danger { background: #a51919; color: #fff; }
.realtime-pagination { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .7rem; }
.realtime-pagination span { color: var(--muted); font-size: .8rem; font-weight: 800; }
button:disabled { cursor: default; opacity: .45; transform: none; }
.metrics-panel { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.metrics-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; }
.metrics-controls label { min-width: 8rem; }
.metrics-date-range-form { display: grid; grid-template-columns: repeat(2, minmax(12rem, 1fr)) auto auto; align-items: end; gap: .55rem; margin-bottom: .8rem; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; background: #edf5fc; }
.metrics-date-range-form small { grid-column: 1 / -1; color: var(--muted); font-size: .72rem; }
.metrics-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  margin: .8rem 0 0;
  padding: .7rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: #edf5fc;
}
.metrics-pagination span { color: var(--deep); font-size: .82rem; font-weight: 900; text-align: center; }
button.metrics-nav-button { min-width: 8rem; min-height: 2.6rem; background: var(--blue); color: #fff; font-size: .86rem; }
button.metrics-nav-button > span { color: inherit; font-size: 1.2rem; line-height: 0; }
.webpush-controls { display: flex; align-items: end; gap: .5rem; }
.webpush-controls label { min-width: 8rem; }
.webpush-status { justify-self: start; padding: .25rem .5rem; border-radius: 999px; background: #ccefdc; color: #075b32; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.webpush-status.disabled { background: #ffe1e1; color: #821414; }
.webpush-status.unconfirmed { background: #fff0bd; color: #715200; }
.metrics-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-bottom: .8rem; }
.metric-card { display: grid; align-content: start; gap: .2rem; padding: .75rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.metric-card strong { color: var(--deep); font-size: 1.5rem; line-height: 1.1; }
.metric-card span { color: var(--deep); font-size: .76rem; font-weight: 900; }
.metric-card small { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.metric-trend { width: fit-content; margin-top: .2rem; padding: .15rem .35rem; border-radius: 999px; background: #e5f7ed; color: #075b32; font-size: .68rem; font-style: normal; font-weight: 900; }
.metric-trend.down { background: #ffe1e1; color: #821414; }
.metrics-time-note { margin: -.25rem 0 .8rem; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.analytics-grid { display: grid; gap: .8rem; margin: 0 0 1rem; }
.analytics-grid section { padding: .8rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.analytics-grid h3 { margin: 0 0 .55rem; color: var(--deep); font-size: .9rem; }
.analytics-ranking { margin: 0; padding-left: 1.5rem; }
.analytics-ranking li { padding: .2rem 0; }
.analytics-ranking strong { float: right; color: var(--deep); }
.analytics-more-button { min-height: 0; margin-top: .55rem; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--blue); font-size: .8rem; font-weight: 900; text-decoration: underline; text-underline-offset: .15rem; }
.analytics-more-button:hover, .analytics-more-button:focus-visible { color: var(--deep); }
.analytics-dialog-card { display: grid; gap: 1rem; max-height: calc(100vh - 1rem); overflow: auto; padding: 1rem; border-radius: 12px; background: var(--paper); }
.analytics-dialog-card h2 { margin: 0; }
.analytics-dialog-card small { color: var(--muted); }
.analytics-dialog-list { min-height: 18rem; padding-left: 2rem; }
.analytics-dialog-list li { border-bottom: 1px solid var(--line); }
.metrics-series { width: 100%; height: 23rem; padding: .2rem; border: 1px solid var(--line); border-radius: 0 0 9px 9px; background: #fff; }
.banner-request-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); align-items: start; gap: .75rem; }
.banner-request { display: grid; gap: .9rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 5px 16px #1020330d; }
.banner-request.editing { grid-column: 1 / -1; }
.banner-request-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.banner-request-head div { display: grid; gap: .2rem; }
.banner-request-head h2 { overflow-wrap: anywhere; }
.banner-request-head small, .banner-request-contact, .banner-request-copy p { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.banner-request-status { flex: 0 0 auto; padding: .3rem .55rem; border-radius: 999px; background: #dfeaf6; color: var(--deep); font-size: .75rem; font-weight: 900; text-transform: uppercase; }
.payment-status { display: block; width: fit-content; max-width: 100%; margin-top: .35rem; padding: .28rem .5rem; border-radius: 6px; background: #ffe1e1; color: #821414; font-size: .78rem; font-weight: 950; overflow-wrap: anywhere; }
.payment-status.completed { background: #ccefdc; color: #075b32; }
.payment-status.pending { background: #fff0a8; color: #6d5100; }
.payment-status.refunded, .payment-status.reversed { background: #e8e2f4; color: #503477; }
.payment-status.mismatch { background: #ffd3a6; color: #713600; }
.banner-request-status.pending { background: #fff0a8; }
.banner-request-status.approved { background: #ccefdc; color: #075b32; }
.banner-request-status.rejected, .banner-request-status.paused { background: #ffe1e1; color: #821414; }
.banner-request-summary { min-width: 0; display: grid; grid-template-columns: 7rem minmax(0, 1fr) auto; align-items: center; gap: .75rem; }
.banner-request-thumbnail { width: 7rem; height: 4.5rem; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #f5f8fb; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.banner-request-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.banner-request-summary-copy { min-width: 0; display: grid; gap: .15rem; }
.banner-request-summary-copy strong, .banner-request-summary-copy p, .banner-request-summary-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner-request-summary-copy p, .banner-request-summary-copy small { color: var(--muted); font-size: .78rem; }
.banner-edit-button { white-space: nowrap; }
.banner-request-details { display: grid; gap: .9rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.banner-request-preview { display: grid; grid-template-columns: 2fr 1fr; align-items: start; gap: .8rem; }
.banner-request-preview img { width: 100%; max-height: 18rem; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #f5f8fb; }
.banner-request-copy { display: grid; gap: .25rem; }
.banner-request-translations { white-space: pre-line; }
.banner-request-copy a { color: var(--blue); font-size: .82rem; font-weight: 800; overflow-wrap: anywhere; }
.banner-review-form { padding-top: .9rem; border-top: 1px solid var(--line); }
.banner-review-form fieldset { display: grid; gap: .8rem; }
.banner-review-form input[type=checkbox] { width: 1.2rem; min-height: 1.2rem; padding: 0; }
.banner-review-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.banner-review-actions .danger { background: #a51919; }

@media (max-width: 640px) {
  .metrics-date-range-form { grid-template-columns: 1fr 1fr; }
  .metrics-date-range-form button { width: 100%; }
  .compact .record strong {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.3;
  }
}

@media (min-width: 640px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-list:not(.compact) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .realtime-grid { grid-template-columns: minmax(16rem, .8fr) minmax(20rem, 1.2fr); }
  .metrics-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .admin-tabs { grid-template-columns: 1fr; }
  .language-toolbar { align-items: stretch; flex-direction: column; }
  .content-language { justify-content: space-between; }
  .section-head { align-items: stretch; flex-direction: column; }
  .metrics-controls { align-items: stretch; flex-direction: column; }
  .metrics-controls label { width: 100%; }
  .metrics-date-range-form { grid-template-columns: 1fr; }
  .metrics-pagination { align-items: stretch; flex-direction: column; }
  .webpush-controls { align-items: stretch; flex-direction: column; }
  .webpush-controls label { width: 100%; }
  .banner-request-head { flex-direction: column; }
  .banner-request-summary { grid-template-columns: 5.5rem minmax(0, 1fr); }
  .banner-request-thumbnail { width: 5.5rem; height: 3.75rem; }
  .banner-edit-button { grid-column: 1 / -1; width: 100%; }
  .banner-request-preview { grid-template-columns: 1fr; }
}
