:root {
  color-scheme: dark;
  --bg: #0B132B;
  --card: #131D3B;
  --b: #24335F;
  --t: #EEF2FF;
  --m: #94A3C4;
  --blue: #2563EB;
  --red: #EF4444;
  --green: #10B981;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--t);
}
h1, h2, h3 { margin: 0 0 12px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--m); }
.small { font-size: 12px; }
.text-green { color: #34D399; }
.error { color: #FCA5A5; min-height: 1em; margin: 8px 0 0; }
.hint { display: block; color: var(--m); font-size: 11.5px; margin-bottom: 4px; }
.error-msg { display: none; color: #FCA5A5; font-size: 12px; margin-top: 4px; }

:is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--red) !important;
  background-color: rgba(239, 68, 68, 0.12) !important;
}
:is(:user-invalid, .user-invalid-fallback) + .error-msg {
  display: block;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.card { background: var(--card); border: 1px solid var(--b); border-radius: 14px; padding: 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-radius: 9px; border: 1px solid var(--b); background: #1A2650;
  color: var(--t); font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #3B82F6; }
.btn.primary { background: var(--blue); border-color: var(--blue); font-weight: 600; }
.btn.danger { background: transparent; border-color: var(--red); color: #FCA5A5; }
.btn.icon, .btn.small { padding: 5px 9px; font-size: 12px; }

input, select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--b); background: #0B132B; color: var(--t);
  font: inherit; font-size: max(1rem, 14px);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid #60A5FA; outline-offset: 2px;
}
input[type=checkbox] { width: auto; accent-color: var(--blue); }
input[type=color] { padding: 2px; height: 38px; }

.field { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 12px; color: var(--m); font-weight: 600; }

.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; padding: 10px 16px;
  background: #070D1F; border-bottom: 1px solid var(--b);
}
.compliance-pill {
  font-size: 11px; font-weight: 700; color: #34D399;
  background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 3px 8px; border-radius: 999px;
}
.topbar-actions, .row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.container { max-width: 1140px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.kpi-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--b);
}
.kpi-val {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
}

.rotation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}
.switch-row { display: flex; gap: 8px; align-items: center; color: var(--t); font-size: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* Responsive Table with Sticky Headers & Container Query */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(640px, 80vh);
  container-type: inline-size;
  border-radius: 10px;
  border: 1px solid var(--b);
}
.offers-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.offers-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #0F172A;
}
.offers-table th, .offers-table td {
  padding: 10px;
  border-bottom: 1px solid var(--b);
  text-align: left;
  white-space: nowrap;
}
.offers-table th { color: var(--m); font-weight: 600; font-size: 12px; }
.offers-table tr.off td { opacity: .45; }
.offers-table tr.pinned td:first-child { color: #FDE047; font-weight: 700; }
.offers-table input[type=number] { width: 84px; padding: 6px 8px; }

@container (width < 680px) {
  .offers-table, .offers-table thead, .offers-table tbody, .offers-table tr, .offers-table th, .offers-table td {
    display: block;
  }
  .offers-table thead {
    display: none;
  }
  .offers-table tr {
    margin-block-end: 12px;
    border: 1px solid var(--b);
    border-radius: 10px;
    padding: 8px;
  }
}

.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: middle; }
.bar { display: inline-block; height: 6px; background: var(--green); border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* Native Modal Dialog */
dialog:modal {
  overscroll-behavior: contain;
}
dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.65);
}
.edit-dialog[open] {
  width: min(860px, 96vw);
  max-height: 92dvh;
  padding: 0;
  border: 1px solid var(--b);
  border-radius: 16px;
  background: var(--card);
  color: var(--t);
}
.edit-dialog form { padding: 16px; display: grid; gap: 14px; }
.dialog-head, .dialog-foot { display: flex; justify-content: space-between; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.checks-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.checks-row div { display: flex; align-items: center; gap: 6px; }
.checks-row label { color: var(--t); font-size: 13px; cursor: pointer; }
.links-fieldset { border: 1px solid var(--b); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.links-fieldset legend { font-weight: 700; font-size: 13px; color: #93C5FD; padding: 0 6px; }
.link-row { display: grid; grid-template-columns: 1fr 95px auto; gap: 8px; align-items: center; }

.admin-logo-thumb {
  width: 22px; height: 22px; object-fit: contain;
  background: #FFF; border-radius: 4px; padding: 2px;
  margin-right: 8px; vertical-align: middle;
}
.btn-pinned {
  background: rgba(253, 224, 71, 0.2) !important;
  border-color: #FDE047 !important;
  color: #FDE047 !important;
  font-weight: 700 !important;
}

.admin-tabs-nav {
  display: flex; gap: 8px; border-bottom: 1px solid var(--b);
  padding-bottom: 12px; overflow-x: auto; scrollbar-width: none;
}
.admin-tabs-nav::-webkit-scrollbar { display: none; }
.admin-tab-btn {
  background: #131D3B; border: 1px solid var(--b); color: var(--m);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.admin-tab-btn:hover { color: var(--t); border-color: #3B82F6; }
.admin-tab-btn.active {
  background: var(--blue); border-color: var(--blue); color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
.admin-tab-pane { display: grid; gap: 16px; }
.admin-tab-pane[hidden] { display: none !important; }

.push-history-list { display: grid; gap: 8px; }
.push-history-item {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}

