:root {
  color-scheme: light;
  --bg: #f2f6fb;
  --panel: #ffffff;
  --panel-2: #edf4fb;
  --line: #d7e3f0;
  --line-strong: #b8cadf;
  --text: #102a43;
  --muted: #627a91;
  --soft: #f7faff;
  --brand: #1267bf;
  --brand-strong: #0b4d94;
  --brand-soft: #dcecff;
  --blue: #0f7bda;
  --amber: #b7791f;
  --red: #c2410c;
  --purple: #7c3aed;
  --shadow: 0 18px 38px rgba(31, 41, 55, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

/* Equipment collection, reminder, and ordering states for the public demo. */
.sort-mode-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #c4d6e7;
  border-radius: 7px;
  background: #f5f9fd;
  color: #236ca9;
  font-weight: 700;
}

.equipment-list-section { display: grid; gap: 7px; margin: 0 0 14px; }
.equipment-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; color: #274b6d; }
.equipment-section-head > span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.equipment-section-head strong { font-size: 12px; letter-spacing: 0.04em; }
.equipment-section-head small { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #e7f0f8; color: #426784; font-size: 10px; font-weight: 750; }
.equipment-section-head em { overflow: hidden; color: #8799a9; font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.section-pinned .equipment-section-head { color: #8a5a0a; }
.section-pinned .equipment-section-head small { background: #fff0d5; color: #98610b; }
.equipment-section-items { display: grid; gap: 7px; }
.equipment-block.sorting { display: grid; grid-template-columns: minmax(0, 1fr) 30px; gap: 5px; }
.equipment-order-controls { display: grid; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 4px; }
.equipment-order-controls button { padding: 0; border: 1px solid #c4d6e7; border-radius: 7px; background: #f5f9fd; color: #236ca9; font-size: 15px; font-weight: 800; }
.equipment-order-controls button:disabled { opacity: 0.28; cursor: not-allowed; }
.equipment-group { overflow: hidden; border: 1px solid #d8e4ef; border-radius: 9px; background: #fff; }
.equipment-group-toggle { width: 100%; min-height: 68px; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 10px; border: 0; background: #fff; color: var(--text); text-align: left; }
.equipment-group-toggle:hover { background: var(--soft); }
.group-chevron { color: var(--brand); font-size: 20px; font-weight: 800; text-align: center; }
.group-label { display: grid; gap: 2px; min-width: 0; }
.group-label strong, .group-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-label strong { font-size: 14px; }
.group-label span { color: var(--muted); font-size: 11px; }
.group-indicators { display: grid; justify-items: end; }
.group-reminder, .pin-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 6px; border-radius: 999px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.group-reminder, .pin-badge.automatic { background: #fff0d5; color: #9a6105; }
.pin-badge.manual { background: #e1effc; color: #1764a5; }
.equipment-group-items { display: grid; gap: 4px; padding: 5px; border-top: 1px solid #d8e4ef; }
.equipment-group-items .equipment-row-child { margin-left: 14px; width: calc(100% - 14px); border-left: 2px solid #b8d8ef; border-radius: 4px 8px 8px 4px; }
.equipment-row { cursor: pointer; }
.equipment-row.auto-pinned, .equipment-group.auto-pinned { border-left: 3px solid #d99016; }
.equipment-row.manual-pinned:not(.auto-pinned), .equipment-group.manual-pinned:not(.auto-pinned) { border-left: 3px solid var(--brand); }
.row-side { display: grid; justify-items: end; gap: 5px; }
.pin-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.manual-pin-button { width: 25px; height: 25px; display: inline-grid; place-items: center; padding: 0; border: 1px solid #c8d9e8; border-radius: 7px; background: #fff; color: #6b8297; font-size: 16px; line-height: 1; }
.manual-pin-button:hover { border-color: #7fb0d8; background: #eff7fe; color: var(--brand); }
.manual-pin-button.active { border-color: #77aeda; background: #e6f2fd; color: #1168b2; }
.equipment-relation { display: inline-flex; margin-right: 6px; padding: 1px 5px; border-radius: 4px; background: #dceeff; color: #175f9f; font-size: 10px; font-weight: 800; vertical-align: 1px; }

@media (max-width: 720px) {
  .equipment-section-head em { display: none; }
  .equipment-block.sorting { grid-template-columns: minmax(0, 1fr) 28px; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(90deg, #ffffff 0%, #f8fbff 68%, #e7f1fc 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 14px rgba(18, 77, 148, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 5px 14px rgba(18, 103, 191, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: #0c427f;
}

.app-version {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.role-badge.admin {
  color: #073f78;
  background: #d9ecff;
}

.role-badge.operator {
  color: #6f4d05;
  background: #fff3cf;
}

@media (max-width: 620px) {
  .topbar {
    height: auto;
    min-height: 68px;
    padding: 10px 14px;
    align-items: flex-start;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

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

  .brand p {
    display: none;
  }
}

.top-actions,
.modal-actions,
.section-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.permission-panel {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
}

.permission-light {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(185, 198, 195, 0.2);
  flex: 0 0 auto;
}

.permission-light.granted {
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.permission-light.busy {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(183, 121, 31, 0.16);
}

.permission-status {
  font-size: 12px;
  white-space: nowrap;
}

.permission-timer {
  min-width: 46px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.permission-button {
  height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 10px;
  background: var(--brand);
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.permission-button:hover {
  background: var(--brand-strong);
}

.permission-button.danger {
  background: #fff7ed;
  color: var(--red);
  border-color: #fed7aa;
}

.permission-button.danger:hover {
  background: #ffedd5;
}

.permission-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.readonly-mode .solid-button,
.readonly-mode .text-button,
.readonly-mode .file-button,
.readonly-mode .icon-button.primary {
  opacity: 0.62;
}

.workspace {
  display: grid;
  grid-template-columns: clamp(340px, 22vw, 410px) minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 14px 8px;
}

.stat-cell {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}

.stat-cell strong {
  display: block;
  font-size: 20px;
}

.stat-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.sidebar-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
}

.search-box {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--soft);
  min-width: 0;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.search-box:focus-within {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(18, 103, 191, 0.1);
}

.search-box span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 17px;
}

.search-box input,
.search-box input:focus {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  text-overflow: ellipsis;
}

.filters {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
}

.filters select {
  field-sizing: content;
  width: auto;
  min-width: 112px;
  max-width: 100%;
  padding-left: 12px;
  padding-right: 34px;
  flex: 0 1 auto;
  font: inherit;
  font-size: 13px;
}

select,
input,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
  color: var(--text);
}

select,
input {
  height: 38px;
  padding: 0 10px;
}

textarea {
  padding: 10px;
  resize: vertical;
  min-height: 76px;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
}

input.auto-calculated {
  border-color: #73aee3;
  background: #f1f8ff;
  box-shadow: 0 0 0 3px rgba(43, 124, 198, 0.08);
}

.equipment-list {
  overflow: auto;
  padding: 0 8px 16px;
}

.equipment-row {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 11px 10px;
  text-align: left;
  display: grid;
  gap: 9px;
}

.equipment-row:hover {
  background: var(--soft);
}

.equipment-row.active {
  background: var(--brand-soft);
  border-color: #a6d7d2;
}

.row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

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

.row-title strong,
.detail-title h2,
.entry-title {
  overflow-wrap: anywhere;
}

.row-title strong {
  display: block;
  font-size: 14px;
  line-height: 1.4;
}

.row-title span,
.row-meta {
  color: var(--muted);
  font-size: 12px;
}

.row-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 6px 12px;
}

.row-meta span {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.maintenance-reminder {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 8px;
  border: 1px solid #c8dcf1;
  border-radius: 7px;
  background: #f3f8fe;
  color: #315c86;
  font-size: 11px;
  line-height: 1.35;
}

.maintenance-reminder strong {
  white-space: nowrap;
}

.maintenance-reminder > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maintenance-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2b7cc6;
}

.maintenance-reminder.maintenance-due_soon {
  border-color: #f4d08f;
  background: #fff8e8;
  color: #8a5a0a;
}

.maintenance-reminder.maintenance-due_soon .maintenance-dot {
  background: #d99016;
}

.maintenance-reminder.maintenance-overdue {
  border-color: #efb7b7;
  background: #fff1f1;
  color: #a52b2b;
}

.maintenance-reminder.maintenance-overdue .maintenance-dot {
  background: #d13c3c;
  box-shadow: 0 0 0 3px rgba(209, 60, 60, 0.12);
}

.detail-pane {
  min-width: 0;
  overflow: auto;
  padding: 22px 26px 40px;
}

.empty-state {
  height: calc(100vh - 130px);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  margin: 0 0 8px;
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-title h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

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

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.info-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 11px 12px;
  min-width: 0;
}

.info-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.info-cell strong {
  display: block;
  overflow-wrap: anywhere;
}

.content-band {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
}

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

.records-band .band-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.band-head h3 {
  margin: 0;
  font-size: 15px;
}

.band-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.band-body {
  padding: 14px;
}

.notes {
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.field-item {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(145deg, #ffffff, #f8fbff);
}

.field-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-item strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.field-item.wide {
  grid-column: 1 / -1;
  min-height: auto;
}

.maintenance-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 12px;
}

.maintenance-plan-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid #2b7cc6;
  border-radius: 9px;
  background: linear-gradient(145deg, #fff, #f7fbff);
}

.maintenance-plan-card.maintenance-due_soon {
  border-left-color: #d99016;
  background: linear-gradient(145deg, #fff, #fffaf0);
}

.maintenance-plan-card.maintenance-overdue {
  border-left-color: #d13c3c;
  background: linear-gradient(145deg, #fff, #fff6f6);
}

.maintenance-plan-card.maintenance-paused {
  border-left-color: #94a3b8;
  background: #f8fafc;
}

.maintenance-plan-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.maintenance-plan-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.maintenance-state {
  display: inline-flex;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.maintenance-plan-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.text-button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.maintenance-plan-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.maintenance-plan-meta > div {
  min-width: 0;
}

.maintenance-plan-meta span,
.maintenance-plan-meta strong {
  display: block;
}

.maintenance-plan-meta span {
  color: var(--muted);
  font-size: 11px;
}

.maintenance-plan-meta strong {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.maintenance-plan-content {
  margin: 12px 0 0;
  padding: 10px 11px;
  border-radius: 7px;
  background: rgba(237, 244, 251, 0.78);
  color: #31475d;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.maintenance-empty {
  padding: 14px 2px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tab-button {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
}

.tab-button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

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

.entry-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.entry-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
}

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

.entry-title {
  font-weight: 750;
  font-size: 15px;
  line-height: 1.45;
}

.entry-content {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-left: 3px solid #9fc6ec;
  border-radius: 0 7px 7px 0;
  background: #f7faff;
  white-space: pre-wrap;
  color: #273532;
  line-height: 1.65;
}

.entry-meta,
.tag-row,
.attachment-list,
.kv-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.entry-meta {
  margin-top: 0;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.entry-meta > span:not(.type-pill):not(.status-pill):not(.severity-pill) {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.entry-plan-link {
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  background: #e9f3ff;
  color: #225f99;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.entry-item > .field-grid,
.entry-item > .tag-row,
.entry-item > .attachment-list {
  margin-top: 12px;
}

.tag-row {
  margin-top: 9px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf2f7;
  color: #394844;
  padding: 2px 9px;
  font-size: 12px;
}

.status-pill,
.type-pill,
.severity-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-running,
.status-resolved {
  background: #dcfce7;
  color: #166534;
}

.status-standby,
.status-tracking {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-repair,
.status-open {
  background: #ffedd5;
  color: #9a3412;
}

.status-retired,
.status-archived {
  background: #e5e7eb;
  color: #374151;
}

.severity-none {
  background: #eef2f7;
  color: #4b5563;
}

.severity-low {
  background: #e0f2fe;
  color: #0369a1;
}

.severity-medium {
  background: #fef3c7;
  color: #92400e;
}

.severity-high,
.severity-critical {
  background: #fee2e2;
  color: #b91c1c;
}

.type-pill {
  background: #ecfdf5;
  color: var(--brand-strong);
}

.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border-radius: 7px 0 0 7px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  padding: 4px 8px;
  background: var(--soft);
  font: inherit;
  cursor: pointer;
}

.attachment-link:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.attachment-item {
  display: inline-flex;
  align-items: stretch;
}

.attachment-download {
  display: inline-grid;
  min-width: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  background: #fff;
  color: var(--brand-strong);
  text-decoration: none;
  font-weight: 800;
}

.attachment-download:hover {
  background: var(--soft);
  color: var(--brand);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
}

.icon-button.primary,
.solid-button {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.icon-button.ghost {
  border-color: transparent;
  background: transparent;
}

.solid-button,
.text-button,
.danger-text,
.file-button span {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.solid-button {
  font-weight: 700;
}

.text-button {
  background: white;
  color: var(--text);
}

.danger-text {
  background: white;
  color: #b91c1c;
  border-color: #fecaca;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-button span {
  background: white;
}

.preview-dialog {
  width: min(1120px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(9, 30, 58, 0.62);
  backdrop-filter: blur(3px);
}

.preview-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

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

.preview-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.preview-head h2 {
  margin: 0;
  max-width: min(760px, 70vw);
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-body {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #edf3f9;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-frame {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
  background: #fff;
}

.preview-unavailable {
  display: grid;
  gap: 8px;
  max-width: 440px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.preview-unavailable strong {
  color: var(--text);
  font-size: 17px;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.preview-actions a {
  text-decoration: none;
}

.modal {
  width: min(980px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.42);
}

.login-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(10, 49, 94, 0.34);
  background: transparent;
}

.login-dialog::backdrop {
  background: rgba(9, 30, 58, 0.62);
  backdrop-filter: blur(4px);
}

.login-card {
  display: grid;
  gap: 14px;
  padding: 38px 38px 34px;
  background: linear-gradient(160deg, #ffffff 0%, #f2f8ff 100%);
  border-top: 5px solid var(--brand);
}

.login-logo {
  width: 122px;
  height: 56px;
  object-fit: contain;
  object-position: left center;
}

.login-kicker {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.login-card h2 {
  margin: -4px 0 0;
  color: #0b3e76;
  font-size: 23px;
  line-height: 1.25;
}

.login-copy {
  margin: -6px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: #385572;
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #c6d9ed;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.login-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 103, 191, 0.14);
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: #c2410c;
  font-size: 12px;
}

.login-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 2px;
}

.modal-body {
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

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

.form-grid label,
.kv-row {
  display: grid;
  gap: 6px;
}

.form-grid label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-section {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}

.section-line {
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-line h3 {
  margin: 0;
  font-size: 14px;
}

.kv-list {
  display: grid;
  grid-template-columns: 1fr;
}

.kv-row {
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) 38px;
  align-items: center;
  width: 100%;
}

.kv-row input {
  width: 100%;
}

.modal-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.grow {
  flex: 1;
}

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

.mini-empty {
  color: var(--muted);
  padding: 8px 0;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 48vh;
  }

  .detail-pane {
    padding: 18px 16px 34px;
  }

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

@media (max-width: 720px) {
  .topbar {
    padding: 0 12px;
    height: auto;
    min-height: 68px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brand p {
    display: none;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .permission-panel {
    width: 100%;
    flex-wrap: wrap;
  }

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

  .filters,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .detail-head,
  .entry-top,
  .band-head {
    display: grid;
  }

  .records-band .band-head {
    grid-template-columns: 1fr;
  }

  .entry-top {
    grid-template-columns: 1fr;
  }

  .maintenance-plan-grid,
  .maintenance-plan-head {
    grid-template-columns: 1fr;
  }

  .maintenance-plan-actions {
    justify-content: flex-start;
  }

  .maintenance-plan-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-top > .text-button {
    justify-self: start;
  }

  .tabs {
    justify-content: flex-start;
  }

  .detail-actions {
    justify-content: stretch;
  }

  .detail-actions button {
    flex: 1;
  }

  .kv-row {
    grid-template-columns: 1fr 1fr 38px;
  }
}
