:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #fff5f5;
  --text: #1f2328;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #c1121f;
  --brand-dark: #8f0d17;
  --brand-soft: #fff1f2;
  --gold: #b7791f;
  --green: #0f766e;
  --danger: #a10f1d;
  --shadow: 0 18px 48px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

button {
  touch-action: manipulation;
}

a {
  color: inherit;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(193, 18, 31, 0.24);
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 13px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a,
.ghost-button {
  color: var(--text);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 500;
}

.topnav a:hover,
.ghost-button:hover {
  background: var(--brand-soft);
  border-color: #fecdd3;
  color: var(--brand-dark);
}

.public-shell,
.admin-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.home-dashboard,
.unit-picker,
.content-panel,
.admin-section,
.admin-sidebar,
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.home-dashboard {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.hero-copy {
  min-height: 280px;
  padding: 34px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #c1121f 0%, #8f0d17 48%, #252b36 100%);
}

.hero-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
}

.hero-copy p {
  max-width: 780px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 16px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.stat-grid {
  display: grid;
  gap: 10px;
}

.stat-card {
  display: grid;
  align-content: center;
  min-height: 86px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-card span {
  font-size: 28px;
  font-weight: 900;
  color: var(--brand-dark);
}

.stat-card small {
  color: var(--muted);
  font-weight: 500;
}

.workflow-strip,
.process-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.workflow-strip article,
.process-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.workflow-strip strong,
.process-grid strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-dark);
}

.workflow-strip span,
.process-grid span {
  color: var(--muted);
  line-height: 1.5;
}

.unit-picker,
.content-panel {
  margin-top: 18px;
  padding: 22px;
}

.section-title,
.site-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.section-title {
  margin-bottom: 16px;
}

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

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

h3 {
  font-size: 20px;
  line-height: 1.25;
}

.page-rich-content {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.page-rich-content > *:first-child {
  margin-top: 0;
}

.page-rich-content > *:last-child {
  margin-bottom: 0;
}

.page-rich-content p,
.page-rich-content div {
  margin: 0 0 14px;
}

.page-rich-content h2,
.page-rich-content h3,
.page-rich-content h4 {
  margin: 22px 0 10px;
  color: var(--text);
  line-height: 1.25;
}

.page-rich-content h2 {
  font-size: 24px;
}

.page-rich-content h3 {
  font-size: 20px;
}

.page-rich-content h4 {
  font-size: 17px;
}

.page-rich-content ul,
.page-rich-content ol {
  margin: 0 0 14px 22px;
  padding: 0;
}

.page-rich-content li {
  margin: 5px 0;
  padding-left: 4px;
}

.page-rich-content blockquote {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #fff7f7;
  color: var(--text);
}

.page-rich-content hr {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: var(--line);
}

.page-rich-content a {
  color: var(--brand);
  font-weight: 700;
}

.page-rich-content table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.page-rich-content th,
.page-rich-content td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.page-rich-content th {
  background: #fff7f7;
  color: var(--text);
  font-weight: 900;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--brand);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
}

.hero-copy .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.picker-tools,
.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 340px);
  gap: 12px;
}

.searchbox,
.select-label,
.unit-switcher,
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select {
  text-overflow: ellipsis;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(193, 18, 31, 0.13);
}

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

