:root {
  --bg: #f8fafc;
  --sidebar: #0f172a;
  --sidebar-soft: #172033;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --ink: #1f2937;
  --ink-strong: #020617;
  --muted: #64748b;
  --line: #dbe4ef;
  --line-strong: #bfccd9;
  --primary: #1e40af;
  --primary-deep: #1e3a8a;
  --primary-soft: #dbeafe;
  --accent: #d97706;
  --success: #047857;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: "Fira Sans", "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
}

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

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

h1 {
  color: #fff;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  color: var(--ink-strong);
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  color: var(--ink-strong);
  font-size: 15px;
  line-height: 1.35;
}

p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

a,
button,
input,
select,
textarea {
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(30, 64, 175, 0.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-140%);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--primary-deep);
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow);
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(30, 64, 175, 0.08), rgba(217, 119, 6, 0.08)),
    var(--bg);
}

.login-view[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand h1 {
  color: var(--ink-strong);
}

.login-copy {
  display: grid;
  gap: 6px;
  padding-top: 4px;
}

.login-status {
  min-height: 20px;
  color: var(--danger);
  font-weight: 800;
}

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

.app-shell[hidden] {
  display: none;
}

.system-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 18px;
  background:
    linear-gradient(180deg, rgba(30, 64, 175, 0.24), rgba(15, 23, 42, 0) 280px),
    var(--sidebar);
  color: #cbd5e1;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 900;
}

.kicker,
.section-kicker {
  color: #2563eb;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-brand .kicker {
  color: #93c5fd;
}

.module-nav {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.module-tab {
  min-height: 48px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: transparent;
  color: #cbd5e1;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.module-tab > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.module-tab:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.module-tab.active {
  border-color: rgba(147, 197, 253, 0.36);
  background: rgba(219, 234, 254, 0.12);
  color: #fff;
}

.nav-index {
  min-width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #93c5fd;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.module-tab.active .nav-index {
  background: #dbeafe;
  color: var(--primary-deep);
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-footer p {
  color: #94a3b8;
}

.sidebar-footer strong {
  display: block;
  margin-top: 4px;
  margin-bottom: 10px;
  color: #fff;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.sidebar-logout {
  width: 100%;
  min-height: 36px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 12px;
}

.sidebar-logout:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
}

.system-workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(520px, auto);
  gap: 20px;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.94);
  backdrop-filter: blur(16px);
}

.brand-block {
  display: grid;
  gap: 5px;
}

.header-copy {
  color: #475569;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(108px, 132px)) minmax(220px, 360px);
  gap: 10px;
}

.status-card {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  background: #fff;
}

.status-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.status-card strong {
  color: var(--ink-strong);
  font-size: 13px;
  line-height: 1.35;
}

.status-card.wide strong {
  color: var(--primary-deep);
}

.tool-main {
  width: 100%;
  max-width: 1760px;
  margin: 0 auto;
  padding: 20px 22px 28px;
}

.module-view[hidden] {
  display: none;
}

.module-view {
  display: grid;
  gap: 16px;
}

