:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #eef4f2;
  --line: #d9e0e6;
  --text: #17202a;
  --muted: #617182;
  --primary: #176d78;
  --primary-strong: #0f5660;
  --accent: #2f6fed;
  --success: #258455;
  --warning: #b76c18;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(31, 46, 61, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #13252b;
  color: #e9f1f2;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #dbeee9;
  color: #0f5660;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.brand span,
.sidebar-note span {
  color: #a7bac0;
  font-size: 12px;
}

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

.nav-item {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #c9d5d8;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #234148;
  color: #ffffff;
}

.nav-item svg,
.btn svg,
.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  flex: none;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 4px;
}

.sidebar-note strong {
  word-break: break-all;
  font-size: 12px;
  color: #ffffff;
  font-weight: 600;
}

.main {
  min-width: 0;
  padding: 22px 28px 38px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1,
.dialog h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p,
.dialog p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-actions,
.toolbar,
.row-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #eef6f5;
  color: #244650;
  font-size: 12px;
  font-weight: 800;
}

.btn,
.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  font-weight: 600;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
  border-color: #f0c5c0;
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.section-head h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.panel-head p,
.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 20px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 12px;
}

.chart-card h3 {
  margin: 0 0 10px;
  color: #243341;
  font-size: 14px;
}

.pie-layout {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.pie {
  width: 112px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 14px rgba(255, 255, 255, 0.72);
}

.pie span {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 900;
}

.legend {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: #344553;
  font-size: 12px;
}

.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ratio-card {
  display: grid;
  gap: 8px;
}

.ratio-card strong {
  font-size: 24px;
  color: var(--primary);
}

.ratio-card span {
  color: var(--muted);
  font-weight: 800;
}

.bar-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebf0;
}

.bar-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  margin-top: 16px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(2, minmax(140px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.filters label,
.form-grid label,
.field label,
.compact-field {
  display: grid;
  gap: 6px;
  color: #2d3b48;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cad4dc;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  min-height: 36px;
  padding: 8px 10px;
  outline: 0;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 109, 120, 0.13);
}

.table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #f1f5f7;
  color: #475866;
  font-size: 12px;
  font-weight: 800;
}

tbody tr {
  background: #ffffff;
}

tbody tr:hover,
tbody tr.selected {
  background: #edf7f5;
}

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.empty.small {
  padding: 16px 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #435260;
  font-size: 12px;
  font-weight: 700;
}

.badge.green {
  background: #e1f4eb;
  color: #14623e;
}

.badge.blue {
  background: #e7efff;
  color: #214f9a;
}

.badge.amber {
  background: #fff1dc;
  color: #8b4c12;
}

.badge.gray {
  background: #eef1f3;
  color: #6f7c86;
}

.badge.red {
  background: #fee8e5;
  color: #a12b22;
}

.subject-summary {
  display: grid;
  gap: 10px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.summary-row span {
  color: var(--muted);
}

.summary-row strong {
  text-align: right;
}

.crf-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
}

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

.form-group-label {
  margin: 10px 2px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-nav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  min-height: 38px;
  padding: 0 10px;
  color: #334351;
  text-align: left;
}

.form-nav-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: normal;
  line-height: 1.35;
}

.visit-badge {
  min-width: 38px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #dfeeed;
  color: #155e68;
  font-size: 11px;
  font-weight: 900;
}

.form-nav button:hover,
.form-nav button.active {
  border-color: var(--line);
  background: #eef6f5;
}

.form-nav button.locked {
  border-color: #e2e7ea;
  background: #f4f6f7;
  color: #78858e;
}

.form-nav button.locked .visit-badge {
  background: #e3e8eb;
  color: #7b8790;
}

.form-nav button.locked.active {
  border-color: #cbd5da;
  background: #edf1f3;
}

