* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #0d1422;
  color: #eef4ff;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, #182844 0, #0d1422 45%);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid #33435f;
  border-radius: 0.85rem;
  background: #141f33;
  color: #eef4ff;
}

button {
  min-height: 3rem;
  padding: 0.75rem 1rem;
  font-weight: 700;
}

button:disabled {
  opacity: 0.55;
}

input,
select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.65rem 0.8rem;
}

.shell {
  width: min(100%, 48rem);
  margin: 0 auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    1rem
    max(2rem, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: #8ba5cc;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.85rem;
}

h2 {
  font-size: 1.15rem;
}

.status,
.card {
  border: 1px solid #33435f;
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(20, 31, 51, 0.92);
  box-shadow: 0 1rem 2.4rem rgba(0, 0, 0, 0.18);
}

.status {
  margin-bottom: 1rem;
}

.status.ok {
  border-color: #31875a;
  background: rgba(25, 74, 49, 0.7);
}

.status.warn {
  border-color: #9c752c;
  background: rgba(84, 61, 19, 0.72);
}

.card {
  margin-bottom: 1rem;
}

.muted {
  color: #aebbd0;
  line-height: 1.45;
}

label {
  display: block;
  margin: 0.9rem 0;
  color: #c8d4e8;
  font-size: 0.92rem;
}

.count-badge {
  min-width: 2rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #df4151;
  color: #fff;
  text-align: center;
  font-weight: 800;
}

.toolbar {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
}

.check input {
  width: 1.2rem;
  min-height: auto;
}

.history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.date-filter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.7rem;
  padding: 0.8rem;
  border: 1px solid #33435f;
  border-radius: 1rem;
  background: rgba(13, 20, 34, 0.42);
}

.date-filter label {
  margin: 0;
}

.date-filter button {
  align-self: end;
}

.date-summary {
  color: #91a6c4;
  font-size: 0.82rem;
}

.history-list {
  display: grid;
  gap: 0.75rem;
}

.event {
  border: 1px solid #33435f;
  border-radius: 1rem;
  padding: 0.9rem;
  background: rgba(20, 31, 51, 0.95);
}

.event.unread {
  border-left: 0.35rem solid #5e9cff;
}

.event.error {
  border-color: #c34b5b;
}

.event.warn {
  border-color: #aa7c2d;
}

.event.success {
  border-color: #31875a;
}

.event-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.event-title {
  margin: 0;
  font-size: 1rem;
}

.event-time {
  color: #8fa4c3;
  white-space: nowrap;
  font-size: 0.8rem;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.55rem 0;
}

.pill {
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  background: #263550;
  color: #cbd7e9;
  font-size: 0.76rem;
}

.event-body {
  margin: 0;
  color: #dce5f4;
  line-height: 1.4;
  white-space: pre-wrap;
}

.event-state {
  margin-top: 0.65rem;
  color: #91a6c4;
  font-size: 0.78rem;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #91a6c4;
}

#token-form {
  margin-top: 1rem;
}

#load-more {
  width: 100%;
  margin-top: 0.8rem;
}


.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.admin-head h2 {
  margin-bottom: 0;
}

.device-list {
  display: grid;
  gap: 0.9rem;
}

.device-card {
  border: 1px solid #33435f;
  border-radius: 1rem;
  padding: 0.9rem;
  background: rgba(13, 20, 34, 0.9);
}

.device-card.state-recent,
.device-card.state-active {
  border-color: #31875a;
}

.device-card.state-stale,
.device-card.state-missing,
.device-card.state-expired {
  border-color: #aa7c2d;
}

.device-card.state-disabled {
  opacity: 0.72;
}

.device-card h3 {
  margin: 0;
}

.device-state {
  margin-top: 0.35rem;
  color: #9fcb83;
  font-size: 0.83rem;
}

.device-details {
  margin: 0.7rem 0;
  padding: 0.7rem;
  border-radius: 0.75rem;
  background: #101a2b;
  color: #aebbd0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.device-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

button.danger {
  border-color: #9b3d49;
  background: #4c2027;
}


#admin-token-form {
  margin-top: 1rem;
}

#admin-access-panel .eyebrow {
  margin-bottom: 0.35rem;
}

