:root {
  color-scheme: light;
  --page: #eef4f6;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --text: #1a2744;
  --heading: #102345;
  --muted: #5b6880;
  --muted-strong: #46566d;
  --primary: #005f73;
  --primary-hover: #004e5f;
  --primary-soft: #e1f1f4;
  --accent: #287a55;
  --border: #d5e0e6;
  --border-strong: #c2d1d9;
  --ok: #216d3a;
  --ok-bg: #e8f7ed;
  --ok-border: #b8dec4;
  --warning: #805500;
  --warning-bg: #fff4d7;
  --warning-border: #efd28e;
  --danger: #9c1930;
  --danger-bg: #fff0f2;
  --danger-border: #edbdc5;
  --info: #155f73;
  --info-bg: #edf7f9;
  --info-border: #bddce3;
  --focus: #16748a;
  --shadow: 0 18px 44px rgba(26, 39, 68, .10);
  --sidebar-width: 212px;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--page);
  font: 13px/1.35 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; }

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

h1,
h2,
h3 {
  color: var(--heading);
  line-height: 1.2;
}

h1 { margin-bottom: 8px; font-size: clamp(24px, 3vw, 29px); letter-spacing: -.02em; }
h2 { margin-bottom: 6px; font-size: 18px; }
h3 { margin-bottom: 6px; font-size: 16px; }
p { margin-bottom: 0; }

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 9px 12px;
  color: #fff;
  background: var(--heading);
  border-radius: 6px;
  font-weight: 700;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 18px 12px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0 4px 25px;
  color: var(--heading);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
}

.brand-mark-large { width: 44px; height: 44px; font-size: 14px; }

.brand-copy { display: grid; min-width: 0; line-height: 1.2; }
.brand-copy strong { font-size: 15px; }
.brand-copy small { color: var(--muted); font-size: 11px; }

.sidebar-nav { display: grid; gap: 4px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--muted-strong);
  border-radius: 7px;
  font-weight: 650;
  text-decoration: none;
}

.nav-link.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 3px 0 var(--primary);
}
.nav-link.is-disabled { color: #8793a3; cursor: not-allowed; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 18px;
  line-height: 1;
}

.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); }

.service-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.state-dot,
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.workspace { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 64px;
  padding: 8px 24px;
  background: rgba(255, 255, 255, .97);
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(26, 39, 68, .04);
}

.topbar-context { min-width: 0; margin-left: auto; }