.form-section {
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

fieldset.form-grid {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.field.full,
.table-field,
.repeater-field,
.note,
.section-field,
.ohs-field {
  grid-column: 1 / -1;
}

.field-title {
  color: #243341;
  font-weight: 800;
  margin: 6px 0 0;
}

.field-help {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.section-field {
  border-left: 4px solid var(--primary);
  background: #f3f8f7;
  padding: 12px 14px;
  border-radius: var(--radius);
}

.section-field h4 {
  margin: 0;
  color: #183840;
  font-size: 15px;
}

.section-field p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.radio-row,
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.computed-group {
  opacity: 0.9;
}

.computed-group .choice {
  background: #f4f7f9;
}

.choice {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: #263542;
  font-weight: 600;
}

.choice input {
  width: auto;
  min-height: auto;
}

.compact-row,
.cell-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-choice {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.note {
  background: var(--surface-alt);
  border: 1px solid #cfe0dc;
  border-radius: var(--radius);
  color: #36515a;
  padding: 10px 12px;
  line-height: 1.55;
}

.data-table input,
.data-table select {
  min-width: 92px;
}

.data-table td:first-child {
  white-space: normal;
  min-width: 160px;
  font-weight: 700;
  color: #31414f;
}

.repeater-item {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) 38px;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: #fbfcfd;
}

.auto-cover-field,
.assignment-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
}

.auto-cover-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.auto-cover-summary div,
.assignment-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 12px;
}

.auto-cover-summary span,
.assignment-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.auto-cover-summary strong,
.assignment-card strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.assignment-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
}

.assignment-card.assigned {
  background: #edf7f5;
  border-color: #c7dfdc;
}

.assignment-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.attachment-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 12px;
}

.attachment-head,
.attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.attachment-head p {
  margin: 5px 0 0;
}

.attachment-list {
  display: grid;
  gap: 8px;
}

.attachment-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.attachment-row strong,
.attachment-row span {
  display: block;
}

.attachment-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.completion-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  padding: 16px;
}

.table-wrap.no-top {
  border-top: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary-table-wrap {
  max-height: calc(100vh - 220px);
  overflow: auto;
  border-top: 1px solid var(--line);
}

.summary-table {
  min-width: 900px;
}

.summary-table th,
.summary-table td {
  max-width: 280px;
  white-space: normal;
  vertical-align: top;
}

.summary-table th:not(.sticky-col),
.summary-table td:not(.sticky-col) {
  min-width: 180px;
}

.summary-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 260px;
  max-width: 360px;
  background: #f8fbfb;
}

.summary-table thead .sticky-col {
  z-index: 3;
}

.ohs-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 12px;
}

.ohs-field p {
  margin: 5px 0 0;
}

.ohs-summary {
  min-width: 110px;
  display: grid;
  gap: 2px;
  text-align: right;
}

.ohs-summary strong {
  font-size: 24px;
  color: var(--primary);
}

.ohs-summary span {
  color: var(--muted);
  font-size: 12px;
}

.ohs-dialog {
  width: min(980px, calc(100vw - 28px));
}

.media-dialog {
  width: min(1080px, calc(100vw - 28px));
}

.media-body {
  min-height: 360px;
  max-height: min(78vh, 820px);
  overflow: auto;
  padding: 16px;
  background: #0b1118;
}

.dicom-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #000000;
  border: 1px solid #263341;
}

.dicom-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 14px;
  color: #526272;
  font-size: 12px;
}

.dicom-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #ffffff;
}

.media-frame {
  width: 100%;
  height: 70vh;
  border: 0;
  background: #ffffff;
}

.volume-toolbar {
  padding: 12px 16px 0;
}

.volume-scene {
  height: min(58vh, 560px);
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0b1118;
  perspective: 880px;
}

.volume-stack {
  position: relative;
  width: 280px;
  height: 280px;
  transform-style: preserve-3d;
}

.volume-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 18px rgba(23, 109, 120, 0.16);
}

.ohs-scorebar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfb;
}

.ohs-scorebar strong {
  color: var(--primary);
  font-size: 20px;
}

.ohs-question-list {
  max-height: min(68vh, 720px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 16px 18px;
}

.ohs-question {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
}

.ohs-question h3 {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
}

.ohs-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}

.ohs-option {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px;
  text-align: left;
}

.ohs-option strong {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #edf2f7;
  color: #334351;
}

.ohs-option span {
  line-height: 1.35;
}

.ohs-option:hover,
.ohs-option.selected {
  border-color: var(--primary);
  background: #edf7f5;
}

.ohs-option.selected strong {
  background: var(--primary);
  color: #ffffff;
}

.locked-panel .section-head,
.locked-panel .form-section,
.savebar.locked {
  background: #f3f5f6;
}

.locked-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid #d7dee2;
  border-radius: var(--radius);
  background: #eef1f3;
  color: #63717a;
  font-weight: 800;
}

