/* MTFDX SNS Factory R4 — design tokens (Owner-provided; matches design v1.1) */
:root {
  --nav: #102238;
  --nav-hover: #1b3352;
  --nav-active: #2563eb;
  --canvas: #f6f7f9;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4fd8;
  --text: #172b4d;
  --muted: #5b6a7b; /* R6: darkened from #64748b to reach WCAG AA 4.5:1 on canvas */
  --line: #dde3ec;
  --success: #00856b;
  --warning: #a65d00;
  --error: #c53939;
  --radius: 10px;
  --radius-sm: 6px;
  /* Design v1.1 界面尺寸: sidebar 220, topbar 64, body 16, label 14, title 28 */
  --sidebar-w: 220px;
  --topbar-h: 64px;
  --shadow: 0 1px 2px rgba(16, 34, 56, 0.06), 0 8px 24px rgba(16, 34, 56, 0.06);
  --font:
    "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button {
  font-family: inherit;
  font-size: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

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

/* Boot + shell */
.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--muted);
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.app-root {
  min-height: 100vh;
}
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #dbe4f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  padding: 20px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand strong {
  display: block;
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.brand span {
  display: block;
  color: #93a4bd;
  font-size: 12px;
  margin-top: 4px;
}
.brand-logo {
  display: block;
  height: 26px;
  width: auto;
  margin-bottom: 10px;
}
.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-foot .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #26385a;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 30px;
}
.sidebar-foot .sf-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.sidebar-foot .sf-text strong {
  color: #fff;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-foot .sf-text small {
  color: #93a4bd;
  font-size: 11px;
}
.nav {
  padding: 10px 8px 24px;
}
.nav-group {
  margin-top: 12px;
}
.nav-group > h2 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7f92ad;
  margin: 14px 12px 6px;
  font-weight: 600;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: #c7d3e4;
  font-size: 14px;
}
.nav-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #9db0cc;
}
.nav a[aria-current="page"] .nav-ico {
  color: #fff;
}
.nav a:hover {
  background: var(--nav-hover);
  text-decoration: none;
  color: #fff;
}
.nav a[aria-current="page"] {
  background: var(--nav-active);
  color: #fff;
  font-weight: 600;
}
.nav a .id {
  font-size: 10px;
  color: #8ea2bf;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}
.nav a[aria-current="page"] .id {
  color: #dbe8ff;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
  flex-wrap: nowrap;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.search-wrap {
  position: relative;
  flex: 0 1 380px;
  min-width: 0;
  max-width: 420px;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--muted);
}
.topbar-search input {
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 14px;
  width: 100%;
}
.topbar-search input:focus {
  outline: none;
}
.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.search-panel a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
}
.search-panel a:hover {
  background: var(--canvas);
  text-decoration: none;
}
.search-panel .kind {
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}
.search-panel .none {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}
.topbar-lead {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.topbar .crumbs {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.topbar .crumb-workspace {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.env-strip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fbf0dc;
  color: var(--warning);
  border: 1px solid #f2ddb8;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.topbar .spacer {
  flex: 1;
}
.user-chip {
  display: flex;
  align-items: center;
  white-space: nowrap;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--canvas);
}
.user-chip .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.role-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #e8eefb;
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}
.content {
  padding: 24px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* Page headers */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 28px;
  margin: 0;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.page-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Cards + grid */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card > h2 {
  font-size: 14px;
  margin: 0 0 12px;
}
.card > h2 .hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 8px;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  background: #eef2ff;
  color: var(--primary);
}
.stat.is-success .stat-icon {
  background: #e2f4ef;
  color: var(--success);
}
.stat.is-warning .stat-icon {
  background: #fbf0dc;
  color: var(--warning);
}
.stat.is-error .stat-icon {
  background: #fbe7e7;
  color: var(--error);
}
.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  padding: 10px 18px;
  margin: -8px 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}