.account-context { display: grid; min-width: 0; text-align: right; line-height: 1.25; }
.account-organization { overflow: hidden; color: var(--heading); font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.account-user { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.main-content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 30px 28px 48px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-header > div { max-width: 720px; }
.page-header p:not(.eyebrow) { color: var(--muted); font-size: 15px; }
.page-header-actions { align-items: center; }
.page-action-help { margin: -15px 0 18px auto; text-align: right; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

.card {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(26, 39, 68, .025);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.card-header p { margin-top: 2px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  display: grid;
  min-width: 0;
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.metric-card-alert { border-left-color: var(--danger); }
.metric-label { color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.metric-value { margin: 8px 0 6px; color: var(--heading); font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1; }
.metric-detail { color: var(--primary); font-size: 12px; font-weight: 700; }
.metric-caption { color: var(--muted); font-size: 12px; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, .75fr);
  gap: 14px;
}

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

.workflow-list li {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
  padding: 9px 0;
}

.workflow-list li:not(:last-child)::after {
  position: absolute;
  top: 35px;
  bottom: -4px;
  left: 14px;
  width: 1px;
  background: var(--border);
  content: "";
}

.workflow-number {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}

.workflow-list strong,
.workflow-list span { display: block; }
.workflow-list li div > span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.card-actions { margin-top: 14px; }

.form-grid-record {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(120px, .6fr) minmax(140px, .65fr);
  gap: 14px;
}

.format-help {
  padding: 12px 14px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.format-help summary {
  color: var(--primary);
  font-weight: 750;
  cursor: pointer;
}

.format-help dl {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
}

.format-help dl div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.format-help dt { color: var(--heading); font-weight: 750; }
.format-help dd { margin: 0; }
.format-help code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

.assurance-card { display: flex; align-items: flex-start; gap: 12px; background: #f5faf7; border-color: var(--ok-border); }
.assurance-card p { color: var(--muted-strong); font-size: 13px; }
.assurance-icon { display: grid; flex: 0 0 auto; place-items: center; width: 30px; height: 30px; color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); border-radius: 50%; font-weight: 850; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.button-primary { color: #fff; background: var(--primary); }
.button-secondary { color: var(--primary); background: var(--primary-soft); border-color: var(--info-border); }
.button-quiet { color: var(--muted-strong); background: var(--surface); border-color: var(--border-strong); }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-full { width: 100%; }
.button:disabled { color: #f8fbfc; background: #71808e; border-color: #71808e; cursor: not-allowed; opacity: .62; }

.text-link { color: var(--primary); font-weight: 750; text-underline-offset: 3px; }

.table-card { padding: 0; overflow: hidden; }
.table-card > .card-header { padding: 20px 20px 0; }
.table-wrap { width: 100%; overflow-x: auto; scrollbar-gutter: stable; }
table { width: 100%; border-collapse: collapse; }
th,
td { padding: 13px 20px; border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
td { font-size: 13px; }
.zone-name { color: var(--heading); font-weight: 750; }
.table-action { text-align: right; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.status-ok .status-dot { background: var(--ok); }
.status-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.status-warning .status-dot { background: var(--warning); }
.status-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.status-danger .status-dot { background: var(--danger); }
.status-neutral { color: var(--muted-strong); background: var(--surface-soft); border-color: var(--border); }

.rdata-value {
  display: block;
  max-width: 52ch;
  overflow-wrap: anywhere;
}

.form-card { width: min(680px, 100%); }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }

.empty-state { display: grid; justify-items: center; padding: 54px 20px 58px; text-align: center; border-top: 1px solid var(--border); }
.empty-state-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 14px; color: var(--primary); background: var(--primary-soft); border-radius: 50%; font-size: 26px; }
.empty-state p { max-width: 430px; color: var(--muted); }

.auth-body {
  background:
    radial-gradient(circle at 50% 0, rgba(0, 95, 115, .075), transparent 36rem),
    var(--page);
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  padding: 32px 18px;
  place-items: center;
}

.auth-card {
  display: grid;
  gap: 21px;
  width: min(420px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-brand { display: flex; align-items: center; gap: 11px; line-height: 1.25; }
.auth-brand div { display: grid; }
.auth-brand strong { color: var(--heading); font-size: 16px; }
.auth-brand span:not(.brand-mark) { color: var(--muted); font-size: 11px; }
.auth-heading h1 { margin-bottom: 8px; font-size: 24px; }
.auth-heading p:not(.eyebrow) { max-width: 35ch; color: var(--muted); line-height: 1.5; }

.form-stack { display: grid; gap: 16px; }
.form-field { display: grid; gap: 6px; color: var(--heading); font-size: 12px; font-weight: 750; }
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-weight: 450;
}
.form-field textarea { min-height: 132px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(22, 116, 138, .12); outline: 0; }

.verification-code { font-size: 21px !important; font-variant-numeric: tabular-nums; font-weight: 750 !important; letter-spacing: .32em; text-align: center; }
.field-help { color: var(--muted); font-size: 11px; }

.alert { min-height: 0; padding: 10px 11px; border: 1px solid; border-radius: 6px; font-size: 12px; font-weight: 650; }
.alert:empty { display: none; }
.alert-error { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.alert-warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.alert-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.page-notice { margin-bottom: 18px; }
.table-limit-notice { margin: 14px 16px 16px; }
.audit-details summary { color: var(--primary); font-weight: 750; cursor: pointer; }
.audit-details dl { display: grid; gap: 5px; margin: 9px 0 0; }
.audit-details dl div { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 7px; }
.audit-details dt { color: var(--muted); font-weight: 700; }
.audit-details dd { margin: 0; overflow-wrap: anywhere; }

.invitation-secret-card { width: min(760px, 100%); }
.invitation-secret { display: grid; gap: 8px; padding: 15px; background: var(--surface-soft); border: 1px solid var(--border-strong); border-radius: 7px; }
.invitation-secret > span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.invitation-bearer { display: block; overflow-wrap: anywhere; color: var(--heading); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: clamp(14px, 2.2vw, 19px); font-weight: 750; line-height: 1.5; user-select: all; }
.invitation-summary { display: grid; gap: 8px; margin: 18px 0; }
.invitation-summary div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; }
.invitation-summary dt { color: var(--muted); font-weight: 700; }
.invitation-summary dd { margin: 0; overflow-wrap: anywhere; }

.workflow-card { display: grid; gap: 18px; }
.workflow-action { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.workflow-action-wide { display: grid; }
.workflow-action-wide form { width: min(680px, 100%); }
.workflow-action-danger { padding: 16px; background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: 7px; }
.workflow-action h3 { margin-bottom: 4px; }

@media (max-width: 620px) {
  .workflow-action { align-items: stretch; flex-direction: column; }
  .workflow-action form .button { width: 100%; }
}

.auth-help { color: var(--muted); font-size: 11px; text-align: center; }
.auth-back { justify-self: center; font-size: 12px; }

.organization-card { width: min(460px, 100%); }

.organization-list {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.organization-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 11px;
  color: var(--heading);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.organization-option:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }
.organization-option:focus-within { border-color: var(--focus); }
.organization-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.organization-option-mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
}

.organization-option input:checked + .organization-option-mark { border: 5px solid var(--primary); }
.organization-option input:focus-visible + .organization-option-mark { outline: 3px solid var(--focus); outline-offset: 3px; }
.auth-logout { padding-top: 4px; border-top: 1px solid var(--border); }

.error-card { justify-items: stretch; text-align: center; }
.error-card .auth-brand { justify-self: start; text-align: left; }
.error-symbol { display: grid; place-items: center; width: 48px; height: 48px; margin: 2px auto -4px; color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: 50%; font-size: 23px; font-weight: 850; }

.support-details { color: var(--muted); font-size: 11px; text-align: left; }
.support-details summary { cursor: pointer; font-weight: 700; }
.support-details p { margin-top: 7px; overflow-wrap: anywhere; }

@media (hover: hover) {
  .nav-link:not(.is-disabled):hover { color: var(--heading); background: var(--surface-soft); }
  .nav-link.is-active:hover { color: var(--primary); background: var(--primary-soft); }
  .metric-card[href]:hover { border-color: var(--border-strong); box-shadow: 0 5px 16px rgba(26, 39, 68, .07); transform: translateY(-1px); }
  .button-primary:hover:not(:disabled) { background: var(--primary-hover); }
  .button-secondary:hover:not(:disabled) { color: var(--primary-hover); background: #d4e9ed; border-color: var(--focus); }
  .button-quiet:hover { color: var(--heading); background: var(--surface-soft); }
  .text-link:hover { color: var(--primary-hover); }
  tbody tr:hover { background: #fbfdfd; }
  .organization-option:hover { background: var(--surface-soft); }
}

@media (max-width: 860px) {
  :root { --sidebar-width: 72px; }
  .sidebar { padding-inline: 9px; }
  .brand { justify-content: center; margin-inline: 0; }
  .brand-copy,
  .nav-label,
  .service-state { display: none; }
  .nav-link { justify-content: center; padding-inline: 7px; }
  .nav-link .nav-icon { font-size: 18px; }
  .sidebar-foot { padding-inline: 0; }
  .metric-grid { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .form-grid-record { grid-template-columns: minmax(0, 1fr) minmax(120px, .55fr); }
  .form-grid-record .form-field:first-child { grid-column: 1 / -1; }
}

@media (max-width: 580px) {
  :root { --sidebar-width: 100%; }
  .app-layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 10px 12px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { justify-content: flex-start; margin: 0 0 8px; }
  .brand-copy { display: grid; }
  .sidebar-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
  .nav-link.is-disabled { display: none; }
  .nav-link { display: grid; justify-items: center; gap: 2px; min-height: 48px; padding: 5px 2px; font-size: 10px; text-align: center; }
  .nav-label { display: block; }
  .nav-link .nav-icon { font-size: 16px; }
  .sidebar-foot { display: none; }
  .topbar { position: static; min-height: 56px; padding: 7px 14px; }
  .account-user { max-width: 190px; }
  .main-content { padding: 22px 14px 38px; }
  .page-header,
  .page-header-actions { align-items: stretch; flex-direction: column; gap: 15px; }
  .page-header-actions .button { width: 100%; }
  .page-action-help { margin: -8px 0 16px; text-align: left; }
  .card { padding: 16px; }
  .table-card { padding: 0; }
  .table-card > .card-header { padding: 16px 16px 0; }
  th,
  td { padding: 11px 13px; }
  .auth-layout { padding: 14px; }
  .auth-card { padding: 22px 19px; }
  .form-grid-record { grid-template-columns: 1fr; }
  .form-grid-record .form-field:first-child { grid-column: auto; }
  .format-help dl div { grid-template-columns: 1fr; gap: 2px; }
}

@media (forced-colors: active) {
  .brand-mark,
  .button-primary,
  .button-secondary { border: 1px solid ButtonText; }
  .nav-link.is-active { box-shadow: none; outline: 1px solid currentColor; }
  .state-dot,
  .status-dot { border: 1px solid currentColor; }
}

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