.locked-notice svg {
  width: 16px;
  height: 16px;
}

.locked-form {
  opacity: 0.62;
  filter: grayscale(0.18);
}

.locked-form input,
.locked-form select,
.locked-form textarea,
.locked-form button,
.btn[disabled],
.icon-btn[disabled] {
  cursor: not-allowed;
}

.btn[disabled],
.icon-btn[disabled] {
  opacity: 0.6;
}

.savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(16, 24, 33, 0.42);
}

.dialog-body {
  padding: 0;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog .form-grid {
  padding: 18px;
}

.dialog-actions {
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius);
  background: #17202a;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

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

.export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.muted {
  color: var(--muted);
}

.auth-mode .sidebar,
.auth-mode .topbar {
  display: none;
}

.auth-mode .app-shell {
  display: block;
  min-height: 100vh;
}

.auth-mode .main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #f6f7f9;
}

.login-panel {
  width: min(440px, calc(100vw - 28px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-head {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: #eef4f2;
}

.login-head h1 {
  margin: 10px 0 0;
  font-size: 22px;
  letter-spacing: 0;
}

.login-head p {
  margin: 7px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 18px 22px 22px;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: #2d3b48;
  font-weight: 800;
}

.login-form .btn {
  width: 100%;
}

body.mobile-entry {
  background: #eef2f5;
  overflow-x: hidden;
  width: 100%;
}

body.mobile-entry *,
body.mobile-entry *::before,
body.mobile-entry *::after {
  max-width: 100%;
}

.mobile-entry .sidebar,
.mobile-entry .topbar {
  display: none;
}

.mobile-entry .app-shell {
  display: block;
  min-height: 100vh;
}

.mobile-entry .main {
  padding: 0;
}

.mobile-shell {
  min-height: 100vh;
  width: 100%;
  padding: 10px 10px 20px;
  background: #eef2f5;
  max-width: 100vw;
  overflow-x: hidden;
}

.mobile-top {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -10px -10px 10px;
  padding: 10px;
  background: rgba(238, 242, 245, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.mobile-top span,
.mobile-panel-head span,
.mobile-form-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mobile-top strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

.mobile-panel,
.mobile-current-subject,
.mobile-form-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(31, 46, 61, 0.06);
  min-width: 0;
  max-width: 100%;
}

.mobile-panel {
  margin-bottom: 10px;
  padding: 12px;
}

.mobile-panel-head,
.mobile-current-subject,
.mobile-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.mobile-panel-head strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.mobile-subject-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(138px, 42vw);
  gap: 8px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 2px;
  scroll-snap-type: x proximity;
}

.mobile-subject-chip {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--text);
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px;
  text-align: left;
  scroll-snap-align: start;
}

.mobile-subject-chip strong,
.mobile-subject-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-subject-chip span {
  color: var(--muted);
  font-size: 12px;
}

.mobile-subject-chip.active {
  border-color: var(--primary);
  background: #e9f5f3;
}

.mobile-current-subject {
  margin-bottom: 10px;
  padding: 12px;
}

.mobile-current-subject strong,
.mobile-current-subject span {
  display: block;
}

.mobile-current-subject strong {
  font-size: 16px;
}

.mobile-current-subject div > span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-form-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  margin: 0 0 10px;
  padding: 0;
}

.mobile-form-tabs button {
  min-width: 0;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 2px 6px;
  padding: 8px 9px;
  text-align: left;
}

.mobile-form-tabs button span,
.mobile-form-tabs button strong {
  overflow: hidden;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.mobile-form-tabs button span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.mobile-form-tabs button strong {
  grid-column: 1 / -1;
  font-size: 12px;
  line-height: 1.25;
}

.mobile-form-tabs button svg {
  width: 15px;
  height: 15px;
  color: var(--success);
}

.mobile-form-tabs button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.mobile-form-tabs button.active span,
.mobile-form-tabs button.active svg {
  color: rgba(255, 255, 255, 0.82);
}

.mobile-form-panel {
  overflow: visible;
  min-width: 0;
}

.mobile-form-head {
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.mobile-form-head > div {
  min-width: 0;
}

.mobile-form-head h2 {
  margin: 3px 0 0;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.mobile-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  min-width: 0;
  max-width: 100%;
}

.mobile-form-grid .field,
.mobile-form-grid .table-field,
.mobile-form-grid .repeater-field,
.mobile-form-grid .note,
.mobile-form-grid .section-field,
.mobile-form-grid .ohs-field,
.mobile-form-grid .attachment-field {
  grid-column: 1 / -1;
  min-width: 0;
  max-width: 100%;
}

.mobile-form-grid input,
.mobile-form-grid textarea,
.mobile-form-grid select {
  display: block;
  width: 100%;
  min-height: 42px;
  font-size: 16px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.mobile-form-grid .choice {
  min-height: 40px;
  padding: 0 11px;
  height: auto;
  align-items: flex-start;
  justify-content: flex-start;
  white-space: normal;
  line-height: 1.35;
  padding-block: 9px;
}

.mobile-form-grid .field-title {
  margin-top: 0;
}

.mobile-field > label,
.mobile-cell {
  display: grid;
  gap: 7px;
  min-width: 0;
  width: 100%;
}

.mobile-cell > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.mobile-choice-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.mobile-option {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  display: flex !important;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: #263542;
  padding: 10px 12px;
  font-weight: 700;
  line-height: 1.35;
}

.mobile-option input {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  margin: 0;
}

.mobile-option span {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mobile-form-grid .table-wrap {
  overflow: visible;
  border: 0;
  border-radius: 0;
}

.mobile-form-grid .data-table,
.mobile-form-grid .data-table thead,
.mobile-form-grid .data-table tbody,
.mobile-form-grid .data-table tr,
.mobile-form-grid .data-table th,
.mobile-form-grid .data-table td {
  display: block;
  width: 100%;
}

.mobile-form-grid .data-table thead {
  display: none;
}

.mobile-form-grid .data-table tr {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.mobile-form-grid .data-table tr:last-child {
  margin-bottom: 0;
}

.mobile-form-grid .data-table td {
  border-bottom: 0;
  padding: 8px 0;
  white-space: normal;
}

.mobile-form-grid .data-table td:first-child {
  min-width: 0;
  margin: -2px 0 4px;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.mobile-form-grid .data-table td:not(:first-child)::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mobile-form-grid .data-table input,
.mobile-form-grid .data-table select {
  min-width: 0;
  width: 100%;
}

.mobile-form-grid .radio-row,
.mobile-form-grid .check-row,
.mobile-form-grid .compact-row,
.mobile-form-grid .cell-choice-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  min-width: 0;
}

.mobile-form-grid .compact-choice {
  min-height: 40px;
  font-size: 14px;
}

.mobile-form-grid .repeater-item {
  padding: 10px;
  border-radius: var(--radius);
}

.mobile-form-grid .repeater-item label {
  min-width: 0;
}

.mobile-table-rows,
.mobile-table-cells,
.mobile-repeater-field,
.mobile-repeater-item {
  display: grid;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.mobile-table-row,
.mobile-repeater-item {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
}

.mobile-table-row > strong {
  display: block;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: #243341;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.mobile-form-grid .ohs-field {
  grid-template-columns: 1fr;
}

.mobile-form-grid .ohs-summary {
  text-align: left;
}

.mobile-savebar {
  position: static;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.mobile-savebar .btn {
  width: 100%;
  min-height: 46px;
}

@media (max-width: 390px) {
  .mobile-form-tabs {
    grid-template-columns: 1fr;
  }

  .mobile-form-grid .radio-row,
  .mobile-form-grid .check-row,
  .mobile-form-grid .compact-row,
  .mobile-form-grid .cell-choice-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .brand {
    grid-template-columns: 1fr;
  }

  .brand div:not(.brand-mark),
  .nav-item span,
  .sidebar-note {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

  .content-grid,
  .crf-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .main {
    padding: 18px 14px 30px;
  }

  .topbar,
  .panel-head,
  .section-head,
  .export-row {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .metric-grid,
  .chart-grid,
  .pie-layout,
  .auto-cover-summary,
  .assignment-card,
  .completion-grid,
  .filters,
  .form-grid,
  .form-grid.two,
  .repeater-item,
  .ohs-field,
  .ohs-options {
    grid-template-columns: 1fr;
  }

  .attachment-head,
  .attachment-row {
    align-items: stretch;
    flex-direction: column;
  }

  .ohs-summary {
    text-align: left;
  }

  th,
  td {
    padding: 9px 10px;
  }
}
