:root {
  /* 中石化集团官网风格：白底顶栏 + 品牌红主色 + 深蓝辅色 */
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-head: #f7f8fa;
  --border: #e2e6ec;
  --border-strong: #c5ccd6;
  --text: #222222;
  --muted: #7f8795;
  --accent: #e60012;
  --accent-hover: #c40010;
  --accent-soft: #fde8ea;
  --brand-blue: #1a4f8b;
  --ok: #1f9d64;
  --danger: #c44536;
  --input: #ffffff;
  --nav: #ffffff;
  --nav-text: #4a5160;
  --nav-border: #e8ebf0;
  --shadow: 0 1px 3px rgba(34, 34, 34, 0.06);
  --radius: 6px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-width: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  background:
    linear-gradient(180deg, #fff 0, transparent 120px),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  background: var(--nav);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  min-height: 58px;
  position: relative;
}

.app-nav::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, #ff4d4f 55%, var(--brand-blue) 100%);
}

.app-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px 6px 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  border-right: 1px solid var(--nav-border);
  white-space: nowrap;
}

.app-nav-brand:hover {
  color: var(--accent);
}

.app-nav-logo {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
}

.app-nav-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-size: 13px;
}

.app-nav-brand-text small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.app-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  flex: 0 0 auto;
  padding: 8px 14px 7px;
  color: var(--nav-text);
  text-decoration: none;
  border-right: 1px solid var(--nav-border);
  font-size: 12px;
  gap: 3px;
  white-space: nowrap;
}

.app-nav-item i {
  font-size: 18px;
  line-height: 1;
  color: var(--brand-blue);
}

.app-nav-item:hover {
  background: #f7f8fa;
  color: var(--accent);
}

.app-nav-item:hover i {
  color: var(--accent);
}

.app-nav-item.active {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--accent);
}

.app-nav-item.active i {
  color: var(--accent);
}

.app-nav-item.logout {
  background: transparent;
  color: var(--muted);
  border-right: 0;
  min-width: 88px;
  margin-left: 0;
}

.app-nav-item.logout i {
  color: var(--muted);
}

.app-nav-item.logout:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.app-nav-item.logout:hover i {
  color: var(--accent);
}

.app-nav-end {
  display: flex;
  align-items: stretch;
  margin-left: auto;
}

.app-user {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  color: var(--muted);
  border-left: 1px solid var(--nav-border);
  white-space: nowrap;
}

.app-main {
  padding: clamp(8px, 1.2vw, 16px) clamp(8px, 1.4vw, 18px) 20px;
  min-width: 0;
  max-width: 100%;
}

.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lv-box {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  padding: 0 14px 14px;
  position: relative;
  height: auto;
  min-width: 0;
  box-shadow: var(--shadow);
}

.lv-box > .lv-legend {
  position: static;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0 -14px 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #f4f8fb 0%, #eef3f8 100%);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px;
  font-weight: 700;
  color: #16324a;
  letter-spacing: 0.02em;
}

.lv-legend .lv-btn {
  font-weight: 600;
  letter-spacing: 0;
  flex-shrink: 0;
}

.lv-collapse-toggle {
  cursor: pointer;
  user-select: none;
}

.lv-collapse-toggle .lv-collapse-icon {
  margin-left: auto;
  font-size: 14px;
  color: #5b7388;
  transition: transform 0.18s ease;
}

.lv-box.is-collapsed > .lv-legend,
.range-module.is-collapsed > .range-module-title {
  margin-bottom: 0;
  border-bottom-color: transparent;
  border-radius: var(--radius);
}

.lv-box.is-collapsed {
  padding-bottom: 0;
}

.lv-box.is-collapsed > .lv-box-body,
.range-module.is-collapsed > .range-module-body {
  display: none;
}

.lv-box.is-collapsed .lv-collapse-icon,
.range-module.is-collapsed .lv-collapse-icon {
  transform: rotate(-90deg);
}

.range-module-title.lv-collapse-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.lv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.lv-label {
  min-width: 72px;
  color: var(--muted);
  white-space: nowrap;
  text-align: left;
}

.field-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 10px;
}

.field-stack .lv-label {
  min-width: 0;
  width: 100%;
  text-align: left;
}

.field-stack .lv-textarea,
.field-stack .lv-input,
.field-stack .lv-select {
  width: 100%;
}

.lv-input,
.lv-select,
.lv-textarea {
  background: var(--input);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 28px;
  color: var(--text);
}

.lv-input:focus,
.lv-select:focus,
.lv-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(230, 0, 18, 0.15);
}

.lv-input.num {
  width: min(88px, 100%);
  min-width: 64px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: #12324a;
  font-weight: 600;
}

.lv-input.num-wide {
  width: min(110px, 100%);
}

