:root {
  --portal-max: 1240px;
  --portal-header-h: 68px;
}

html { min-width: 320px; scroll-behavior: smooth; }
body { min-height: 100vh; }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ztc-space-2);
  padding: 0 var(--ztc-space-5);
  border: 1px solid transparent;
  border-radius: var(--ztc-radius-sm);
  font-weight: var(--ztc-weight-semibold);
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--ztc-duration-fast) var(--ztc-ease-standard),
              border-color var(--ztc-duration-fast) var(--ztc-ease-standard),
              color var(--ztc-duration-fast) var(--ztc-ease-standard);
}

.button:hover { text-decoration: none; }
.button.primary { background: var(--ztc-action); color: var(--ztc-action-ink); }
.button.primary:hover { background: var(--ztc-action-hover); color: var(--ztc-action-ink); }
.button.secondary { background: var(--ztc-surface-page); border-color: var(--ztc-border-strong); color: var(--ztc-action); }
.button.secondary:hover { background: var(--ztc-surface-hover); border-color: var(--ztc-action); }
.button.link { min-height: 44px; padding: 0 var(--ztc-space-2); background: transparent; color: var(--ztc-action); }
.button.link.danger { color: var(--ztc-error-ink); }
.button.wide { width: 100%; }

.eyebrow {
  color: var(--ztc-info-ink);
  font-size: var(--ztc-ui-xs);
  font-weight: var(--ztc-weight-bold);
  letter-spacing: .11em;
  text-transform: uppercase;
}

.eyebrow.light { color: #BEE8FA; }
.brand-rule { width: 56px; height: 4px; margin-bottom: var(--ztc-space-6); background: var(--ztc-accent-bar); }

.login-page { background: var(--ztc-surface-subtle); }
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
}

.login-card {
  width: min(100%, 620px);
  align-self: center;
  justify-self: end;
  padding: clamp(40px, 7vw, 96px);
}

.login-card h1 { margin-top: var(--ztc-space-3); font-size: clamp(34px, 4.2vw, 52px); max-width: 560px; }
.login-lead { margin-top: var(--ztc-space-5); color: var(--ztc-text-muted); font-size: var(--ztc-ui-lg); line-height: var(--ztc-leading-body); }
.boundary-note {
  display: grid;
  gap: var(--ztc-space-2);
  margin: var(--ztc-space-7) 0 var(--ztc-space-5);
  padding: var(--ztc-space-5);
  border-left: 4px solid var(--ztc-accent-bar);
  background: var(--ztc-surface-page);
}
.boundary-note span, .support-copy { color: var(--ztc-text-muted); line-height: var(--ztc-leading-body); }
.login-actions { display: grid; gap: var(--ztc-space-3); }
.support-copy { margin-top: var(--ztc-space-4); font-size: var(--ztc-ui-sm); }

.login-context {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(48px, 7vw, 108px);
  color: var(--ztc-text-on-dark);
  background: var(--ztc-surface-inverse);
}
.login-context h2 { max-width: 580px; margin-top: var(--ztc-space-3); font-size: clamp(30px, 3.2vw, 46px); }
.feature-list { display: grid; gap: var(--ztc-space-5); margin: var(--ztc-space-9) 0 0; padding: 0; list-style: none; }
.feature-list li { display: grid; grid-template-columns: 48px 1fr; gap: var(--ztc-space-4); align-items: start; padding-top: var(--ztc-space-5); border-top: 1px solid rgba(255,255,255,.24); }
.feature-list li > span { color: #BEE8FA; font-variant-numeric: tabular-nums; }
.feature-list strong, .feature-list small { display: block; }
.feature-list strong { font-size: var(--ztc-ui-lg); }
.feature-list small { margin-top: var(--ztc-space-1); color: rgba(255,255,255,.8); font-size: var(--ztc-ui-base); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--portal-header-h);
  border-bottom: 1px solid var(--ztc-border-default);
  background: rgba(255,255,255,.96);
}
.header-inner {
  width: min(calc(100% - 48px), var(--portal-max));
  min-height: var(--portal-header-h);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  gap: var(--ztc-space-6);
  align-items: center;
}
.brand { display: flex; align-items: center; gap: var(--ztc-space-3); color: var(--ztc-text-default); font-weight: var(--ztc-weight-semibold); }
.brand:hover { color: var(--ztc-text-default); text-decoration: none; }
.brand img { width: 112px; height: auto; }
.brand span { padding-left: var(--ztc-space-3); border-left: 1px solid var(--ztc-border-strong); }
.site-header nav { display: flex; align-items: stretch; align-self: stretch; }
.site-header nav a { position: relative; min-width: 96px; display: flex; align-items: center; justify-content: center; padding: 0 var(--ztc-space-3); color: var(--ztc-text-muted); font-weight: var(--ztc-weight-medium); }
.site-header nav a:hover { color: var(--ztc-action); text-decoration: none; background: var(--ztc-surface-hover); }
.site-header nav a[aria-current="page"] { color: var(--ztc-action); }
.site-header nav a[aria-current="page"]::after { content: ""; position: absolute; right: var(--ztc-space-3); bottom: 0; left: var(--ztc-space-3); height: 3px; background: var(--ztc-accent-bar); }
.user-menu { justify-self: end; display: flex; align-items: center; gap: var(--ztc-space-3); }
.user-menu > span { font-weight: var(--ztc-weight-semibold); }