.metric-strip strong {
  color: var(--text);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.stat .label {
  color: var(--muted);
  font-size: 12px;
}
.stat .value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat .value.small {
  font-size: 16px;
}
.stat.is-primary {
  border-left: 3px solid var(--primary);
}
.stat.is-success {
  border-left: 3px solid var(--success);
}
.stat.is-warning {
  border-left: 3px solid var(--warning);
}
.stat.is-error {
  border-left: 3px solid var(--error);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  min-height: 40px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.btn:hover {
  background: var(--canvas);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-danger {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(0.94);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
}
.btn-sm {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 13px;
}

/* Forms */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-row label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.form-row .help {
  font-size: 11.5px;
  color: var(--muted);
}
input[type="text"],
input[type="password"],
input[type="url"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}
.field-error {
  color: var(--error);
  font-size: 12px;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody td {
  height: 48px;
}
th {
  background: var(--canvas);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  position: sticky;
  top: 0;
}
tbody tr:hover {
  background: #fafbfd;
}
tbody tr:last-child td {
  border-bottom: none;
}
td .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* Badges + states */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-neutral {
  background: #eef1f5;
  color: var(--muted);
  border-color: #e2e6ec;
}
.badge-primary {
  background: #e8eefb;
  color: var(--primary);
  border-color: #d3dffb;
}
.badge-success {
  background: #e2f4ef;
  color: var(--success);
  border-color: #c4e8de;
}
.badge-warning {
  background: #fbf0dc;
  color: var(--warning);
  border-color: #f2ddb8;
}
.badge-error {
  background: #fbe7e7;
  color: var(--error);
  border-color: #f3cccc;
}

.state-block {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.state-block h3 {
  color: var(--text);
  margin: 0 0 6px;
}
.state-block .btn {
  margin-top: 12px;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--canvas);
  padding: 32px 20px;
}
.login-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-bottom: 18px;
  text-align: center;
}
.login-brand .login-logo {
  height: 40px;
  width: auto;
}
.login-brand h1 {
  font-size: 22px;
  margin: 0;
  color: var(--text);
}
.login-primary {
  width: 100%;
  justify-content: center;
  margin-bottom: 14px;
}
.demo-block {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--canvas);
  margin-top: 10px;
}
.demo-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}
.login-facts {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 8px;
}
.login-facts li {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.login-facts li::before {
  content: "✓";
  color: var(--success);
  font-weight: 700;
}
.login-art {
  background: var(--nav);
  color: #dbe4f0;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-art h1 {
  color: #fff;
  font-size: 26px;
  margin: 0 0 10px;
}
.login-art p {
  color: #a9b8cd;
  max-width: 42ch;
}
.login-art .facts {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 10px;
}
.login-art .facts li {
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: #c7d3e4;
}
.login-art .facts li::before {
  content: "✓";
  color: #5ee0b8;
  font-weight: 700;
}
.login-form-wrap {
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--surface);
}
.login-form {
  width: 100%;
  max-width: 360px;
}
.login-form h2 {
  margin: 0 0 4px;
  font-size: 20px;
}
.login-form .sub {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 13px;
}
.login-env {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}
.cred-hint {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--canvas);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted);
}
.cred-hint code {
  font-family: ui-monospace, Menlo, monospace;
  color: var(--text);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 34, 56, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(16, 34, 56, 0.3);
}
.modal header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal header h2 {
  margin: 0;
  font-size: 15px;
}
.modal .body {
  padding: 18px 20px;
}
.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

/* Toast */
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 60;
  max-width: 380px;
}
.toast {
  background: var(--surface);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 13px;
}
.toast.success {
  border-left-color: var(--success);
}
.toast.error {
  border-left-color: var(--error);
}
.toast.warning {
  border-left-color: var(--warning);
}

