:root {
  color-scheme: dark;
  --focus: #80b7ff;
  --surface-input: #091523;
  /* Recessed panels (workspace ops summary, the no-panel-yet notice). Defined as
     tokens so the light theme can redefine them; hardcoding the dark navy left both
     rendering as a grey slab on the white page. */
  --surface-sunken: rgba(16, 36, 71, 0.35);
  --surface-sunken-strong: rgba(16, 36, 71, 0.55);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
body {
  overflow-x: hidden;
}
html[data-theme='light'] {
  color-scheme: light;
  --bg: #eef2f9;
  --bg-2: #e3eaf6;
  --panel: #ffffff;
  --card: #ffffff;
  --soft: #e9eff8;
  --line: #d3ddee;
  --line-strong: #b9c8e0;
  --text: #0f1d38;
  --muted: #566380;
  --muted-soft: #7c8aa6;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent2: #0ea394;
  --accent2-strong: #0b877a;
  --success: #0f9d76;
  --warn: #b7791f;
  --danger: #d64560;
  --info: #2563eb;
  --focus: #1d4ed8;
  --surface-input: #f6f9fe;
  --surface-sunken: #f4f7fd;
  --surface-sunken-strong: #eef3fb;
  --shadow: 0 18px 50px rgba(26, 53, 91, 0.12);
  --shadow-sm: 0 1px 3px rgba(26, 53, 91, 0.08);
  --shadow-md: 0 14px 34px rgba(26, 53, 91, 0.14);
}
html[data-theme='light'] body {
  background:
    radial-gradient(1000px 560px at 100% -5%, rgba(37, 99, 235, 0.08), transparent 60%),
    linear-gradient(135deg, #f7f9fd, #eaf0fa);
}
html[data-theme='light'] aside {
  background: rgba(255, 255, 255, 0.97);
}
html[data-theme='light'] .metric,
html[data-theme='light'] .card {
  background: linear-gradient(145deg, #fff, #f8faff);
}
html[data-theme='light'] .lane,
html[data-theme='light'] .field input,
html[data-theme='light'] .field textarea,
html[data-theme='light'] .field select,
html[data-theme='light'] .inline-form input {
  background: var(--surface-input);
}
html[data-theme='light'] .badge {
  background: #dce8fa;
  color: #204575;
}
html[data-theme='light'] .badge.good {
  background: #d8f3ea;
  color: #11604d;
}
html[data-theme='light'] .badge.warn {
  background: #fff0d1;
  color: #704900;
}
html[data-theme='light'] .badge.bad {
  background: #ffe0e4;
  color: #8a2232;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  right: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-160%);
}
.skip-link:focus {
  transform: translateY(0);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
button,
input,
select,
textarea,
a {
  font: inherit;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}
.primary:hover:not(:disabled),
.secondary:hover:not(:disabled),
.danger-button:hover:not(:disabled) {
  filter: brightness(1.12);
}
.primary:active:not(:disabled),
.secondary:active:not(:disabled),
.danger-button:active:not(:disabled) {
  transform: translateY(1px);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.menu-toggle,
.sidebar-close {
  display: none;
}
.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.environment-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.environment-control select {
  width: auto;
  min-width: 130px;
}
.global-search input {
  width: min(250px, 28vw);
  background: var(--surface-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
}
.profile-button {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 13px;
  padding: 5px 9px 5px 6px;
  text-align: right;
}
.profile-button strong,
.profile-button small {
  display: block;
  max-width: 125px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-button strong {
  font-size: 11px;
}
.profile-button small {
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
}
.notification-button {
  position: relative;
}
.notification-dot {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--panel);
}
.context-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: -12px 0 20px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.environment-badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: #214067;
  color: #bcd4ff;
  font-weight: 700;
}
.environment-badge.production {
  background: #482831;
  color: #ffb1bb;
}
.environment-badge.staging {
  background: #45351e;
  color: #ffd18a;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}
.table tbody tr:hover {
  background: color-mix(in srgb, var(--soft) 52%, transparent);
}
.table td {
  vertical-align: middle;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-bottom: 14px;
}
.filter-row input,
.filter-row select {
  width: auto;
  min-width: 170px;
  background: var(--surface-input);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
}
.result-count {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 12px;
}
.field small {
  display: block;
  margin-top: 5px;
}
.field-error {
  min-height: 16px;
  color: var(--danger);
  font-size: 11px;
}
.field [aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(255, 107, 120, 0.14);
}
.button-loader {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-inline-end: 7px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.danger-button {
  border: 1px solid #a33b4c;
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  background: #8b2638;
  color: #fff;
}
dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(2, 8, 23, 0.74);
  backdrop-filter: blur(3px);
}
dialog form {
  padding: 22px;
}
.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.dialog-head {
  margin-bottom: 16px;
}
.dialog-head h2 {
  margin: 0;
}
.dialog-actions {
  justify-content: flex-end;
  margin-top: 20px;
}
.danger-summary {
  padding: 14px;
  margin-bottom: 15px;
  border: 1px solid #6b303d;
  border-radius: 13px;
  background: #3b2028;
  color: #ffd5da;
  line-height: 1.7;
}
.danger-summary dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 7px;
  margin: 0;
  font-size: 12px;
}
.danger-summary dt {
  color: #ff9dab;
}
.danger-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
}
#toast {
  z-index: 1100;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.sidebar-backdrop {
  display: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 230px 1fr;
  }
  aside {
    padding-inline: 12px;
  }
  main {
    padding-inline: 20px;
  }
  .global-search {
    order: 3;
    width: 100%;
  }
  .global-search input {
    width: 100%;
  }
}
@media (max-width: 720px) {
  .shell {
    display: block;
  }
  aside {
    position: fixed;
    z-index: 900;
    top: 0;
    right: 0;
    width: min(320px, 88vw);
    height: 100dvh;
    overflow-y: auto;
    border-left: 1px solid var(--line);
    border-bottom: 0;
    transform: translateX(105%);
    transition: transform 0.22s ease;
  }
  body.sidebar-open aside {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    position: fixed;
    z-index: 850;
    inset: 0;
    display: block;
    background: rgba(2, 8, 23, 0.64);
  }
  .sidebar-backdrop[hidden] {
    display: none;
  }
  nav {
    grid-template-columns: 1fr;
  }
  .menu-toggle,
  .sidebar-close {
    display: grid;
  }
  .sidebar-close {
    margin-inline-start: auto;
  }
  main {
    padding: 16px 14px 40px;
  }
  header {
    gap: 13px;
    margin-bottom: 18px;
  }
  .header-actions {
    width: auto;
  }
  .environment-control span,
  .profile-button > span:last-child,
  .notification-button {
    display: none;
  }
  .environment-control select {
    min-width: 118px;
  }
  .global-search {
    display: none;
  }
  .context-banner {
    margin-top: 0;
    align-items: flex-start;
  }
  h1 {
    font-size: 22px;
  }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-head > button {
    width: 100%;
  }
  .filter-row > * {
    width: 100% !important;
  }
  .result-count {
    margin: 0;
  }
  .card {
    padding: 16px;
    border-radius: 15px;
    max-width: 100%;
    overflow-x: auto;
  }
  .table {
    min-width: 560px;
  }
  .metric strong {
    font-size: 22px;
  }
  #toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

/* Create-MiniApp wizard: completed stage marker and post-create next action. */
.steps .done {
  background: #173c35;
  color: #7ce0c0;
  border: 1px solid #286d5a;
}
.callout-actions {
  margin-top: 10px;
}
.callout-actions .primary.small {
  display: inline-block;
}

/* ---- OTP / verification settings page ---- */
.otp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.otp-sec {
  border: 1px solid var(--border, #e3e6ea);
  border-radius: 12px;
  padding: 16px;
  background: var(--card, #fff);
}
.otp-sec h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.otp-sec h4 {
  margin: 12px 0 6px;
  font-size: 13px;
}
.otp-sec hr {
  border: none;
  border-top: 1px solid var(--border, #e3e6ea);
  margin: 14px 0;
}
.otp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.otp-chip {
  border: 1px solid var(--border, #cfd4da);
  background: transparent;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font: inherit;
}
.otp-chip-on {
  background: var(--accent, #0c7c59);
  color: #fff;
  border-color: var(--accent, #0c7c59);
}
.otp-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.otp-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
}
.otp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  margin-bottom: 10px;
}
.otp-field input {
  padding: 8px 10px;
  border: 1px solid var(--border, #cfd4da);
  border-radius: 8px;
  font: inherit;
}
.otp-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}
.otp-sec .field-error {
  display: block;
  margin-top: 8px;
  min-height: 1em;
}