.page-shell { width: min(calc(100% - 48px), var(--portal-max)); margin: 0 auto; padding: var(--ztc-space-8) 0 var(--ztc-space-10); }
.hero-compact { display: flex; align-items: end; justify-content: space-between; gap: var(--ztc-space-7); padding: var(--ztc-space-5) 0 var(--ztc-space-8); }
.hero-compact > div { min-width: 0; }
.hero-compact h1 { margin-top: var(--ztc-space-2); font-size: clamp(30px, 3.5vw, 44px); }
.hero-compact p:not(.eyebrow) { max-width: 720px; margin-top: var(--ztc-space-3); color: var(--ztc-text-muted); font-size: var(--ztc-ui-md); }
.hero-actions, .role-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--ztc-space-3); }
.role-pills span { padding: var(--ztc-space-2) var(--ztc-space-3); border: 1px solid var(--ztc-border-default); border-radius: var(--ztc-radius-pill); background: var(--ztc-surface-page); color: var(--ztc-text-muted); font-size: var(--ztc-ui-sm); }

.identity-strip, .admin-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--ztc-border-default);
  border-left: 4px solid var(--ztc-accent-bar);
  background: var(--ztc-surface-page);
}
.identity-strip > div, .admin-metrics > div { min-height: 94px; display: flex; flex-direction: column; justify-content: center; gap: var(--ztc-space-2); padding: var(--ztc-space-5); border-right: 1px solid var(--ztc-border-default); }
.identity-strip > div:last-child, .admin-metrics > div:last-child { border-right: 0; }
.identity-strip span, .admin-metrics span { color: var(--ztc-text-muted); font-size: var(--ztc-ui-sm); }
.identity-strip strong, .admin-metrics strong { font-size: var(--ztc-ui-lg); }
.admin-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: var(--ztc-space-7); }
.admin-metrics strong { font-size: var(--ztc-ui-2xl); font-variant-numeric: tabular-nums; }
.status-text.success { color: var(--ztc-success-ink); }

.section-block { margin-top: var(--ztc-space-9); }
.muted-section { padding: var(--ztc-space-7); border: 1px solid var(--ztc-border-default); background: var(--ztc-surface-subtle); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: var(--ztc-space-5); margin-bottom: var(--ztc-space-5); }
.section-heading h2 { margin-top: var(--ztc-space-1); font-size: var(--ztc-ui-2xl); }
.section-heading p { margin-top: var(--ztc-space-2); color: var(--ztc-text-muted); }
.count-badge { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--ztc-radius-pill); background: var(--ztc-tint-info-bg); color: var(--ztc-tint-info-fg); font-weight: var(--ztc-weight-semibold); }