.unit-card,
.doc-item,
.admin-doc-item,
.audit-item,
.menu-item {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  text-align: left;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.unit-card,
.menu-item,
.admin-doc-item {
  cursor: pointer;
}

.unit-card:hover,
.menu-item:hover,
.admin-doc-item:hover,
.doc-item:hover {
  transform: translateY(-1px);
  border-color: #fca5a5;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.09);
}

.unit-card strong,
.doc-item strong,
.admin-doc-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.unit-card span,
.unit-card small,
.doc-item p,
.admin-doc-item p {
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.unit-card small {
  display: inline-flex;
  margin-top: 10px;
  color: var(--brand);
  font-weight: 800;
}

.unit-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.unit-toolbar .unit-switcher {
  width: min(440px, 100%);
}

.site-head {
  padding: 28px;
  margin: -22px -22px 0;
  color: #fff;
  background: linear-gradient(135deg, #c1121f 0%, #8f0d17 50%, #293241 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.site-head .eyebrow,
.site-head #site-summary,
.site-head .site-contact {
  color: rgba(255, 255, 255, 0.84);
}

.site-head h2 {
  margin-bottom: 8px;
  font-size: clamp(26px, 4vw, 42px);
}

.site-contact {
  display: grid;
  gap: 6px;
  min-width: 220px;
  text-align: right;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 16px 0 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-button,
.secondary-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 700;
}

.tab-button.active,
.primary-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(193, 18, 31, 0.18);
}

.primary-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

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

.page-view,
.documents-band {
  padding-top: 22px;
}

.page-view p,
.page-content p,
.doc-item p {
  color: var(--muted);
  line-height: 1.65;
}

.page-content {
  display: grid;
  gap: 14px;
}

.org-chart {
  min-width: 0;
}

.org-chart-tree {
  display: grid;
  gap: 22px;
  padding: 10px 0 2px;
}

.org-tier {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.org-tier + .org-tier::before {
  content: "";
  position: absolute;
  top: -18px;
  left: 50%;
  width: 2px;
  height: 18px;
  background: #fecdd3;
}

.org-tier-deputy::after,
.org-tier-staff::after {
  content: "";
  position: absolute;
  top: -18px;
  left: 18%;
  right: 18%;
  height: 2px;
  background: #fecdd3;
}

.org-member-card {
  width: min(260px, 100%);
  min-width: 220px;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.06);
  text-align: center;
}

.org-member-head {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff7f7, #fff);
}

.org-member-deputy {
  border-color: #fed7aa;
}

.org-role {
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
}

.org-member-card strong {
  text-align: center;
  overflow-wrap: anywhere;
}

.org-position {
  color: var(--muted);
  line-height: 1.45;
  min-height: 18px;
  text-align: center;
}

.org-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.org-contact.has-email.has-phone .org-phone::before {
  content: "\00b7";
  margin-right: 8px;
  color: #98a2b3;
}

.org-email {
  color: var(--brand-dark);
  text-decoration: none;
}

.pdf-viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.pdf-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.pdf-viewer-toolbar .secondary-button {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
}

.pdf-zoom-btn {
  width: 38px;
  padding-inline: 0 !important;
  font-size: 18px;
  line-height: 1;
}

.pdf-zoom-label {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.pdf-exit-fullscreen {
  display: none !important;
}

.document-preview-shell:fullscreen .pdf-exit-fullscreen,
.public-document-preview-shell:fullscreen .pdf-exit-fullscreen {
  display: inline-flex !important;
}

.pdf-pan-viewport {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  background: #f8fafc;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
}

.pdf-zoom-stage {
  min-width: 100%;
  min-height: 100%;
  background: #fff;
}

.document-preview-shell:fullscreen,
.public-document-preview-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  background: #111827;
}

.document-preview-shell:fullscreen .pdf-pan-viewport,
.public-document-preview-shell:fullscreen .pdf-pan-viewport {
  height: calc(100vh - 52px);
}

.document-preview-shell:fullscreen iframe,
.public-document-preview-shell:fullscreen iframe {
  width: 100vw;
  height: calc(100vh - 52px);
  min-height: calc(100vh - 52px);
}

.documents-band {
  margin-top: 10px;
}

.document-list,
.admin-doc-list,
.audit-list,
.menu-list {
  display: grid;
  gap: 10px;
}

.document-list {
  margin-top: 12px;
}

.inspection-upload-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fffafa;
}

.inspection-upload-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.inspection-upload-head strong {
  display: block;
  color: var(--text);
}

.inspection-upload-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inspection-upload-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.inspection-upload-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inspection-upload-table {
  min-width: 1120px;
}

.inspection-upload-table td {
  vertical-align: top;
}

.inspection-upload-table input,
.inspection-upload-table textarea,
.inspection-upload-table select {
  width: 100%;
}

.inspection-upload-table textarea {
  margin-top: 6px;
  resize: vertical;
}

.inspection-upload-table label {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inspection-row-status {
  display: block;
  min-width: 160px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.metrics-admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 14px;
  align-items: start;
}

.metric-admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric-admin-table {
  min-width: 980px;
}

.metric-admin-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
}

.metric-json-field {
  grid-column: 1 / -1;
}

.tt20-admin-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tt20-heading {
  display: flex;
  gap: 14px;
  align-items: end;
  justify-content: space-between;
}

.tt20-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.tt20-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.tt20-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, .8fr) minmax(150px, .6fr);
  gap: 8px;
  width: min(760px, 100%);
}

.tt20-filter-row input,
.tt20-filter-row select {
  width: 100%;
}

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

.tt20-summary-card {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
}

.tt20-summary-card strong {
  color: var(--brand);
  font-size: 22px;
  line-height: 1;
}

.tt20-summary-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.tt20-admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .55fr);
  gap: 14px;
  align-items: start;
}

.tt20-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tt20-table {
  min-width: 1120px;
}

.tt20-table td {
  vertical-align: top;
}

.tt20-table small,
.tt20-table em,
.tt20-form-context small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.35;
}

.tt20-table em {
  max-width: 420px;
}

.evidence-stack {
  display: grid;
  gap: 4px;
  align-items: start;
}