.lv-input.grow,
.lv-select.grow,
.lv-textarea.grow {
  flex: 1;
  width: 100%;
}

.lv-select.meter-name {
  color: var(--danger);
  font-weight: 700;
}

.lv-select-wide {
  min-width: min(220px, 100%);
  width: 100%;
  max-width: 320px;
}

.lv-textarea {
  height: auto;
  min-height: 72px;
  padding: 8px;
  resize: vertical;
}

.lv-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin-right: 10px;
  color: var(--muted);
}

.lv-btn {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.3;
}

.lv-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.lv-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lv-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.lv-btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: #9d372c;
}

.lv-btn-danger:hover {
  background: #a8372c;
  color: #fff;
}

.lv-btn-lg {
  min-width: 120px;
  padding: 8px 18px;
  font-size: 14px;
}

.lv-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lv-input[readonly] {
  background: #f4f8fb;
  border-color: #d3dee8;
  color: #12324a;
  cursor: default;
  box-shadow: none;
}

.lv-input[readonly]:focus {
  border-color: #c3d0dc;
  box-shadow: none;
}

.lv-input.num.is-warn {
  color: var(--danger);
  border-color: #e3b4ae;
  background: #fff5f3;
}

.lv-warn {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.sampling-mid,
.sampling-charts {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  min-width: 0;
}

.sampling-mid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: stretch;
}

.sampling-mid > .collect-section {
  grid-column: span 4;
}

.sampling-mid > .collect-section.is-8 {
  grid-column: span 2;
}

.sampling-mid > .collect-section.is-4 {
  grid-column: span 1;
}

.sampling-mid > .collect-section.is-2 {
  grid-column: span 2;
}

.collect-section {
  min-width: 0;
  padding: 0 0 14px;
  background: #edf2f6;
  border: 1px solid #c7d5e0;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.collect-section + .collect-section {
  margin-top: 0;
}

.collect-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 16px;
  border-bottom: 2px solid #2f6fed;
  background: linear-gradient(180deg, #f8fbfe 0%, #e8f0f7 100%);
  border-radius: 10px 10px 0 0;
}

.collect-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  color: #12324a;
  letter-spacing: 0.02em;
}

.collect-section-hint {
  color: #5f7386;
  font-size: 12px;
  font-weight: 600;
}

.collect-section-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px 14px 0;
  min-width: 0;
}

.collect-section-body-flat {
  padding-bottom: 14px;
}

.collect-fields-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 10px;
  min-width: 0;
}

/* 8 项：4 行 × 2 列 */
.collect-fields-row.is-8 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.collect-fields-row.is-10 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.collect-fields-row.is-12 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* 4 项：4 行 × 1 列 */
.collect-fields-row.is-4 {
  grid-template-columns: 1fr;
}

.collect-fields-row.is-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.collect-section .metric-row .lv-label {
  min-width: 5.6em;
}

.sampling-charts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 1fr 1fr;
  min-height: clamp(280px, 38vh, 480px);
}

.sampling-records {
  margin-bottom: 12px;
}

.sampling-records > .lv-legend {
  flex-wrap: wrap;
  row-gap: 8px;
}

.sampling-records-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-left: auto;
}

.data-table-records {
  height: min(360px, 42vh);
  min-height: 220px;
  border: 0;
  border-radius: 0;
  margin: 0 -14px 0;
  border-top: 1px solid var(--border);
}

.chart-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px 8px;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  min-width: 0;
}

.chart-box h3 {
  font-size: 12px;
  margin: 0 0 4px;
  text-align: center;
  font-weight: 700;
  color: var(--accent);
}

.chart-canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 120px;
  height: 100%;
}

.chart-box canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(247, 249, 252, 0.15), rgba(247, 249, 252, 0.55));
}

.chart-empty.is-hidden {
  display: none;
}

.data-table-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 100%;
  min-width: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table-wrap table {
  font-size: 14px;
  margin: 0;
  white-space: nowrap;
  width: 100%;
}

.data-table-wrap .table-sm > :not(caption) > * > * {
  padding: 0.45rem 0.6rem;
}

.data-table-wrap thead th {
  position: sticky;
  top: 0;
  background: #eef4f8;
  color: var(--muted);
  font-weight: 700;
  z-index: 1;
}

.data-table-tall {
  height: min(520px, 70vh);
  min-height: 280px;
}

.data-table-mid {
  height: auto;
  min-height: 120px;
  max-height: min(320px, 40vh);
}

.log-table td.log-detail {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.sampling-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sampling-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.sampling-toolbar-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.sampling-title {
  font-size: 15px;
  color: #16324a;
}

.sampling-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f3f7fa;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.sampling-status-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.sampling-status-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9aa8b6;
  box-shadow: 0 0 0 3px rgba(154, 168, 182, 0.18);
  flex-shrink: 0;
}