.admin-disclosure.card {
  padding: 0;
  overflow: hidden;
}

.admin-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.82rem 0.95rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.admin-summary::after {
  content: "›";
  color: #aebbd0;
  font-size: 1.35rem;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.18s ease;
}

.admin-disclosure[open] > .admin-summary::after {
  transform: rotate(-90deg);
}

.admin-summary-title {
  min-width: 0;
  color: #eef4ff;
  font-size: 1rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.admin-summary-meta {
  color: #9fcb83;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.admin-disclosure-body {
  padding: 0 0.95rem 0.95rem;
  border-top: 1px solid #33435f;
}

.admin-head-compact {
  padding-top: 0.85rem;
}

.admin-head-compact .muted {
  margin: 0;
}

.admin-note {
  margin-top: 0.8rem;
  font-size: 0.8rem;
}

.device-diagnostics {
  margin: 0.65rem 0;
  border: 1px solid #293955;
  border-radius: 0.75rem;
  background: #101a2b;
  overflow: hidden;
}

.device-diagnostics > summary {
  padding: 0.62rem 0.72rem;
  color: #aebbd0;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}

.device-diagnostics .device-details {
  margin: 0;
  border-radius: 0;
  border-top: 1px solid #293955;
}

/* Mobile width hardening: one vertical page, no horizontal scrolling. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body,
.shell,
.topbar,
.status,
.card,
#history-panel,
.toolbar,
.date-filter,
.history-actions,
.history-list,
.event,
.device-list,
.device-card,
.admin-head {
  min-width: 0;
  max-width: 100%;
}

.shell,
.status,
.card,
#history-panel,
.toolbar,
.date-filter,
.history-actions,
.history-list,
.event,
.device-list,
.device-card {
  width: 100%;
}

.topbar > *,
.admin-head > *,
.event-head > *,
.history-actions > *,
.date-filter > *,
.device-actions > *,
.toolbar > * {
  min-width: 0;
  max-width: 100%;
}

.status,
.card,
.muted,
.event-title,
.event-body,
.event-state,
.device-state,
.device-details,
.pill,
label {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.event-head,
.admin-head,
.topbar {
  flex-wrap: wrap;
}

.event-title {
  flex: 1 1 12rem;
  min-width: 0;
}

.event-time {
  flex: 0 0 auto;
  max-width: 100%;
}

.event-body,
.device-details {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.device-details {
  font-family: inherit;
}

button,
input,
select {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 32rem) {
  .history-actions,
  .date-filter,
  .device-actions {
    grid-template-columns: 1fr;
  }

  .event-time {
    white-space: normal;
  }
}

/* WEBPUSH_SECURE_SETTINGS_V2_CSS_BEGIN */
.secure-settings-panel { margin-top: 1rem; border-top: 1px solid rgba(127,127,127,.35); padding-top: 1rem; }
.secure-settings-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(260px,1fr)); gap: 1rem; }
.secure-settings-card { display: grid; gap: .75rem; padding: 1rem; border: 1px solid rgba(127,127,127,.35); border-radius: .75rem; }
.secure-settings-card h3 { margin: 0; font-size: 1rem; }
.secure-settings-card label { display: grid; gap: .35rem; }
.secure-settings-progress { margin-top: 1rem; }
/* WEBPUSH_SECURE_SETTINGS_V2_CSS_END */

/* WEBPUSH_SECURE_SETTINGS_V3_EMAIL_CSS_BEGIN */
.secure-email-v3-card {
  border: 2px solid rgba(70, 150, 255, .55);
}
.secure-email-v3-badge {
  display: inline-block;
  width: fit-content;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  background: rgba(70, 150, 255, .16);
}
.secure-email-v3-codes {
  display: grid;
  gap: .75rem;
  padding-top: .25rem;
}
.secure-email-v3-codes input {
  font-variant-numeric: tabular-nums;
  letter-spacing: .18em;
  font-size: 1.08rem;
}
#secure-email-v3-state {
  margin: .15rem 0 0;
  font-weight: 600;
}
#secure-email-v3-attempts,
#secure-email-v3-countdown,
#secure-email-v3-current {
  margin: 0;
}
/* WEBPUSH_SECURE_SETTINGS_V3_EMAIL_CSS_END */