.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ztc-space-5); }
.app-card { min-height: 214px; display: grid; grid-template-columns: 58px 1fr; gap: var(--ztc-space-4); padding: var(--ztc-space-6); border: 1px solid var(--ztc-border-default); border-radius: var(--ztc-radius-card); background: var(--ztc-surface-page); }
.app-mark { width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid var(--ztc-border-default); border-left: 4px solid var(--ztc-accent-bar); background: var(--ztc-surface-subtle); color: var(--ztc-action); font-family: var(--ztc-font-serif); font-size: var(--ztc-ui-xl); font-weight: var(--ztc-weight-bold); }
.app-card-body { min-width: 0; display: flex; flex-direction: column; }
.app-card-title { display: flex; align-items: start; justify-content: space-between; gap: var(--ztc-space-3); }
.app-card h3 { font-size: var(--ztc-ui-xl); }
.app-card p { margin-top: var(--ztc-space-3); color: var(--ztc-text-muted); line-height: var(--ztc-leading-body); }
.app-card-action { margin-top: auto; padding-top: var(--ztc-space-5); }
.disabled-action { min-height: 44px; display: inline-flex; align-items: center; color: var(--ztc-text-muted); font-weight: var(--ztc-weight-semibold); }

.status-tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--ztc-space-3); border-radius: var(--ztc-radius-pill); font-size: var(--ztc-ui-xs); font-weight: var(--ztc-weight-semibold); white-space: nowrap; }
.status-tag.active { background: var(--ztc-tint-success-bg); color: var(--ztc-tint-success-fg); }
.status-tag.planned { background: var(--ztc-tint-info-bg); color: var(--ztc-tint-info-fg); }
.status-tag.maintenance { background: var(--ztc-tint-warning-bg); color: var(--ztc-tint-warning-fg); }
.status-tag.retired { background: var(--ztc-surface-disabled); color: var(--ztc-text-muted); }

.help-panel, .boundary-card, .notice { display: flex; justify-content: space-between; align-items: center; gap: var(--ztc-space-6); margin-top: var(--ztc-space-9); padding: var(--ztc-space-6); border: 1px solid var(--ztc-border-default); border-left: 4px solid var(--ztc-accent-bar); background: var(--ztc-surface-page); }
.help-panel h2 { font-size: var(--ztc-ui-xl); }
.help-panel p, .boundary-card p { margin-top: var(--ztc-space-2); color: var(--ztc-text-muted); }
.boundary-card { display: block; }
.notice { margin: 0 0 var(--ztc-space-6); border-left-color: var(--ztc-success); background: var(--ztc-tint-success-bg); color: var(--ztc-success-ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--ztc-border-default); border-radius: var(--ztc-radius-md); background: var(--ztc-surface-page); }
.table-wrap table { min-width: 680px; }
.table-wrap th, .table-wrap td { padding: var(--ztc-space-3) var(--ztc-space-4); height: 52px; vertical-align: middle; }

.search-form { max-width: 720px; }
.search-form > label, .form-grid label, .stack-form label { display: grid; gap: var(--ztc-space-2); font-weight: var(--ztc-weight-semibold); }
.search-form > div { display: grid; grid-template-columns: 1fr auto; gap: var(--ztc-space-3); margin-top: var(--ztc-space-2); }
input, select { width: 100%; min-height: 44px; padding: 0 var(--ztc-space-3); border: 1px solid var(--ztc-border-strong); border-radius: var(--ztc-radius-sm); background: var(--ztc-surface-page); }
input:hover, select:hover { border-color: var(--ztc-action); }
small { color: var(--ztc-text-muted); font-weight: var(--ztc-weight-regular); line-height: var(--ztc-leading-ui); }

.inline-admin-panel { margin-top: var(--ztc-space-6); padding: var(--ztc-space-5); border: 1px solid var(--ztc-border-default); background: var(--ztc-surface-subtle); }
.inline-admin-panel h3 { font-size: var(--ztc-ui-lg); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: var(--ztc-space-4); align-items: end; margin-top: var(--ztc-space-4); }
.admin-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ztc-space-5); }
.admin-card { display: grid; grid-template-columns: 1.05fr .95fr; gap: var(--ztc-space-5); padding: var(--ztc-space-5); border: 1px solid var(--ztc-border-default); border-radius: var(--ztc-radius-card); }
.admin-card h3 { margin-top: var(--ztc-space-3); font-size: var(--ztc-ui-lg); }
.admin-card p { margin-top: var(--ztc-space-2); color: var(--ztc-text-muted); }
.stack-form { display: grid; gap: var(--ztc-space-3); }