.page-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.summary-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-pills span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.workbench-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(520px, 680px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

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

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

.panel {
  padding: 14px;
}

.step-panel {
  position: relative;
}

.panel-head,
.preview-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.step-title {
  display: flex;
  align-items: start;
  gap: 10px;
}

.step-index {
  min-width: 36px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #eff6ff;
  color: var(--primary-deep);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 900;
}

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

.compact-form {
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 10px;
}

.span-2 {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: var(--ink-strong);
  padding: 10px 11px;
}

select:hover,
input:hover,
textarea:hover {
  border-color: #94a3b8;
}

textarea {
  min-height: 128px;
  resize: vertical;
  line-height: 1.65;
}

button,
.ghost {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 9px 13px;
  background: #fff;
  color: #1e293b;
  font-weight: 900;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

button:hover,
.ghost:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

button:active,
.ghost:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.primary:hover {
  border-color: var(--primary-deep);
  background: var(--primary-deep);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.history-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #eff6ff;
}

.history-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-copy strong {
  color: var(--primary-deep);
  font-size: 13px;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-toggle {
  width: auto;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  padding: 6px 10px;
  background: #fff;
  color: var(--primary-deep);
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.enterprise-table {
  max-height: min(34vh, 330px);
}

.reports-table {
  max-height: min(38vh, 390px);
}

.reports-table.multi-line-board {
  max-height: min(48vh, 520px);
  background: #f8fafc;
}

.reports-table.multi-line-board thead {
  display: none;
}

.reports-table.multi-line-board table,
.reports-table.multi-line-board tbody,
.reports-table.multi-line-board tr,
.reports-table.multi-line-board td {
  display: block;
  width: 100%;
}

.reports-table.multi-line-board tr:hover td {
  background: transparent;
}

.report-board-cell {
  border-bottom: 0;
  padding: 12px;
}

.report-line-grid {
  display: grid;
  gap: 12px;
}

.report-line-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--report-line-accent) 34%, #dbe4ef);
  border-top: 4px solid var(--report-line-accent);
  border-radius: var(--radius);
  background: #fff;
}

.report-line-column-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(180deg, var(--report-line-soft), #fff);
  border-bottom: 1px solid #e5edf7;
}

.report-line-index {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--report-line-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.report-line-title {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.report-line-title strong {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-line-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-line-options {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 380px;
  overflow: auto;
  padding: 10px;
  background: #fff;
}

.report-option-card {
  width: 100%;
  min-height: 82px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
}

.report-option-card:hover {
  border-color: color-mix(in srgb, var(--report-line-accent) 48%, #dbe4ef);
  background: #fbfdff;
}

.report-option-card:has(input:checked) {
  border-color: var(--report-line-accent);
  background: var(--report-line-soft);
  box-shadow: inset 3px 0 0 var(--report-line-accent);
}

.report-option-control {
  padding-top: 2px;
}

.report-option-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.report-option-main strong {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-option-period {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.report-option-side {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.report-current-mark {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.report-line-empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  background: #f8fafc;
}

.library-table {
  max-height: calc(100vh - 248px);
}

.library-group-row td {
  border-top: 1px solid var(--line);
  border-bottom-color: var(--line);
  background: #eef6ff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 10px 10px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

td {
  color: #1f2937;
}

tbody tr:hover td {
  background: #f8fbff;
}

.library-group-row:hover td {
  background: #eef6ff;
}

.report-history-row td {
  background: #f8fafc;
  color: #64748b;
}

.report-history-row:hover td {
  background: #f1f5f9;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.group-row td {
  background: #eef6ff;
  color: var(--primary-deep);
  font-size: 12px;
  font-weight: 900;
}

.library-group-toggle {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary-deep);
  text-align: left;
}

.library-group-toggle:hover {
  background: transparent;
}

.library-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.library-group-title strong {
  overflow: hidden;
  color: var(--primary-deep);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-group-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.library-group-meta {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.library-report-cell {
  display: grid;
  gap: 2px;
  padding-left: 20px;
}

.library-report-cell strong {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--ink-strong);
}

.library-child-row td:first-child {
  border-left: 3px solid #bfdbfe;
}

.jobs-panel {
  min-height: 420px;
}

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

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

.job-card.running,
.job-card.queued {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.job-card.succeeded {
  border-color: #bbf7d0;
  background: #f8fffb;
}

.job-card.failed {
  border-color: #fecaca;
  background: #fff8f8;
}

.job-card.cancelled {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.job-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.job-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.job-title strong {
  color: var(--ink-strong);
  font-size: 14px;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.job-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.job-badge.running,
.job-badge.queued {
  background: #dbeafe;
  color: var(--primary-deep);
}

.job-badge.succeeded {
  background: #dcfce7;
  color: var(--success);
}

.job-badge.failed {
  background: #fee2e2;
  color: var(--danger);
}

.job-badge.cancelled {
  background: #e2e8f0;
  color: #475569;
}

.job-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.job-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.job-card.succeeded .job-progress span {
  background: var(--success);
}

.job-card.failed .job-progress span {
  background: var(--danger);
}

.job-card.cancelled .job-progress span {
  background: #94a3b8;
}

.job-message {
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
}

.job-error {
  border: 1px solid #fecaca;
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff1f2;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.revision-target {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #f8fbff;
}

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

.revision-target-head strong {
  min-width: 0;
  color: var(--primary-deep);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.revision-target-id {
  color: var(--ink-strong);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.revision-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.revision-source {
  color: #92400e;
}

.copy-edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.copy-edit-toolbar button {
  min-height: 34px;
}

.copy-edit-status {
  margin: 10px 0 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.6;
}

.report-source-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #dcfce7;
  color: var(--success);
  font-size: 11px;
  font-weight: 900;
}

.report-source-pill.new {
  background: #fef3c7;
  color: #92400e;
}

.empty {
  height: 56px;
  color: var(--muted);
  text-align: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.action-bar {
  justify-content: flex-end;
}

.generation-notice {
  min-height: 38px;
  margin-top: 10px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 9px 11px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 900;
}

.hidden {
  display: none;
}

.preview-pane {
  min-height: calc(100vh - 174px);
  overflow: hidden;
}

.preview-bottom {
  min-height: 720px;
}

.preview-head {
  padding: 16px 16px 0;
}

iframe {
  width: 100%;
  height: calc(100vh - 252px);
  border: 0;
  background: #fff;
}

.preview-bottom iframe {
  height: 640px;
}

.row-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.history-sub {
  color: var(--success);
  font-weight: 900;
}

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

.small-action {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.danger-action {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

.danger-action:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}

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

@media (max-width: 1380px) {
  .app-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .status-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .preview-pane {
    min-height: 720px;
  }

  iframe {
    height: 640px;
  }
}

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

  .system-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
  }

  .sidebar-brand {
    min-width: 220px;
  }

  .module-nav {
    flex: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 0;
  }

  .sidebar-footer {
    display: none;
  }

  .workbench-layout,
  .library-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .system-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding: 12px max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  }

  .sidebar-brand {
    min-width: 0;
  }

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

  .module-tab {
    justify-content: center;
    min-height: 44px;
    padding: 8px 7px;
    text-align: center;
  }

  .module-tab > span:last-child {
    white-space: nowrap;
  }

  .app-header {
    position: static;
    padding: 14px;
  }

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

  .tool-main {
    padding: 14px max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left));
  }

  .page-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .history-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .history-actions {
    justify-content: flex-start;
  }

  .history-actions > *,
  .copy-edit-toolbar > *,
  .actions > * {
    flex: 1 1 148px;
  }

  .history-toggle {
    justify-content: center;
    white-space: normal;
  }

  .revision-target-head {
    align-items: stretch;
    flex-direction: column;
  }

  .revision-target-head .small-action {
    width: fit-content;
  }

  .job-top {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-pills {
    justify-content: flex-start;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .panel,
  .preview-head {
    padding: 13px;
  }

  .table-wrap {
    max-height: 360px;
  }

  .enterprise-table table {
    min-width: 560px;
  }

  .reports-table table {
    min-width: 520px;
  }

  .reports-table.multi-line-board table {
    min-width: 100%;
  }

  .library-table table {
    min-width: 880px;
  }

  .preview-pane {
    min-height: 0;
  }

  iframe {
    height: min(68vh, 560px);
  }
}

@media (max-width: 480px) {
  h2 {
    font-size: 20px;
  }

  .login-view {
    padding: 18px max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left));
  }

  .login-panel {
    padding: 18px;
  }

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

  .sidebar-brand {
    gap: 10px;
    min-height: 44px;
  }

  .sidebar-brand h1 {
    font-size: 16px;
  }

  .module-tab {
    gap: 6px;
    font-size: 13px;
  }

  .nav-index {
    min-width: 24px;
    height: 22px;
    border-radius: 6px;
    font-size: 10px;
  }

  .app-header,
  .tool-main {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .status-card {
    min-height: 52px;
  }

  .summary-pills span {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
    text-align: center;
  }

  .panel,
  .preview-head {
    padding: 12px;
  }

  .step-title {
    gap: 9px;
  }

  .step-index {
    min-width: 34px;
  }

  button,
  .ghost,
  select,
  input,
  textarea {
    min-height: 44px;
  }

  iframe {
    height: min(64vh, 520px);
  }
}