/* V3_HIDE_RESERVE_EMAIL_UI */
#secure-email-form[data-v2-email-reserve="true"] {
  display: none !important;
}

/* HISTORY_FILTER_PANEL_V3_BEGIN */
.filter-disclosure {
  border: 1px solid #33435f;
  border-radius: 1.1rem;
  background: rgba(20, 31, 51, 0.68);
  margin-bottom: 0.9rem;
  overflow: hidden;
}

.filter-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  list-style: none;
}

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

.filter-summary-title {
  display: block;
  font-weight: 800;
  color: #f2f6ff;
}

.filter-summary-meta {
  display: block;
  margin-top: 0.25rem;
  color: #91a6c4;
  font-size: 0.82rem;
  line-height: 1.35;
}

.filter-summary-chevron {
  color: #91a6c4;
  font-size: 1.4rem;
  transition: transform 0.16s ease;
}

.filter-disclosure[open] .filter-summary-chevron {
  transform: rotate(180deg);
}

.filter-disclosure .toolbar {
  padding: 0 1rem 1rem;
  margin-bottom: 0;
}

.period-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: stretch;
}

.period-trigger {
  display: grid;
  gap: 0.25rem;
  justify-items: start;
  text-align: left;
  min-height: 4.2rem;
}

.period-trigger span {
  color: #91a6c4;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.period-trigger strong {
  color: #f2f6ff;
  font-size: 1rem;
  line-height: 1.3;
}

.period-clear {
  align-self: stretch;
}

.period-dialog[hidden] {
  display: none;
}

.period-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.period-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  border-radius: 0;
  background: rgba(3, 8, 18, 0.72);
  backdrop-filter: blur(0.25rem);
}

.period-sheet {
  position: relative;
  z-index: 1;
  width: min(54rem, 100%);
  max-height: min(44rem, calc(100vh - 2rem));
  overflow: auto;
  border: 1px solid #425574;
  border-radius: 1.3rem;
  background: #111a2b;
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.45);
  padding: 1rem;
}

.period-head,
.period-month-nav,
.period-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.period-head h3 {
  margin: 0.15rem 0 0;
}

.period-icon-button {
  min-height: 2.55rem;
  padding: 0.2rem 0.75rem;
  font-size: 1.45rem;
}

.period-layout {
  display: grid;
  grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.period-presets {
  display: grid;
  align-content: start;
  gap: 0.5rem;
}

.period-presets button {
  text-align: left;
  justify-content: flex-start;
  min-height: 2.65rem;
}

.period-presets button.active,
.period-day.selected-start,
.period-day.selected-end {
  background: #3d7dff;
  border-color: #75a2ff;
  color: #fff;
}

.period-calendar-card {
  display: grid;
  gap: 0.8rem;
}

.period-month-nav strong {
  color: #f2f6ff;
  text-transform: capitalize;
  text-align: center;
}

.period-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(2.25rem, 1fr));
  gap: 0.3rem;
}

.period-weekday {
  color: #91a6c4;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.period-day {
  min-height: 2.6rem;
  padding: 0.2rem;
  border-radius: 0.75rem;
  font-weight: 800;
}

.period-day.outside {
  opacity: 0.42;
}

.period-day.today {
  outline: 2px solid #75a2ff;
  outline-offset: -2px;
}

.period-day.in-range {
  background: rgba(61, 125, 255, 0.22);
  border-color: rgba(117, 162, 255, 0.35);
}

.period-preview {
  margin: 0;
  color: #c8d4e8;
  min-height: 1.5rem;
}

.period-actions {
  margin-top: 1rem;
}

.period-actions .primary {
  min-width: 9rem;
}

body.period-dialog-open {
  overflow: hidden;
}

@media (max-width: 44rem) {
  .period-filter {
    grid-template-columns: 1fr;
  }

  .period-layout {
    grid-template-columns: 1fr;
  }

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

  .period-dialog {
    padding: 0.55rem;
    align-items: end;
  }

  .period-sheet {
    width: 100%;
    max-height: calc(100vh - 1.1rem);
    border-radius: 1.15rem;
  }
}
/* HISTORY_FILTER_PANEL_V3_END */