/* Misc */
dl.meta {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 13px;
}
dl.meta dt {
  color: var(--muted);
}
dl.meta dd {
  margin: 0;
  word-break: break-word;
}
.kv-list {
  display: grid;
  gap: 8px;
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tabs button {
  border: none;
  background: transparent;
  padding: 9px 14px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.muted {
  color: var(--muted);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}
.stack {
  display: grid;
  gap: 12px;
}
.inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-cell {
  background: var(--surface);
  min-height: 96px;
  padding: 8px;
}
.cal-cell .day {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.cal-cell.today .day {
  color: var(--primary);
}
.cal-item {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  padding: 3px 5px;
  border-radius: 4px;
  background: #e8eefb;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-head {
  background: var(--canvas);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
  font-weight: 700;
}
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}
.timeline li {
  position: relative;
  padding: 0 0 16px 22px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.timeline li.ok::before {
  background: var(--success);
}
.timeline li.warn::before {
  background: var(--warning);
}
.timeline li.err::before {
  background: var(--error);
}
.matrix td.yes {
  color: var(--success);
  font-weight: 700;
}
.matrix td.no {
  color: var(--muted);
}
.check-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: grid;
  gap: 8px;
}
.check-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.check-list li::before {
  content: "✓";
  color: var(--success);
  font-weight: 700;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 10px 0;
}
.checkbox-row input {
  width: auto;
}
.preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  background: var(--canvas);
}
.preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.preview-head .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--nav);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.preview-body {
  display: grid;
  gap: 8px;
}
.preview-body .muted {
  font-size: 12px;
}

@media (max-width: 1024px) {
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 820px) {
  .env-strip,
  .topbar .crumb-workspace {
    display: none;
  }
  .search-wrap {
    display: none;
  }
  .btn,
  .btn-sm {
    min-height: 44px;
  }
  .nav a {
    min-height: 44px;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .nav {
    display: block;
  }
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-art {
    display: none;
  }
}
@media (max-width: 620px) {
  .content {
    padding: 16px;
  }
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }
  dl.meta {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  dl.meta dt {
    margin-top: 8px;
  }
  .page-head .actions {
    margin-left: 0;
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
  * {
    transition: none !important;
  }
}

/* ---------------------------------------------- R5 additions */

.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;
}
.sub-h {
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.code-block {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  overflow: auto;
  max-height: 240px;
  white-space: pre-wrap;
}
.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
}
.attention-box {
  border: 1px solid #f2ddb8;
  background: #fbf0dc;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
}
.attention-box h3 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--warning);
}
.attention-box p {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--text);
}

/* Tabs / filters / pager */
.tabbar {
  gap: 2px;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.filter-bar input[type="search"] {
  max-width: 320px;
}
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 12px;
}
.radio-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.radio input {
  width: auto;
}

/* Overview layout */
.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.overview-main {
  min-width: 0;
}
.overview-rail {
  display: grid;
  gap: 16px;
}
.tl {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tl li {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.tl li:last-child {
  border-bottom: none;
}
.tl-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  min-width: 44px;
}
.tl-body {
  min-width: 0;
  font-size: 13px;
}
.pipeline {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
}
.pipeline li {
  position: relative;
  padding-left: 18px;
}
.pipeline-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}
.pipeline-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.pipeline-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Stage track (task detail) */
.stage-track {
  list-style: none;
  display: flex;
  gap: 6px;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}
.stage-track li {
  flex: 1 1 120px;
  min-width: 110px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--canvas);
}
.stage-track li.done {
  border-color: #c4e8de;
  background: #e2f4ef;
  color: var(--success);
  font-weight: 600;
}
.stage-index {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid currentColor;
  font-size: 10px;
  margin-right: 6px;
}

/* Account tags */
.tag-list .badge {
  text-transform: none;
}