.text-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

.text-action:hover,
.text-action:focus-visible {
  color: var(--brand-dark);
}

.tt20-value-form textarea {
  resize: vertical;
}

.tt20-form-context {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: var(--brand-soft);
}

.checklist-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.checklist-summary-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.checklist-summary-card strong {
  color: var(--brand);
  font-size: 24px;
  line-height: 1;
}

.checklist-summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.checklist-guidance {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.checklist-guidance strong {
  color: var(--brand);
}

.checklist-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.checklist-table {
  min-width: 1180px;
}

.checklist-table td {
  vertical-align: top;
}

.checklist-title-cell small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.checklist-table select,
.checklist-table input,
.checklist-table textarea {
  width: 100%;
}

.checklist-evidence-url,
.checklist-note {
  margin-top: 8px;
}

.public-metrics {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.metric-public-group h4 {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 16px;
}

.metric-public-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.metric-public-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric-public-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.metric-public-item strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.metric-public-item small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.doc-meta,
.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.status-badge,
.meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
}

.status-badge {
  flex: 0 0 auto;
}

.status-draft {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}

.status-submitted {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.status-needs-revision {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.status-rejected {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.status-approved {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.status-published {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.status-archived,
.status-obsolete {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #4b5563;
}

.category-pill {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.classification-public,
.classification-low {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.classification-internal {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.classification-sensitive,
.classification-special {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.doc-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.doc-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 0;
  padding: 6px 8px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.doc-link:hover {
  background: var(--brand-soft);
}

.doc-preview-action {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.doc-preview-action:hover {
  background: var(--brand-dark);
}

.doc-download-action {
  color: var(--brand-dark);
}

.doc-link[hidden] {
  display: none;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 18px;
}

.admin-workspace.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.admin-workspace.sidebar-collapsed .admin-sidebar {
  display: none;
}

.admin-workspace > *,
.admin-main,
.admin-section {
  min-width: 0;
}

.admin-sidebar {
  display: grid;
  gap: 16px;
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.admin-main {
  display: grid;
  gap: 18px;
}

.workspace-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 44px;
}

.admin-section {
  padding: 22px;
}

.user-card {
  display: grid;
  gap: 4px;
  padding: 13px;
  border-radius: 8px;
  background: var(--brand-soft);
  border: 1px solid #fecdd3;
}

.user-card span,
.metric-grid small,
.section-title span {
  color: var(--muted);
}

.role-switch-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff7f7;
}

.role-switch-card strong {
  color: var(--brand);
}

.role-switch-card small {
  color: var(--muted);
  line-height: 1.45;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav button {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.admin-nav button:hover,
.admin-nav button.active {
  background: var(--brand-soft);
  border-color: #fecdd3;
  color: var(--brand-dark);
}

.bottom-nav a.active {
  background: var(--brand);
  color: #fff;
}

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

.metric-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.metric-grid span {
  display: block;
  font-weight: 900;
  font-size: 23px;
  color: var(--brand-dark);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  gap: 14px;
}

.menu-item.active,
.admin-doc-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-item strong {
  margin-bottom: 0;
  min-width: 0;
}

.admin-doc-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.admin-doc-title-row strong {
  margin-bottom: 0;
}

.admin-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.doc-date {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

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

.category-list {
  display: grid;
  gap: 10px;
}

.category-admin-item,
.dss-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-admin-item strong,
.dss-card strong {
  display: block;
  margin-bottom: 6px;
}

.category-admin-item p,
.dss-card p {
  color: var(--muted);
  line-height: 1.55;
}

.dss-card {
  display: grid;
  gap: 10px;
  align-content: start;
}

.dss-qr-wrap,
.dss-sms-confirm {
  display: grid;
  gap: 10px;
}

.dss-qr-wrap img {
  width: min(220px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.backup-code-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.backup-code-list code {
  display: block;
  padding: 10px;
  border: 1px dashed #fda4af;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  white-space: normal;
  overflow-wrap: anywhere;
}

.phone-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.phone-row span {
  color: var(--muted);
  font-weight: 700;
}

.login-panel {
  min-height: calc(100vh - 116px);
  display: grid;
  place-items: center;
  padding: 22px 0;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-help {
  color: var(--muted);
  line-height: 1.55;
}

.login-card form,
.editor-form,
.document-form {
  display: grid;
  gap: 12px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-actions button {
  min-height: 48px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.document-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 14px;
}

.document-form > label:nth-of-type(1),
.document-form .doc-form-section,
.document-form .upload-panel,
.document-form .button-row,
.document-form .dss-status {
  grid-column: 1 / -1;
}

.doc-form-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
}

.doc-form-section h3 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 14px;
}

.doc-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.upload-panel {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.upload-file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.upload-status {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.dss-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--danger);
  font-weight: 700;
}

.empty-state {
  padding: 16px;
  border: 1px dashed #fda4af;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--muted);
}

.bottom-nav {
  display: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1080px) {
  .hero-panel,
  .admin-workspace,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .workflow-strip,
  .process-grid,
  .unit-grid,
  .category-admin-grid,
  .dss-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-sidebar {
    position: static;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 64px;
    padding: 10px 14px;
    align-items: flex-start;
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand small {
    font-size: 12px;
  }

  .brand {
    align-items: flex-start;
    gap: 10px;
    flex: 1 1 auto;
  }

  .brand span:last-child {
    min-width: 0;
  }

  .topnav {
    display: none;
  }

  .public-shell,
  .admin-shell {
    width: 100%;
    padding: 10px;
  }

  .home-dashboard,
  .unit-picker,
  .content-panel,
  .admin-section {
    padding: 14px;
  }

  .hero-copy {
    min-height: auto;
    padding: 20px;
  }

  .hero-copy h1 {
    font-size: 32px;
    line-height: 1.08;
  }

  .hero-actions,
  .unit-toolbar,
  .section-title,
  .site-head {
    display: grid;
  }

  .workflow-strip,
  .process-grid,
  .unit-grid,
  .auth-actions,
  .picker-tools,
  .filters,
  .document-form,
  .doc-field-grid,
  .upload-panel,
  .inspection-upload-fields,
  .metric-grid,
  .category-admin-grid,
  .dss-grid {
    grid-template-columns: 1fr;
  }

  .inspection-upload-head {
    display: grid;
  }

  .inspection-upload-table {
    min-width: 920px;
  }

  input,
  select,
  textarea,
  button,
  .primary-button,
  .secondary-button,
  .ghost-button {
    max-width: 100%;
    min-height: 44px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    white-space: normal;
    text-align: center;
  }

  .admin-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .admin-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 12px;
  }

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

  .admin-nav button {
    justify-content: center;
    min-height: 46px;
    padding: 9px 8px;
    font-size: 13px;
    line-height: 1.2;
    text-align: center;
  }

  .workspace-toolbar {
    display: none;
  }

  .admin-main {
    gap: 12px;
  }

  .metrics-admin-layout {
    grid-template-columns: 1fr;
  }

  .tt20-heading,
  .tt20-admin-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .tt20-filter-row {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .tt20-table {
    min-width: 980px;
  }

  .metric-admin-table {
    min-width: 820px;
  }

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

  .checklist-table {
    min-width: 980px;
  }

  .admin-doc-title-row,
  .admin-doc-meta {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-badge,
  .meta-pill {
    width: fit-content;
    white-space: normal;
    text-align: left;
  }

  .doc-date {
    margin-left: 0;
    text-align: left;
  }

  .site-head {
    margin: -14px -14px 0;
    padding: 20px;
  }

  .site-contact {
    min-width: 0;
    text-align: left;
  }

  .unit-toolbar .unit-switcher {
    width: 100%;
  }

  .tabs {
    padding-top: 12px;
    margin-inline: -2px;
  }

  .tab-button {
    min-width: max-content;
  }

  .org-tier {
    display: grid;
    grid-template-columns: 1fr;
  }

  .org-tier-deputy::after,
  .org-tier-staff::after {
    display: none;
  }

  .org-member-card {
    width: 100%;
    min-width: 0;
  }

  .bottom-nav {
    position: fixed;
    left: 10px;
    bottom: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 6px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    padding: 7px;
    padding-bottom: calc(7px + env(safe-area-inset-bottom));
    border: 1px solid rgba(228, 231, 236, 0.95);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 18px 42px rgba(17, 24, 39, 0.18);
    backdrop-filter: blur(14px);
  }

  .bottom-nav a {
    min-width: 0;
    min-height: 46px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
  }

  .bottom-nav span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bottom-nav a:focus,
  .bottom-nav a:active,
  .bottom-nav a.active {
    background: var(--brand);
    color: #fff;
    outline: none;
  }
}

@media (max-width: 430px) {
  .topbar {
    padding: 9px 10px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small {
    display: none;
  }

  .public-shell,
  .admin-shell {
    padding: 8px;
  }

  .home-dashboard,
  .unit-picker,
  .content-panel,
  .admin-section,
  .admin-sidebar,
  .login-card {
    padding: 12px;
  }

  .hero-copy {
    padding: 18px;
  }

  .hero-copy h1 {
    font-size: 28px;
  }

  .hero-copy p {
    font-size: 14px;
  }

  .admin-nav {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    left: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }

  .bottom-nav a {
    font-size: 11px;
  }
}