.empty-state { min-height: 170px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--ztc-space-2); padding: var(--ztc-space-6); border: 1px dashed var(--ztc-border-strong); color: var(--ztc-text-muted); text-align: center; }
.empty-state strong { color: var(--ztc-text-default); font-size: var(--ztc-ui-lg); }

.site-footer { display: flex; justify-content: space-between; align-items: center; gap: var(--ztc-space-5); padding: var(--ztc-space-7) max(24px, calc((100% - var(--portal-max))/2)); border-top: 1px solid var(--ztc-border-default); background: var(--ztc-surface-subtle); color: var(--ztc-text-muted); font-size: var(--ztc-ui-sm); }
.site-footer div { display: flex; align-items: center; gap: var(--ztc-space-3); }
.site-footer strong { color: var(--ztc-text-default); }

.error-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--ztc-space-6); background: var(--ztc-surface-subtle); }
.error-shell section { width: min(100%, 560px); padding: var(--ztc-space-8); border: 1px solid var(--ztc-border-default); border-left: 4px solid var(--ztc-accent-bar); background: var(--ztc-surface-page); }
.error-shell h1 { margin-top: var(--ztc-space-3); font-size: var(--ztc-ui-3xl); }
.error-shell p:not(.eyebrow) { margin: var(--ztc-space-4) 0 var(--ztc-space-6); color: var(--ztc-text-muted); line-height: var(--ztc-leading-body); }

@media (max-width: 1040px) {
  .header-inner { grid-template-columns: 1fr auto; }
  .site-header nav { grid-row: 2; grid-column: 1 / -1; min-height: 48px; border-top: 1px solid var(--ztc-border-subtle); }
  .user-menu { grid-column: 2; grid-row: 1; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .admin-card { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-card { justify-self: center; padding: 52px 32px; }
  .login-context { padding: 52px 32px; }
  .header-inner, .page-shell { width: min(calc(100% - 32px), var(--portal-max)); }
  .brand span { display: none; }
  .hero-compact { align-items: start; flex-direction: column; }
  .hero-compact > div { width: 100%; }
  .hero-actions, .role-pills { justify-content: flex-start; }
  .card-grid, .admin-card-grid { grid-template-columns: 1fr; }
  .identity-strip { grid-template-columns: 1fr; }
  .identity-strip > div { border-right: 0; border-bottom: 1px solid var(--ztc-border-default); }
  .identity-strip > div:last-child { border-bottom: 0; }
  .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-metrics > div:nth-child(2) { border-right: 0; }
  .admin-metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--ztc-border-default); }
  .site-footer, .site-footer div { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .page-shell { width: min(calc(100% - 24px), var(--portal-max)); padding-top: var(--ztc-space-5); }
  .header-inner { width: min(calc(100% - 24px), var(--portal-max)); gap: var(--ztc-space-3); }
  .brand img { width: 92px; }
  .user-menu > span { display: none; }
  .site-header nav { overflow-x: auto; justify-content: flex-start; }
  .site-header nav a { min-width: max-content; padding: 0 var(--ztc-space-4); }
  .login-card, .login-context { padding: 40px 24px; }
  .login-card h1 { font-size: 34px; }
  .hero-compact { padding-bottom: var(--ztc-space-6); }
  .hero-compact h1 { font-size: 30px; }
  .hero-actions { width: 100%; display: grid; grid-template-columns: 1fr; }
  .hero-actions .button { width: 100%; min-width: 0; }
  .muted-section { margin-right: -12px; margin-left: -12px; padding: var(--ztc-space-5) var(--ztc-space-3); }
  .app-card { grid-template-columns: 1fr; padding: var(--ztc-space-5); }
  .app-mark { width: 44px; height: 44px; }
  .section-heading, .help-panel { align-items: flex-start; }
  .help-panel { flex-direction: column; }
  .search-form > div, .form-grid { grid-template-columns: 1fr; }
  .admin-metrics { grid-template-columns: 1fr; }
  .admin-metrics > div { border-right: 0; border-bottom: 1px solid var(--ztc-border-default); }
  .admin-metrics > div:last-child { border-bottom: 0; }
  .site-footer { padding: var(--ztc-space-6) var(--ztc-space-4); }
}

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