.sampling-status[data-state="live"] {
  background: #e8f7ef;
  border-color: #b7e0c8;
}

.sampling-status[data-state="live"] .sampling-status-text {
  color: #146b44;
}

.sampling-status[data-state="live"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(31, 157, 100, 0.18);
  animation: status-pulse 1.6s ease-out infinite;
}

.legend-unit {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  background: #f6f9fb;
  border: 1px solid #e6eef4;
  border-radius: 6px;
}

.metric-row .lv-label {
  min-width: 4.8em;
  font-family: var(--mono);
  font-size: 12px;
}

.metric-row .lv-input.num {
  flex: 1;
  width: auto;
  min-width: 0;
}

.metric-value-btn {
  flex: 1;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid #c9d7e3;
  border-radius: 6px;
  background: #eef3f7;
  color: #12324a;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-align: right;
  cursor: default;
  box-shadow: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.metric-value-btn:disabled {
  opacity: 1;
  -webkit-text-fill-color: currentColor;
}

.metric-value-btn.is-ok,
.metric-value-btn.is-ok:disabled {
  background: #1f9d64 !important;
  border-color: #187a4e !important;
  color: #fff !important;
}

.metric-value-btn.is-bad,
.metric-value-btn.is-bad:disabled {
  background: #c44536 !important;
  border-color: #a3382c !important;
  color: #fff !important;
}

.sampling-page .lv-box {
  padding-bottom: 12px;
}

.sampling-page .data-table-wrap {
  box-shadow: var(--shadow);
}

#reading-table .table-empty td {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  background: #fafcfe;
  font-size: 13px;
}

@keyframes status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 157, 100, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(31, 157, 100, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 100, 0); }
}

.settings-page {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 90px);
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(300px, 1.2fr);
  gap: 14px;
  align-items: start;
}

.settings-left,
.settings-center {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.gas-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.gas-set-item {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(72px, 0.9fr);
  align-items: center;
  gap: 8px;
  font-size: 12px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 6px;
  background: #f6f9fb;
}

.gas-set-item span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gas-set-item .lv-input {
  width: 100%;
}

.range-settings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.range-modules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.range-box {
  margin-top: 12px;
}

.range-module {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.range-module-title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.range-set-item {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(160px, 1.4fr);
  align-items: center;
  gap: 8px;
  font-size: 12px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 6px;
  background: #f6f9fb;
}

.range-set-item > span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-set-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.range-set-inputs .lv-input {
  width: 100%;
  min-width: 0;
}

.range-sep {
  color: var(--muted);
  flex: 0 0 auto;
}

.notice-warn {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff6e8;
  color: #8a5a12;
  font-size: 12px;
  line-height: 1.45;
}

.mode-pills {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 10px;
  padding: 3px;
  background: #eef3f8;
  border-radius: 999px;
}

.lv-legend .mode-pills {
  margin-bottom: 0;
  background: #e4ebf1;
}

.mode-pills .lv-check {
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
}

.mode-pills input:checked + span,
.mode-pills .lv-check:has(input:checked) {
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow);
}

.comm-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.comm-tab {
  padding: 5px 14px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: #e4ebf1;
  color: var(--muted);
  cursor: pointer;
  margin-right: 4px;
  border-radius: 6px 6px 0 0;
}

.comm-tab.active {
  background: #fff;
  color: var(--accent);
  font-weight: 700;
}

.comm-pane {
  display: none;
}

.comm-pane.active {
  display: block;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
  padding: 12px 0 4px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(231, 237, 243, 0), var(--bg) 28%);
}

.stat-card {
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.stat-label {
  color: var(--muted);
  font-size: 0.875rem;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(230, 0, 18, 0.06) 0%, transparent 42%),
    linear-gradient(160deg, #f7f8fa 0%, #eef1f5 55%, #e8edf4 100%);
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(34, 34, 34, 0.08);
  overflow: hidden;
}

.login-card .card-body {
  background: #fff;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.login-brand img {
  height: 48px;
  width: auto;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.login-card .btn-primary:hover,
.login-card .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.login-card .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(230, 0, 18, 0.15);
}

.captcha-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.captcha-row .form-control {
  flex: 1;
}

.captcha-img {
  width: 176px;
  height: 54px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  object-fit: contain;
}

.totp-secret-block {
  background: #f3f6f9;
  border-radius: 8px;
  padding: 12px 14px;
}

.totp-secret {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  letter-spacing: 0.04em;
}

.backup-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 1rem;
}

.badge-source {
  font-weight: 500;
}

.table td, .table th {
  vertical-align: middle;
}

.app-toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(20, 50, 77, 0.18);
  animation: app-toast-in 0.22s ease-out;
}

.app-toast.is-leaving {
  animation: app-toast-out 0.2s ease-in forwards;
}

