:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #182230;
  --muted: #5f6c7b;
  --border: #d8e0ea;
  --brand: #075ea8;
  --brand-strong: #004783;
  --brand-soft: #eaf4ff;
  --success: #16794a;
  --success-soft: #e9f8f0;
  --warning: #9a5b00;
  --warning-soft: #fff4d6;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 12px 32px rgb(20 42 74 / 9%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgb(35 125 206 / 11%), transparent 34rem),
    var(--bg);
}

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

button {
  min-height: 42px;
  padding: 0.62rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover:not(:disabled) {
  background: var(--brand-strong);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(7 94 168 / 22%);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-secondary {
  color: var(--brand-strong);
  border-color: #aac7e0;
  background: #fff;
}

.button-secondary:hover:not(:disabled) {
  background: var(--brand-soft);
}

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

.button-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.button-quiet {
  min-height: 36px;
  padding: 0.42rem 0.7rem;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.button-quiet:hover:not(:disabled) {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.62rem 0.72rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: #fff;
}

textarea {
  min-height: 6.5rem;
  resize: vertical;
}

input[type="checkbox"] {
  width: 1.1rem;
  min-height: 1.1rem;
  margin: 0;
  accent-color: var(--brand);
}

label,
.field-label {
  display: grid;
  gap: 0.35rem;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 650;
}

.app-loading {
  max-width: 72rem;
  margin: 4rem auto;
  padding: 2rem;
  color: var(--muted);
}

.site-header {
  color: #fff;
  background: linear-gradient(118deg, #003c72, #0876be);
  box-shadow: 0 4px 18px rgb(0 43 80 / 18%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2rem, 76rem);
  margin: 0 auto;
  padding: 1.25rem 0;
  gap: 1.5rem;
}

.brand-block {
  min-width: 0;
}

.brand-title {
  max-width: 56rem;
  margin: 0;
  font-size: clamp(1.1rem, 2.1vw, 1.7rem);
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.brand-subtitle {
  margin: 0.35rem 0 0;
  color: rgb(255 255 255 / 78%);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.identity {
  max-width: 18rem;
  overflow: hidden;
  color: rgb(255 255 255 / 90%);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-switch {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid rgb(255 255 255 / 36%);
  border-radius: 0.7rem;
  background: rgb(0 28 53 / 18%);
}

.language-switch button {
  min-height: 32px;
  padding: 0.25rem 0.55rem;
  border-radius: 0.48rem;
  color: rgb(255 255 255 / 78%);
  background: transparent;
  font-size: 0.8rem;
}

.language-switch button[aria-pressed="true"] {
  color: var(--brand-strong);
  background: #fff;
}

.header-signout {
  min-height: 36px;
  padding: 0.42rem 0.75rem;
  color: #fff;
  border-color: rgb(255 255 255 / 52%);
  background: transparent;
}

.header-signout:hover:not(:disabled) {
  background: rgb(255 255 255 / 13%);
}

.page-shell {
  width: min(100% - 2rem, 76rem);
  margin: 1.6rem auto 3rem;
}

.session-warning,
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  gap: 1rem;
  border: 1px solid #efca75;
  border-radius: 0.75rem;
  color: #704100;
  background: var(--warning-soft);
}

.session-warning[hidden] {
  display: none;
}

.notice-danger {
  display: block;
  color: #7a271a;
  border-color: #f0b7b1;
  background: var(--danger-soft);
}

.tabs,
.subtabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tabs {
  padding: 0.35rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: rgb(255 255 255 / 74%);
  box-shadow: 0 3px 14px rgb(20 42 74 / 5%);
}

.tabs button,
.subtabs button {
  flex: 0 0 auto;
  color: var(--muted);
  background: transparent;
}

.tabs button[aria-selected="true"],
.subtabs button[aria-selected="true"] {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.subtabs {
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.subtabs button {
  border-radius: 0.55rem 0.55rem 0 0;
}

.card {
  padding: clamp(1.05rem, 2.6vw, 1.55rem);
  border: 1px solid rgb(216 224 234 / 85%);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 1rem;
}

.card-header,
.section-heading-row,
.job-header,
.policy-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card h2,
.card h3,
.card h4 {
  margin: 0;
  line-height: 1.3;
}

.section-description,
.muted,
.help-text {
  color: var(--muted);
}

.section-description {
  max-width: 54rem;
  margin: 0.35rem 0 1.2rem;
}

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

.form-grid .span-two {
  grid-column: 1 / -1;
}

.form-actions,
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.form-actions {
  margin-top: 1.1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 0.55rem;
}

.bypass-toggle {
  padding: 0.75rem;
  border: 1px solid #efca75;
  border-radius: 0.7rem;
  color: #704100;
  background: var(--warning-soft);
}

.bypass-fields {
  padding: 1rem;
  border: 1px solid #f0b7b1;
  border-radius: 0.8rem;
  background: #fffafa;
}

.bypass-fields[hidden] {
  display: none;
}

.bypass-fields .notice {
  margin-top: 0;
}

.status-message {
  min-height: 1.5rem;
  margin-top: 0.9rem;
  color: var(--muted);
}

.status-message.is-error {
  color: var(--danger);
}

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

.jobs-list,
.policy-list,
.audit-list {
  display: grid;
  margin-top: 1rem;
  gap: 0.8rem;
}

.jobs-workbench {
  display: grid;
  margin-top: 1rem;
  gap: 1rem;
}

.jobs-region {
  padding: clamp(0.9rem, 2vw, 1.2rem);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--surface-subtle);
}

.jobs-region-active {
  border-color: #a9d5f4;
  background: linear-gradient(135deg, #f2faff, var(--surface-subtle));
}

.jobs-region .section-description {
  margin-bottom: 0;
}

.jobs-region-heading {
  align-items: center;
}

.jobs-refresh-info {
  display: grid;
  min-width: min(100%, 17rem);
  gap: 0.15rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #b9dcf5;
  border-radius: 0.65rem;
  color: #075985;
  background: #e8f5ff;
  font-size: 0.79rem;
  font-weight: 650;
  text-align: right;
}

.active-jobs-list,
.job-history-list {
  margin-top: 0.85rem;
}

.job-history-list {
  height: clamp(18rem, 45vh, 34rem);
  padding-right: 0.35rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.job-card,
.policy-row,
.audit-row,
.architecture-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-subtle);
}

.job-title,
.policy-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0.85rem 0 0;
  gap: 0.8rem;
}

.metadata-grid div {
  min-width: 0;
}

.metadata-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.metadata-grid dd {
  margin: 0.18rem 0 0;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  color: #475467;
  background: #e9edf2;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.status-running {
  color: #075985;
  background: #e0f2fe;
}

.status-success,
.status-enabled {
  color: var(--success);
  background: var(--success-soft);
}

.status-failed,
.status-disabled {
  color: var(--danger);
  background: var(--danger-soft);
}

.failure-detail {
  margin: 0.8rem 0 0;
  color: var(--danger);
}

.policy-platforms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.policy-platform {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: #fff;
}

.policy-form {
  padding: 1rem;
  margin-top: 0.9rem;
  border-radius: 0.75rem;
  background: var(--surface-subtle);
}

.policy-form .form-grid {
  grid-template-columns: 1fr 1fr;
}

.access-grant-form {
  padding: 1rem;
  border: 1px solid #b9dcf5;
  border-radius: 0.8rem;
  background: #f5fbff;
}

.access-grant-form h3 {
  margin: 0;
  line-height: 1.3;
}

.access-grant-form {
  margin-top: 1rem;
}

.access-grant-form textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.access-grant-form .form-actions {
  margin-bottom: 0;
}

.access-scope-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 42px;
  margin: 0;
  padding: 0.75rem;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
}

.access-scope-fields legend {
  padding: 0 0.3rem;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 650;
}

.access-grant-list {
  display: grid;
  margin-top: 0.9rem;
  gap: 0.8rem;
}

.access-grant-row {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-subtle);
}

.access-grant-action-reason {
  margin-top: 0.9rem;
}

.access-grant-row .inline-actions {
  margin-top: 0.7rem;
}

.empty-state {
  padding: 1.5rem;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #bdc8d5;
  border-radius: 0.75rem;
  background: var(--surface-subtle);
}

.architecture-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.architecture-card h3 {
  font-size: 1rem;
}

.architecture-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.audit-row {
  display: block;
}

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

.audit-heading strong {
  overflow-wrap: anywhere;
}

.audit-metadata {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.25rem;
}

.login-card {
  width: min(100%, 42rem);
  padding: clamp(1.5rem, 5vw, 3rem);
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 22px 55px rgb(20 42 74 / 13%);
}

.login-card h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
}

.login-card p {
  margin: 1rem auto 1.5rem;
  color: var(--muted);
}

.login-language {
  display: flex;
  justify-content: center;
  margin-top: 1.4rem;
  gap: 0.4rem;
}

.login-language button[aria-pressed="true"] {
  color: var(--brand-strong);
  border-color: #aac7e0;
  background: var(--brand-soft);
}

.password-dialog {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgb(13 29 49 / 48%);
}

.password-dialog-card {
  display: grid;
  width: min(100%, 32rem);
  gap: 0.85rem;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 24px 60px rgb(8 22 40 / 30%);
}

.password-dialog-card h2 {
  margin: 0 0 0.25rem;
}

@media (max-width: 900px) {
  .policy-platforms,
  .architecture-grid {
    grid-template-columns: 1fr;
  }

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

  .audit-row {
    display: block;
  }
}

@media (max-width: 680px) {
  .header-inner,
  .card-header,
  .section-heading-row,
  .job-header,
  .policy-header,
  .session-warning {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .subtabs {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .subtabs button {
    flex: 1 1 auto;
  }

  .identity {
    max-width: 100%;
  }

  .jobs-refresh-info {
    text-align: left;
  }

  .form-grid,
  .policy-form .form-grid,
  .metadata-grid,
  .audit-filters {
    grid-template-columns: 1fr;
  }

  .form-grid .span-two {
    grid-column: auto;
  }

  .form-actions button,
  .inline-actions button {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