/* Candidate list + review layout */
.review-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.candidate-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.candidate-list li a {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.candidate-list li a:hover {
  background: var(--canvas);
  text-decoration: none;
}
.candidate-list li.active a {
  border-color: var(--primary);
  background: #eef3fe;
}

/* Calendar week view */
.calendar-toolbar {
  justify-content: space-between;
  margin-bottom: 8px;
}
.legend {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12px;
}
.lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lg::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.ev-scheduled::before,
.lg.ev-scheduled::before {
  background: var(--primary);
}
.ev-published::before,
.lg.ev-published::before {
  background: var(--success);
}
.ev-attention::before,
.lg.ev-attention::before {
  background: var(--warning);
}
.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}
.cal-main {
  min-width: 0;
}
.cal-rail {
  display: grid;
  gap: 16px;
}
.week-grid {
  display: grid;
  grid-template-columns: 64px repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}
.week-corner,
.week-day,
.week-hour,
.week-cell {
  background: var(--surface);
}
.week-corner {
  padding: 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.week-day {
  padding: 8px;
  font-size: 12px;
  text-align: center;
}
.week-day.today {
  background: #eef3fe;
}
.week-day .muted {
  font-size: 10.5px;
}
.week-hour {
  padding: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.week-cell {
  min-height: 74px;
  padding: 6px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.week-cell-other {
  min-height: 52px;
}
.cal-event {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid #d3dffb;
  border-left-width: 3px;
  background: #f4f7fe;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text);
}
.cal-event.ev-scheduled {
  border-left-color: var(--primary);
}
.cal-event.ev-published {
  border-left-color: var(--success);
  background: #eef8f5;
}
.cal-event.ev-attention {
  border-left-color: var(--warning);
  background: #fdf6ea;
}
.cal-event:hover {
  filter: brightness(0.98);
}
.cal-event .badge {
  margin-top: 4px;
  font-size: 10px;
}

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 34, 56, 0.28);
  z-index: 55;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 92vw);
  background: var(--surface);
  box-shadow: -12px 0 40px rgba(16, 34, 56, 0.22);
  z-index: 56;
  display: flex;
  flex-direction: column;
}
.drawer header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.drawer header h2 {
  margin: 0;
  font-size: 15px;
  flex: 1;
}
.drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
}

@media (max-width: 1100px) {
  .overview-layout,
  .cal-layout,
  .review-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 820px) {
  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .week-grid {
    grid-template-columns: 52px repeat(7, minmax(70px, 1fr));
    overflow-x: auto;
  }
}
@media (max-width: 620px) {
  .pipeline {
    grid-template-columns: 1fr;
  }
  .calendar-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

.sso-note {
  font-size: 11.5px;
  margin-top: 10px;
}
.form-row .help {
  font-size: 11.5px;
  color: var(--muted);
}

/* ------------------------------------------- R6 accessibility hardening */

/*
 * Badge text is 11px (below WCAG "large text"), so it must reach 4.5:1. The
 * badge foregrounds are darkened here without changing the shared semantic
 * tokens used by links, buttons and statuses.
 */
.badge-primary {
  color: #1d4ed8;
}
.badge-success {
  color: #006b56;
}
.badge-warning {
  color: #8a4e00;
}
.badge-error {
  color: #a92f2f;
}

/* Long machine identifiers must wrap instead of forcing horizontal scroll. */
.meta dd,
.mono,
td {
  overflow-wrap: anywhere;
}

/* Collapsible raw ledger keeps the control page at design height. */
.raw-details {
  margin-top: 10px;
}
.raw-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  padding: 4px 0;
}
.raw-details summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.raw-details .code-block {
  max-height: 320px;
  overflow: auto;
  margin-top: 8px;
}

/* Keep the modal reachable and scrollable on short viewports. */
.modal {
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* Grid/flex children must be shrinkable or wide tables force page overflow. */
.grid > * {
  min-width: 0;
}
.overview-layout > *,
.cal-layout > *,
.review-layout > * {
  min-width: 0;
}

/* Mobile: toolbars wrap instead of pushing the document wider than the viewport. */
@media (max-width: 620px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }
  .topbar .user-chip {
    max-width: 100%;
  }
  .page-head,
  .page-head .actions,
  .filter-bar,
  .form-actions,
  .calendar-toolbar,
  .radio-row {
    flex-wrap: wrap;
  }
}
