/*
 * The portal's pages and bar, in the dashboard's palette (portal/REQUIREMENTS.md, Look and feel):
 * Coastal Slate (light) and Harbor Night (dark). Text pairs meet WCAG AA in both themes.
 */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f0f4f5;
  --surface: #ffffff;
  --surface-2: #f6f9fa;
  --border: #d3dde1;
  --text: #1e293b;
  --text-2: #475569;
  --primary: #0369a1; /* white labels: 5.9:1 */
  --on-primary: #ffffff;
  --accent: #0284c7; /* large text, icons and the focus ring only */
  --link: #075985;
  --sage: #789d4a;
  --on-sage: #1e293b;
  --input: #64748b;
  --danger: #b91c1c;
  --success: #15803d;
  --focus: #0284c7;
  --shadow: 0 1px 2px rgba(30, 41, 59, 0.06), 0 4px 16px rgba(30, 41, 59, 0.06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1519;
  --surface: #13232a;
  --surface-2: #182c34;
  --border: #25404b;
  --text: #e3ecee;
  --text-2: #94a9b0;
  --primary: #38bdf8;
  --on-primary: #0b1519;
  --accent: #38bdf8;
  --link: #7dd3fc;
  --sage: #a3c46c;
  --on-sage: #0b1519;
  --input: #6b8590;
  --danger: #f87171;
  --success: #4ade80;
  --focus: #38bdf8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1519;
    --surface: #13232a;
    --surface-2: #182c34;
    --border: #25404b;
    --text: #e3ecee;
    --text-2: #94a9b0;
    --primary: #38bdf8;
    --on-primary: #0b1519;
    --accent: #38bdf8;
    --link: #7dd3fc;
    --sage: #a3c46c;
    --on-sage: #0b1519;
    --input: #6b8590;
    --danger: #f87171;
    --success: #4ade80;
    --focus: #38bdf8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--link);
}

code {
  font: 0.92em ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.icon {
  flex: none;
  vertical-align: -3px;
}

.muted {
  color: var(--text-2);
}

/* -- buttons ------------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--input);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.btn-secondary {
  background: transparent;
}

.btn-icon {
  width: 36px;
  padding: 0;
  justify-content: center;
}

.btn-row {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  min-height: 48px;
}

.row-main {
  font-weight: 600;
  margin-right: auto;
}

:root[data-theme="dark"] .when-light,
:root:not([data-theme]) .when-dark,
:root[data-theme="light"] .when-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .when-dark {
    display: inline;
  }
  :root:not([data-theme]) .when-light {
    display: none;
  }
}

/* -- the frame: the bar above the dashboard ------------------------------------------------- */

body.frame {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  border-radius: 6px;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-tag {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-sage);
  background: var(--sage);
  border-radius: 999px;
  padding: 1px 8px;
}

.bar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bar-spacer {
  flex: 1 1 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
}

.chip > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-live[data-state="live"] {
  color: var(--success);
}

.chip-live:not([data-state="live"]) .when-live,
.chip-live:not([data-state="offline"]) .when-offline,
.chip-live:not([data-state="maintenance"]) .when-maintenance {
  display: none;
}

.chip-live[data-state="maintenance"] {
  color: var(--text);
}

.chip-live[data-state="offline"] {
  color: var(--danger);
}

.chip-quiet {
  color: var(--text-2);
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.inline-form {
  display: inline;
  margin: 0;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.stage iframe {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  display: block;
  background: var(--bg);
}

@media (max-width: 640px) {
  .bar {
    padding: 6px 12px;
    gap: 6px 8px;
  }
  .bar .brand-tag,
  .who span,
  .bar .btn-secondary span {
    display: none;
  }
  .bar-spacer {
    display: none;
  }
  .chip {
    font-size: 12px;
    min-height: 26px;
    padding: 2px 8px;
  }
}

/* -- card pages (sign-in, notices) ---------------------------------------------------------- */

.card-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.card h1 {
  margin: 4px 0 8px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pick-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 8px;
}

@media (max-width: 400px) {
  .card {
    padding: 20px;
  }
}

/* -- card pages: brand, notices, actions ---------------------------------------------------- */

.card-wide {
  max-width: 600px;
}

.card-brand {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--text);
  text-decoration: none;
}

.card-brand img {
  border-radius: 6px;
}

.status-ok {
  color: var(--success);
}

.status-bad {
  color: var(--danger);
}

.small {
  font-size: 13px;
}

.actions {
  margin: 18px 0 0;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.notice > .icon {
  margin-top: 3px;
  color: var(--accent);
}

.notice p {
  margin: 0 0 8px;
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice-bad {
  border-color: var(--danger);
}

.notice-bad > .icon {
  color: var(--danger);
}

/* -- forms ------------------------------------------------------------------------------- */

.form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

.req,
.opt {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-left: 4px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
  border-width: 2px;
  padding: 7px 9px;
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.field-error .icon {
  margin-top: 2px;
}

.hint {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 13px;
}

.check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500 !important;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.form-foot {
  display: grid;
  gap: 10px;
}

.btn-wide {
  justify-content: center;
  width: 100%;
  min-height: 44px;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

/* -- privacy -------------------------------------------------------------------------------- */

.prose h2 {
  font-size: 17px;
  margin: 22px 0 6px;
}

.prose ul {
  padding-left: 20px;
}

.prose li {
  margin: 4px 0;
}

/* -- the admin page ------------------------------------------------------------------------- */

.admin-bar .brand-tag {
  display: inline;
}

.admin-bar .tab span {
  display: inline;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.tab[aria-current="page"] {
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.admin {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.strip-item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-head h1 {
  margin: 0;
  font-size: 22px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.filter[aria-current="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge .icon {
  width: 14px;
  height: 14px;
}

.status-approved,
.badge-ok {
  color: var(--success);
}

.status-denied,
.status-revoked,
.badge-bad {
  color: var(--danger);
}

.status-pending {
  color: var(--on-sage);
  background: var(--sage);
  border-color: var(--sage);
}

.status-unconfirmed,
.status-expired,
.badge-quiet,
.badge-warn {
  color: var(--text-2);
}

.badge-warn {
  color: var(--text);
}

.requests {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.request {
  padding: 14px 16px;
  scroll-margin-top: 16px;
}

.request-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.request-name {
  margin: 0 0 0 4px;
  font-size: 17px;
}

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

.fields .wide {
  grid-column: 1 / -1;
}

.fields dt,
.dates dt {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

.fields dd,
.dates dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.dates {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

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

.confirm-delete summary {
  list-style: none;
}

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

.confirm-box {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  max-width: 360px;
}

.confirm-box p {
  margin: 0 0 8px;
}

.empty {
  padding: 20px;
}

@media (max-width: 640px) {
  .admin {
    padding: 12px;
  }
  .admin-bar .btn-secondary span {
    display: none;
  }
}

.request .notice {
  margin: 10px 0 0;
}
