:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #17202a;
  --muted: #667586;
  --line: #d9e0e7;
  --strong: #0f5132;
  --accent: #1d6f5f;
  --accent-2: #194f90;
  --danger: #a12836;
  --warning: #966400;
  --shadow: 0 18px 48px rgba(23, 32, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
  max-width: 520px;
  min-width: 0;
  padding: 32px;
  width: 100%;
}

.brand-mark,
.info-icon {
  align-items: center;
  background: #e4f3ed;
  color: var(--accent);
  display: inline-flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.auth-header,
.page-header,
.panel-head,
.method-card-head {
  display: grid;
  gap: 6px;
}

.eyebrow,
.auth-footer,
.muted-copy,
.page-header p,
.panel p,
.method-card-head span,
.table-meta,
.data-table span,
.sidebar-label {
  color: var(--muted);
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
}

.flow-stack,
.message-stack,
.flow-form,
.content-grid,
.admin-page {
  display: grid;
  gap: 16px;
}

.method-card,
.panel,
.notice,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 0;
  padding: 18px;
}

.method-card-head {
  border-bottom: 1px solid var(--line);
  grid-template-columns: 1fr auto;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span,
.check-row {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.input,
.field input,
.field select,
.field textarea {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 111, 95, 0.16);
  outline: 0;
}

.textarea {
  min-height: 132px;
  resize: vertical;
}

.button,
.link-button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  text-decoration: none;
}

.button-secondary {
  background: #fff;
  color: var(--text);
}

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

.button[aria-busy="true"] {
  opacity: 0.72;
}

.button-row,
.toolbar,
.action-cell,
.inline-form,
.auth-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.wrap {
  flex-wrap: wrap;
}

.check-row {
  align-items: flex-start;
  display: flex;
  gap: 9px;
}

.check-row input {
  margin-top: 3px;
}

.scope-list {
  display: grid;
  gap: 8px;
}

.text-link,
.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-2);
  min-height: auto;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.back-link {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  width: fit-content;
}

.notice {
  align-items: center;
  display: flex;
  gap: 9px;
}

.notice-error {
  border-color: #e4a1aa;
  color: var(--danger);
}

.notice-success {
  border-color: #9ad0b5;
  color: var(--strong);
}

.field-messages {
  color: var(--danger);
  display: grid;
  font-size: 13px;
  gap: 3px;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #17202a;
  color: #edf2f7;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
}

.sidebar-title,
.nav-link,
.account-pill {
  align-items: center;
  display: flex;
  gap: 10px;
}

.sidebar-title {
  font-weight: 700;
}

.nav-list,
.sidebar-section {
  display: grid;
  gap: 8px;
}

.sidebar-label {
  color: #9fb0c2;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  text-transform: uppercase;
}

.nav-link {
  color: #dce6ef;
  min-height: 40px;
  padding: 9px 10px;
  text-decoration: none;
}

.nav-link.is-active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-link.is-disabled {
  opacity: 0.48;
  pointer-events: none;
}

.app-main {
  display: grid;
  gap: 22px;
  min-width: 0;
  padding: 32px;
}

.page-header {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
}

.account-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 38px;
  padding: 8px 12px;
}

.account-pill.muted {
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.info-card {
  display: grid;
  gap: 12px;
}

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

.detail-list {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: 120px minmax(0, 1fr);
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.code-block {
  background: #111820;
  color: #edf2f7;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.toolbar {
  flex-wrap: wrap;
}

.toolbar .input {
  max-width: 280px;
}

.stat-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.stat-card {
  display: grid;
  gap: 4px;
}

.stat-card strong {
  font-size: 24px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.data-table {
  background: var(--surface);
  border-collapse: collapse;
  min-width: 920px;
  width: 100%;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.data-table td,
.data-table td > span,
.data-table code {
  overflow-wrap: anywhere;
}

.data-table td {
  display: table-cell;
}

.data-table td > span,
.data-table td > code {
  display: block;
  margin-top: 4px;
}

.badge {
  border: 1px solid var(--line);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
}

.badge-ok {
  background: #e4f3ed;
  border-color: #9ad0b5;
  color: var(--strong);
}

.badge-warn {
  background: #fff4d8;
  border-color: #f0cd79;
  color: var(--warning);
}

.badge-danger {
  background: #feecef;
  border-color: #e4a1aa;
  color: var(--danger);
}

.badge-strong {
  background: #e7eef8;
  border-color: #a8bdd8;
  color: var(--accent-2);
}

.admin-form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.simple-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.simple-list ul {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 860px) {
  .app-shell,
  .dashboard-grid,
  .two-col,
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .app-main,
  .auth-panel {
    padding: 20px;
  }

  .page-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .auth-shell {
    align-items: stretch;
    padding: 0;
  }

  .auth-panel {
    border: 0;
    box-shadow: none;
    min-height: 100vh;
  }

  .method-card-head,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .button-row,
  .auth-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