.app-toast > .bi {
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 16px;
  color: var(--accent);
}

.app-toast-body {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.app-toast-close {
  flex: 0 0 auto;
  margin: -4px -4px 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.app-toast-close:hover {
  color: var(--text);
}

.app-toast-success {
  border-left-color: var(--ok);
}

.app-toast-success > .bi {
  color: var(--ok);
}

.app-toast-danger {
  border-left-color: var(--danger);
}

.app-toast-danger > .bi {
  color: var(--danger);
}

.app-toast-warning {
  border-left-color: #d59a1a;
}

.app-toast-warning > .bi {
  color: #d59a1a;
}

.app-toast-info {
  border-left-color: var(--accent);
}

@keyframes app-toast-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes app-toast-out {
  to {
    opacity: 0;
    transform: translateX(18px);
  }
}

.container .lv-box,
.container .card {
  border-color: var(--border);
  border-radius: var(--radius);
}

.page-toolbar form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

@media (max-width: 1599px) {
  .collect-fields-row.is-10,
  .collect-fields-row.is-12,
  .collect-fields-row:not(.is-8):not(.is-4):not(.is-2) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .settings-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 1199px) {
  .sampling-charts,
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .sampling-mid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sampling-mid > .collect-section,
  .sampling-mid > .collect-section.is-8 {
    grid-column: span 2;
  }
  .sampling-mid > .collect-section.is-4,
  .sampling-mid > .collect-section.is-2 {
    grid-column: span 1;
  }
  .collect-section-body,
  .collect-fields-row.is-10,
  .collect-fields-row.is-12,
  .collect-fields-row:not(.is-8):not(.is-4):not(.is-2) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collect-fields-row.is-8 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collect-fields-row.is-4 {
    grid-template-columns: 1fr;
  }
  .collect-fields-row.is-2 {
    grid-template-columns: 1fr;
  }
  .sampling-charts {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    min-height: 0;
  }
  .chart-box {
    min-height: 220px;
  }
  .data-table-wrap {
    min-height: 240px;
  }
  .sampling-records-controls {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
}

@media (max-width: 767px) {
  .app-nav-brand {
    width: 100%;
    border-right: 0;
    padding: 10px 14px;
  }
  .app-nav-brand-text {
    font-size: 14px;
  }
  .app-nav-end {
    width: 100%;
    margin-left: 0;
    border-top: 1px solid var(--nav-border);
  }
  .app-nav-item {
    flex: 1 1 auto;
    min-width: 72px;
  }
  .app-user {
    flex: 1;
    border-left: 0;
  }
  .lv-label {
    min-width: 56px;
  }
  .sampling-mid {
    grid-template-columns: 1fr;
  }
  .sampling-mid > .collect-section,
  .sampling-mid > .collect-section.is-8,
  .sampling-mid > .collect-section.is-4,
  .sampling-mid > .collect-section.is-2 {
    grid-column: span 1;
  }
  .collect-section-body,
  .collect-fields-row,
  .collect-fields-row.is-8,
  .collect-fields-row.is-10,
  .collect-fields-row.is-12,
  .collect-fields-row.is-4,
  .collect-fields-row.is-2 {
    grid-template-columns: 1fr;
  }
  .lv-btn-lg {
    min-width: 0;
    flex: 1 1 120px;
  }
  .gas-settings {
    grid-template-columns: 1fr;
  }
  .range-modules {
    grid-template-columns: 1fr;
  }
  .range-set-item {
    grid-template-columns: 1fr;
  }
  .sampling-records-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .sampling-status {
    justify-content: flex-start;
  }
  .sampling-actions {
    width: 100%;
  }
  .app-toast-stack {
    right: 12px;
    bottom: 12px;
  }
}

.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.app-dialog.is-open {
  display: flex;
}

.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 50, 77, 0.45);
}

.app-dialog-card {
  position: relative;
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(20, 50, 77, 0.22);
  padding: 18px 18px 14px;
}

.app-dialog-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.app-dialog-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.push-usage {
  margin: 0 0 12px;
}

.push-usage textarea {
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
}

@media (min-width: 1920px) {
  .app-main {
    max-width: 1920px;
    margin: 0 auto;
  }
}

.list-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 10px;
  font-size: 0.875rem;
  color: var(--muted);
}

.list-pagination-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.list-pagination-link {
  color: var(--brand-blue);
  text-decoration: none;
  padding: 0 2px;
}

.list-pagination-link:hover {
  text-decoration: underline;
}

.list-pagination-current {
  color: var(--text);
  padding: 0 4px;
}

.list-pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.list-pagination-jump-label {
  margin: 0;
  color: var(--muted);
}

.list-pagination-input {
  width: 72px;
  min-width: 72px;
  padding: 2px 8px;
  height: 30px;
}

.sampling-pagination {
  margin: 10px -14px -12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
