* {
  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;
}

.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,
.history-actions,
.history-list,
.event,
.device-list,
.device-card,
.admin-head {
  min-width: 0;
  max-width: 100%;
}

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

.topbar > *,
.admin-head > *,
.event-head > *,
.history-actions > *,
.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,
  .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;
}
