:root {
  color-scheme: dark;
  --bg: #08121e;
  --panel: #101f30;
  --panel-2: #15283b;
  --line: #2a4158;
  --text: #ecf3fc;
  --muted: #9db0c6;
  --accent: #38bdf8;
  --soft: #172f47;
  --good: #4ade80;
  --warning: #facc15;
  --danger: #fb7185;
  --card: var(--panel);
  --bad: var(--danger);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(ellipse at 15% 0, #172e45 0, #08121e 48%);
  font:
    15px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Noto Sans KR",
    sans-serif;
  min-height: 100vh;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button,
a,
input,
select,
textarea:focus {
  outline-offset: 3px;
}
button {
  cursor: pointer;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
input,
select,
textarea {
  background: #091929;
  border: 1px solid #37546d;
  border-radius: 9px;
  padding: 9px 11px;
  min-width: 0;
}
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #38bdf8;
  vertical-align: middle;
}
textarea {
  width: 100%;
  resize: vertical;
}
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 9px;
  border: 1px solid #37546d;
  background: #1b3349;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}
button:hover,
.btn:hover {
  background: #28455e;
  text-decoration: none;
}
button.primary,
.btn.primary {
  background: #087eb4;
  border-color: #22a5dd;
  color: white;
}
button.danger,
.btn.danger {
  background: #391c2a;
  color: #ffb1c2;
  border-color: #814052;
}
.btn.small,
button.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}
.btn.ghost {
  background: transparent;
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
label.field > input,
label.field > select {
  font-size: 14px;
  color: var(--text);
  min-height: 42px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -0.7px;
  margin-bottom: 4px;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 16px;
}
.shell {
  width: min(1700px, calc(100% - 36px));
  margin: 22px auto 40px;
}
.site-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.brand {
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid #369ac9;
  border-radius: 13px;
  background: linear-gradient(145deg, #1695c5, #1b385b);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #fff;
}
.site-head .sub {
  color: var(--muted);
  font-size: 12px;
}
.site-head nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(16, 31, 48, 0.93);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px 16px;
}
.toolbar .nav-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.toolbar input[type="date"] {
  min-width: 155px;
}
.toolbar select {
  min-width: 145px;
}
.status-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin: 13px 3px 18px;
  flex-wrap: wrap;
}
.status-row strong {
  color: #d9eaff;
}
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 18px;
}
.graph-card,
.panel {
  background: linear-gradient(145deg, rgba(21, 40, 59, 0.98), rgba(13, 27, 43, 0.98));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 25px #0002;
  min-width: 0;
  overflow: hidden;
}
.graph-card:hover {
  border-color: #487599;
}
.graph-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.graph-head h2 {
  margin: 0;
  font-size: 17px;
}
.graph-head .graph-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.drag-handle {
  padding: 0;
  width: 33px;
  min-height: 36px;
  font-size: 18px;
  cursor: grab;
  touch-action: none;
  flex: none;
}
.dragging {
  opacity: 0.35;
}
.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chart-open {
  background: none;
  border: 0;
  display: block;
  padding: 0;
  width: 100%;
  border-radius: 0;
  cursor: zoom-in;
  white-space: normal;
}
.chart-open:hover {
  background: #0b1725;
}
.card-chart {
  display: block;
  width: 100%;
  height: 234px;
}
.series-legend {
  display: flex;
  gap: 6px 12px;
  padding: 10px 16px 0;
  flex-wrap: wrap;
}
.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  min-width: 0;
}
.swatch {
  width: 20px;
  height: 3px;
  background: var(--series);
  display: inline-block;
  flex: none;
  border-radius: 3px;
}
.swatch-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--series);
  display: inline-block;
}
.device-groups {
  display: grid;
  gap: 0;
}
.device-group {
  border-top: 1px solid var(--line);
  padding: 12px 15px;
  min-width: 0;
  border-left: 3px solid var(--series);
}
.device-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.device-heading strong {
  font-size: 14px;
}
.device-heading .readout {
  margin-left: auto;
  font-size: 22px;
  font-weight: 800;
  color: var(--series);
  font-variant-numeric: tabular-nums;
}
.readout small {
  font-size: 11px;
  color: var(--muted);
  margin-left: 3px;
}
.device-id {
  font:
    11px/1.4 Consolas,
    monospace;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 9px 0;
}
.metric-grid .metric {
  min-width: 0;
}
.metric > span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.metric > strong {
  display: block;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.device-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 9px;
}
.zero-status {
  color: var(--muted);
  font-size: 11px;
  flex: 1;
  min-width: 160px;
}
.last-stale {
  color: var(--warning) !important;
}
.last-old {
  color: var(--danger) !important;
}
.empty-state {
  padding: 45px 24px;
  text-align: center;
  border: 1px dashed #46637e;
  border-radius: 16px;
  color: var(--muted);
  background: #102134;
}
.empty-state h2 {
  color: var(--text);
}
.notice {
  padding: 12px 16px;
  border: 1px solid #417099;
  border-radius: 10px;
  background: #142f46;
  margin: 12px 0;
  line-height: 1.6;
}
.notice.error {
  border-color: #965067;
  background: #331e2a;
  color: #ffd3de;
}
.notice.success {
  border-color: #2c755c;
  color: #b7f9d9;
}
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 11px;
}
.mono {
  font-family: Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.pill {
  display: inline-flex;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0e2034;
  color: var(--muted);
  font-size: 11px;
}
.pill.event {
  border-color: #577b9f;
  color: #ecf3fc;
}
.pill.zero {
  border-color: #3b8066;
  color: #97edbf;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.section-head h2,
.section-head h3 {
  margin: 0;
}
.section-body {
  padding: 16px;
}
.section-body > p:last-child {
  margin-bottom: 0;
}
.stack {
  display: grid;
  gap: 16px;
}
.two-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr);
  gap: 20px;
  align-items: start;
}
.form-row {
  display: flex;
  align-items: end;
  gap: 9px;
  flex-wrap: wrap;
}
.form-row .grow {
  flex: 1;
  min-width: 180px;
}
.setting-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}
.setting-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
}
.setting-link.selected {
  border-color: #38bdf8;
  background: #18354e;
}
.setting-link .muted {
  margin-left: auto;
  font-size: 12px;
}
.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.check-list label {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.device-settings {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.device-setting {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px;
  background: #0b1c2c;
}
.device-setting.enabled {
  border-color: #347caf;
}
.device-setting header {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.device-setting .form-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) 120px 130px;
}
.color-choice {
  display: flex;
  align-items: center;
  gap: 7px;
}
.color-choice select {
  width: 100%;
}
.help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.danger-zone {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}
.screen-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: #050c14;
  color: var(--text);
  flex-direction: column;
}
.screen-modal.open {
  display: flex;
}
.modal-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 17px;
  border-bottom: 1px solid #38506a;
  flex: none;
  background: #101e2d;
}
.modal-top h2 {
  margin: 0;
  font-size: 18px;
}
.modal-title-wrap {
  flex: 1;
  min-width: 0;
}
.modal-top .subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.modal-close {
  min-height: 38px;
  width: 40px;
  padding: 0;
  font-size: 23px;
  flex: none;
}
.modal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 17px;
  font-size: 12px;
  background: #101e2d;
  border-bottom: 1px solid var(--line);
}
.modal-controls input {
  width: 85px;
  padding: 5px 7px;
}
.modal-controls select {
  padding: 5px 7px;
  max-width: 450px;
}
.modal-controls .series-legend {
  padding: 0;
  margin-right: auto;
}
.modal-graph-wrap {
  flex: 1;
  min-height: 170px;
  position: relative;
  background: #050b12;
}
.modal-chart {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}
.selection-line {
  stroke: #facc15;
  stroke-width: 1;
  stroke-dasharray: 5 4;
  pointer-events: none;
}
.selection-shade {
  fill: #facc1515;
  stroke: #facc15;
  stroke-width: 1;
  pointer-events: none;
}
.event-dot {
  fill: white;
  stroke: var(--series);
  stroke-width: 2;
  cursor: pointer;
  filter: drop-shadow(0 0 3px #fff6);
}
.modal-results {
  flex: 0 0 auto;
  max-height: 43vh;
  min-height: 100px;
  overflow: auto;
  border-top: 1px solid #38506a;
  background: #0b1623;
  padding: 12px 17px;
  overscroll-behavior: contain;
}
.result-heading {
  font-size: 13px;
  font-weight: 700;
  color: #cde4fb;
  margin-bottom: 9px;
}
.result-groups {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(370px, 1fr));
}
.result-group {
  border: 1px solid #304960;
  border-left: 3px solid var(--series);
  border-radius: 10px;
  padding: 11px 13px;
  background: #102134;
  min-width: 0;
}
.result-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--series);
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.result-stats span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.result-stats strong {
  display: block;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.trend-increase {
  color: #7dd3fc;
}
.trend-decrease {
  color: #facc15;
}
.trend-flat {
  color: #b8c9db;
}
.forecast {
  font-size: 12px;
  margin-top: 9px;
  color: #b7eccf;
}
.segment-details {
  font-size: 11px;
  margin-top: 8px;
  color: var(--muted);
}
.segment-details summary {
  cursor: pointer;
}
.event-editor {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1.6fr);
  gap: 18px;
}
.event-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.event-editor label {
  font-size: 12px;
  color: var(--muted);
}
.event-editor textarea {
  height: 74px;
  display: block;
  margin: 5px 0 8px;
}
.event-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.event-state {
  font-size: 12px;
  color: #b8e6cd;
  white-space: normal;
}
.data-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}
.data-toolbar .field {
  min-width: 175px;
  flex: 1;
}
.data-tools {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.data-layout {
  display: grid;
  grid-template-columns: 255px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.device-selector {
  position: sticky;
  top: 15px;
}
.device-selector .check-list {
  display: block;
  max-height: 65vh;
  overflow: auto;
}
.device-selector .check-list label {
  margin: 6px 0;
  align-items: start;
}
.device-selector select {
  width: 100%;
}
.data-chart {
  width: 100%;
  height: 220px;
  display: block;
  background: #081724;
  border-radius: 10px;
}
.raw-chart-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.raw-chart-tabs label {
  font-size: 12px;
}
.table-wrap {
  overflow: auto;
  max-height: 62vh;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #152a3f;
  font-size: 11px;
  color: #a8c5e3;
}
td.num {
  text-align: right;
  font-family: Consolas, monospace;
}
tr.zero-row {
  background: #11332b;
}
tr.event-row {
  background: #152f46;
}
td.wrap-text {
  white-space: normal;
  min-width: 170px;
  max-width: 300px;
  overflow-wrap: anywhere;
}
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  flex-wrap: wrap;
}
.zero-list {
  max-height: 275px;
  overflow: auto;
}
.zero-list input {
  margin: 0;
}
.experiment-list {
  display: grid;
  gap: 8px;
}
.experiment-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px;
}
.experiment-item summary {
  cursor: pointer;
}
.experiment-item .content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0;
}
.experiment-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.experiment-form .form-row label {
  flex: 1;
}
.page-caption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  display: none;
}
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2500;
  max-width: min(460px, calc(100% - 32px));
  background: #173b4c;
  color: #e8faff;
  padding: 13px 17px;
  border: 1px solid #3ba0bc;
  border-radius: 12px;
  box-shadow: 0 7px 28px #0006;
}
.toast.error {
  background: #462332;
  border-color: #d36b89;
}
.modal-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}
.hourly-layout {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 16px;
  padding: 16px;
  flex: 1;
  min-height: 0;
}
.hourly-layout .table-wrap {
  max-height: none;
}
.hourly-chart {
  width: 100%;
  height: 100%;
  min-height: 250px;
}
.screen-modal.hourly {
  z-index: 1100;
}
.zero-history-details {
  margin-top: 12px;
}
.zero-history-details > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}
body.modal-open {
  overflow: hidden;
}
.chart-hint {
  fill: #88a1b9;
  font-size: 12px;
}
.chart-axis {
  fill: #9bb2cb;
  font-size: 11px;
}
.chart-grid {
  stroke: #294259;
  stroke-width: 1;
}
.chart-grid.minor {
  stroke: #1a2b3d;
  stroke-width: 0.65;
}
.chart-label {
  fill: #d4e7f8;
  font-size: 12px;
}
.chart-line {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.context-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.context-grid strong {
  display: block;
  word-break: break-word;
}
.context-grid span {
  font-size: 11px;
  color: var(--muted);
}
@media (min-width: 1450px) {
  .dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .dashboard:has(.graph-card:only-child) {
    grid-template-columns: minmax(0, 850px);
  }
}
@media (max-width: 1080px) {
  .two-columns {
    grid-template-columns: 1fr;
  }
  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .data-layout {
    grid-template-columns: 215px minmax(0, 1fr);
  }
  .toolbar .nav-actions {
    margin-left: 0;
  }
  .result-groups {
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  }
}
@media (max-width: 760px) {
  .shell {
    width: calc(100% - 20px);
    margin: 13px auto 25px;
  }
  .site-head {
    gap: 10px;
    flex-wrap: wrap;
  }
  .site-head nav {
    width: 100%;
    margin: 2px 0 0;
    gap: 6px;
  }
  h1 {
    font-size: 23px;
  }
  .toolbar {
    gap: 9px;
    padding: 12px;
  }
  .toolbar > .field {
    flex: 1;
    min-width: 130px;
  }
  .toolbar .nav-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .toolbar select,
  .toolbar input[type="date"] {
    width: 100%;
    min-width: 0;
  }
  .dashboard {
    grid-template-columns: 1fr;
  }
  .status-row {
    gap: 6px;
    margin-bottom: 12px;
  }
  .metric-grid {
    gap: 6px;
  }
  .modal-top {
    padding: 8px 10px;
    gap: 8px;
  }
  .modal-top h2 {
    font-size: 16px;
  }
  .modal-controls {
    padding: 7px 10px;
    gap: 7px;
  }
  .modal-controls select {
    max-width: 100%;
    width: 100%;
  }
  .modal-results {
    padding: 10px;
    max-height: 45vh;
  }
  .result-groups {
    grid-template-columns: 1fr;
  }
  .event-editor {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .modal-graph-wrap {
    min-height: 180px;
  }
  .data-layout {
    grid-template-columns: 1fr;
  }
  .device-selector {
    position: static;
  }
  .device-selector .check-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 240px;
  }
  .device-selector .check-list label {
    margin: 0;
  }
  .device-setting .form-row {
    grid-template-columns: 1fr 1fr;
  }
  .device-setting .form-row .field:first-child {
    grid-column: 1/-1;
  }
  .hourly-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 250px 1fr;
    overflow: auto;
  }
  .modal-top .btn {
    font-size: 11px;
    padding: 5px 8px;
  }
  .context-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .raw-chart-tabs {
    gap: 5px;
  }
  .device-heading .readout {
    font-size: 21px;
  }
}
@media (max-height: 550px) and (min-width: 761px) {
  .modal-results {
    max-height: 39vh;
  }
  .modal-graph-wrap {
    min-height: 130px;
  }
  .modal-top {
    padding: 5px 12px;
  }
  .modal-controls {
    padding: 4px 12px;
  }
}
@media print {
  body {
    background: white;
    color: #111;
  }
  .site-head nav,
  .toolbar,
  .nav-actions,
  .device-actions,
  .drag-handle,
  .modal-close,
  button,
  .pagination {
    display: none !important;
  }
  .shell {
    width: 100%;
    margin: 0;
  }
  .panel,
  .graph-card {
    break-inside: avoid;
    box-shadow: none;
    background: #fff;
    color: #111;
  }
  .dashboard {
    grid-template-columns: 1fr 1fr;
  }
  .screen-modal {
    position: static !important;
  }
  .screen-modal:not(.open) {
    display: none !important;
  }
  .screen-modal.open {
    min-height: 260mm;
    background: #091723;
  }
  .table-wrap {
    max-height: none;
    overflow: visible;
  }
  @page {
    size: A4;
    margin: 12mm;
  }
}

/* v3.1: only device-specific data pages can operate zero controls. */
.device-zero-control {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #102536;
}
.device-zero-info {
  min-width: 0;
  flex: 1;
}
.device-zero-info h3 {
  margin: 0 0 6px;
  font-size: 14px;
}
.device-zero-info p {
  margin: 9px 0 6px;
  line-height: 1.65;
}
.zero-target {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--series);
  font-size: 13px;
}
.zero-target .mono {
  color: #a9c7e1;
  font-size: 12px;
}
.device-zero-buttons {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.device-zero-buttons form {
  margin: 0;
}
.zero-request-button {
  white-space: nowrap;
}
.zero-pending-status {
  display: inline-block;
  color: #fcd34d;
  font-size: 12px;
  font-weight: 700;
}
.sample-zero-guide {
  padding: 12px 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  border-bottom: 1px solid var(--line);
}
.sample-zero-guide strong {
  color: #d7e9f7;
}
.sample-target {
  vertical-align: top;
  min-width: 237px;
}
.sample-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.sample-zero-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
}
.sample-zero-form {
  margin: 0;
}
.zero-set-button {
  background: #123a53;
  color: #b8e7ff;
  border-color: #326788;
}
.zero-unset-button {
  background: #19302d;
  color: #c1e6d9;
  border-color: #547e72;
}
.zero-point-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  padding: 3px 7px;
  background: #164934;
  color: #9df0c0;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.sample-table tr.zero-row .sample-target {
  box-shadow: inset 3px 0 #4ade80;
}
.data-device,
[id^="samples-"] {
  scroll-margin-top: 16px;
}
@media (max-width: 760px) {
  .device-zero-control {
    flex-direction: column;
    padding: 14px;
    gap: 12px;
  }
  .device-zero-buttons {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .device-zero-info {
    width: 100%;
  }
  .sample-zero-guide {
    padding: 12px 14px;
  }
  .sample-zero-actions {
    gap: 6px;
  }
  .sample-zero-form button {
    min-height: 34px;
  }
  .sample-target {
    min-width: 234px;
  }
  .zero-request-button {
    font-size: 13px;
  }
}
@media print {
  .device-zero-control,
  .sample-zero-actions,
  .sample-zero-guide {
    display: none !important;
  }
}

/* v3.2: per-measurement events and notes, independent of per-device zero controls. */
.sample-event-guide {
  padding: 11px 18px;
  color: #a9c5df;
  font-size: 12px;
  line-height: 1.7;
  background: #0c1f30;
  border-bottom: 1px solid var(--line);
}
.sample-event-guide strong {
  color: #d8edfc;
}
.sample-table td {
  vertical-align: top;
}
td.sample-annotation-cell {
  min-width: 265px;
  max-width: 360px;
}
.sample-event-status {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 7px;
}
.sample-event-label {
  white-space: normal;
  text-align: left;
  line-height: 1.5;
}
.event-suppressed,
.event-empty {
  font-size: 11px;
  color: #94a9bc;
}
.event-suppressed {
  border: 1px dashed #536679;
  padding: 3px 7px;
  border-radius: 5px;
}
.sample-note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
  font-size: 12px;
  color: #f0f6fc;
  margin: 5px 0 9px;
}
.sample-note-text.is-empty {
  color: #7d97b0;
  font-size: 11px;
}
.sample-annotation-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.sample-annotation-actions button {
  min-height: 32px;
  white-space: nowrap;
}
.event-add-button {
  background: #193b59;
  border-color: #367ba8;
  color: #c6ecff;
}
.event-remove-button {
  background: #302a33;
  border-color: #735a70;
  color: #f0cbdc;
}
.sample-note-editor > td {
  padding: 0 !important;
  white-space: normal;
  background: #0f2437;
  border-top: 1px solid #41688b;
  border-bottom: 1px solid #41688b;
}
.sample-editor {
  padding: 16px 18px;
  min-width: 0;
  max-width: 960px;
}
.event-preview:not(:empty) {
  margin-top: 14px;
  border: 1px solid #41688b;
  border-radius: 10px;
  background: #0f2437;
}
.sample-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.sample-editor-head .mono {
  font-size: 12px;
  color: #a5c6e1;
  margin-left: 8px;
}
.sample-editor-time {
  margin-top: 4px;
  font-size: 13px;
  color: #cde7fa;
  font-variant-numeric: tabular-nums;
}
.sample-editor-head button {
  flex: none;
}
.sample-editor .context-grid {
  gap: 12px;
  line-height: 1.5;
}
.sample-editor .context-grid strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.sample-editor-event {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  margin-bottom: 6px;
}
.editor-event-status {
  font-size: 12px;
  color: #d6ecfb;
}
.sample-editor-label {
  margin-top: 12px;
  gap: 6px;
}
.sample-note-input {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  white-space: pre-wrap;
}
.sample-editor-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.editor-save-state {
  margin-right: auto;
  color: #a9dfc8;
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.sample-editor p.help {
  margin: 10px 0 0;
  line-height: 1.6;
}
.event-saved-note {
  margin: 7px 0 9px;
  padding: 9px 12px;
  border-left: 3px solid #5395c0;
  background: #132b40;
  color: #ecf5ff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.6;
  max-height: 115px;
  overflow: auto;
}
.event-saved-note.is-empty {
  color: #8facbf;
}
.event-actions {
  flex-wrap: wrap;
}
.event-actions .btn {
  white-space: normal;
  text-align: center;
}
@media (max-width: 760px) {
  .sample-event-guide {
    padding: 11px 14px;
  }
  .sample-editor {
    padding: 13px;
    width: calc(100vw - 64px);
    max-width: 100%;
  }
  .sample-editor-head {
    gap: 8px;
    flex-wrap: wrap;
  }
  .sample-editor-head .mono {
    display: block;
    margin-left: 0;
    margin-top: 4px;
  }
  .sample-editor-footer {
    gap: 6px;
  }
  .editor-save-state {
    width: 100%;
    margin: 0;
  }
  .sample-annotation-actions button {
    min-height: 35px;
  }
  .sample-note-input {
    font-size: 16px;
  }
  .event-actions .btn {
    width: 100%;
  }
}
@media print {
  .sample-annotation-actions,
  .sample-note-editor,
  .sample-event-guide,
  .event-actions {
    display: none !important;
  }
  .sample-note-text {
    color: #111;
  }
  .sample-event-label {
    display: inline !important;
    background: none;
    color: #111;
    padding: 0;
    border: 0;
  }
}

@media (max-width: 760px) {
  .sample-table.editing-note {
    max-height: 78vh;
  }
}

/* v3.2.4: event action + event text / memo action + memo text: two compact lines. */
td.sample-annotation-cell {
  min-width: 300px;
  max-width: 410px;
}
.sample-annotation-line {
  display: grid;
  grid-template-columns: 108px minmax(145px, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 32px;
}
.sample-annotation-line + .sample-annotation-line {
  margin-top: 5px;
}
.sample-annotation-line > button {
  margin: 0;
  min-height: 32px;
  min-width: 0;
  white-space: nowrap;
  padding: 5px 7px;
  font-size: 11px;
}
.sample-annotation-line .sample-event-status {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.sample-annotation-line .sample-event-label {
  min-width: 0;
  min-height: 0;
  padding: 2px 0;
  border: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.5;
}
.sample-annotation-line .event-suppressed {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sample-annotation-line .sample-note-text {
  min-width: 0;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
}
/* v3.2.5: internal signed values are unchanged; display magnitudes with ▲/▼ and the existing colors. */
.signed-value {
  display: inline !important;
  font-size: inherit !important;
  font-weight: inherit;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.signed-value .value-direction {
  display: inline !important;
  color: inherit !important;
  font-size: 0.78em !important;
  font-weight: 900 !important;
  line-height: 1;
  vertical-align: 0.06em;
  font-family: Arial, "Noto Sans KR", sans-serif;
}
.signed-value.value-positive {
  color: #7dd3fc;
}
.signed-value.value-negative {
  color: #facc15;
}
.signed-value.value-zero,
.signed-value.value-none {
  color: #b8c9db;
}
@media screen {
  .signed-value.value-endpoint {
    color: #fff;
  }
}
.chart-axis.value-positive {
  fill: #7dd3fc;
}
.chart-axis.value-negative {
  fill: #facc15;
}
.chart-axis.value-zero {
  fill: #cddce9;
}
.chart-zero-line {
  stroke: #9eb5cb;
  stroke-width: 1.5;
}
.value-color-legend {
  white-space: normal;
}
@media (max-width: 760px) {
  .sample-annotation-line > button {
    min-height: 35px;
  }
  .sample-annotation-line {
    min-height: 35px;
  }
}
@media print {
  .sample-annotation-line {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .sample-annotation-line > .sample-event-toggle,
  .sample-annotation-line > .sample-memo-button {
    display: none !important;
  }
  .sample-annotation-line .sample-note-text {
    white-space: pre-wrap;
    overflow: visible;
  }
  .signed-value.value-positive {
    color: #0369a1;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .signed-value.value-negative {
    color: #986800;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .signed-value.value-zero {
    color: #475569;
  }
}

/* v3.2.6: marker kinds are independent of signed ▲/▼ value indicators. */
.marker-legend {
  display: flex;
  gap: 9px 18px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 2px;
  padding: 9px 11px;
  background: #091b2b;
  border: 1px solid #2d4962;
  border-radius: 9px;
}
.marker-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--marker-color, #f8fafc);
}
.marker-event {
  --marker-color: #f8fafc;
}
.marker-zero-request {
  --marker-color: #fb923c;
}
.marker-zero-applied {
  --marker-color: #4ade80;
}
.marker-symbol {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--marker-color, #f8fafc);
  border: 1px solid #071321;
  vertical-align: middle;
}
.marker-event > .marker-symbol {
  border-radius: 50%;
}
.marker-zero-request > .marker-symbol {
  width: 9px;
  height: 9px;
  margin: 0 1px;
  transform: rotate(45deg);
}
.marker-zero-applied > .marker-symbol {
  border-radius: 1px;
}
.marker-legend b {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  opacity: 0.8;
}
.chart-marker {
  cursor: pointer;
  outline: none;
}
.chart-marker .marker-shape {
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2px #0009);
}
.chart-marker:hover .marker-shape,
.chart-marker:focus .marker-shape {
  stroke: #fff;
  stroke-width: 2.5;
}
.marker-stem {
  stroke: #8aa4bb;
  stroke-width: 1;
  stroke-dasharray: 2 2;
  vector-effect: non-scaling-stroke;
}
.sample-annotation-line .sample-event-label .marker-badge {
  font-size: 11px;
  margin-right: 7px;
}
.sample-annotation-line .sample-event-label .marker-badge:last-child {
  margin-right: 0;
}
.editor-event-status {
  display: flex;
  gap: 6px 12px;
  flex-wrap: wrap;
}
.editor-marker-selection {
  font-size: 12px;
  color: #dcebf8;
  border-left: 2px solid #7396b4;
  padding: 4px 8px;
  margin-top: 12px;
}
.editor-marker-selection[hidden] {
  display: none;
}
.zero-point-pill {
  gap: 5px;
}
@media (max-width: 760px) {
  .marker-legend {
    gap: 8px 13px;
    padding: 8px;
  }
  .marker-legend .marker-badge {
    font-size: 11px;
  }
}
@media print {
  .marker-symbol,
  .marker-badge {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .marker-legend {
    background: #102536;
  }
}

/* v3.3: the active calibration is visible beside each device's converted values. */
.device-calibration-status {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  font-size: 12px;
  margin: 7px 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.device-calibration-status.is-calibrated {
  color: #87dfc1;
}
.device-calibration-status.is-default {
  color: #f7cc71;
}
.device-calibration-status span {
  color: var(--muted);
}
.device-calibration-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #102638;
}
.device-calibration-panel > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 14px;
  min-width: 0;
}
.device-calibration-panel strong {
  font-size: 13px;
}
.device-calibration-panel.is-calibrated strong {
  color: #87dfc1;
}
.device-calibration-panel.is-default strong {
  color: #f7cc71;
}
.device-calibration-ratio {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.device-calibration-panel .help {
  flex-basis: 100%;
  font-size: 12px;
}
@media (max-width: 760px) {
  .device-calibration-panel {
    padding: 12px 14px;
    align-items: flex-start;
  }
  .device-calibration-panel > div {
    display: block;
  }
  .device-calibration-ratio,
  .device-calibration-panel .help {
    display: block;
    margin-top: 4px;
  }
  .device-calibration-panel .btn {
    flex-shrink: 0;
  }
}
@media print {
  .device-calibration-panel,
  .device-calibration-status {
    background: white;
    color: #111;
  }
  .device-calibration-panel strong,
  .device-calibration-status.is-calibrated,
  .device-calibration-status.is-default {
    color: #111;
  }
}

/* Device unit selection and the compact readout suffix. */
.device-setting .form-row.device-spec-fields {
  grid-template-columns: minmax(140px, 1fr) 90px 120px 130px;
}
.device-spec-fields .field {
  min-width: 0;
}
.device-spec-fields input,
.device-spec-fields select {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.device-heading .readout {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.readout .readout-unit {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 760px) {
  .device-setting .form-row.device-spec-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .device-spec-fields .device-label-field,
  .device-spec-fields .device-color-field {
    grid-column: 1/-1;
  }
}

/* Selected-range zoom uses one button for zooming and restoring the full day. */
#chartModal {
  overflow-y: auto;
}
#chartModal .modal-results {
  flex-shrink: 1;
}
.modal-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
  flex: none;
  padding: 7px 17px;
  background: #101e2d;
  border-bottom: 1px solid var(--line);
}
.modal-zoom-controls .help {
  flex: 1;
  min-width: 180px;
  font-size: 11px;
  line-height: 1.5;
}
#modalZoomButton {
  min-height: 34px;
  min-width: 138px;
}
#modalZoomButton:disabled {
  cursor: not-allowed;
}
#modalZoomButton[aria-pressed="true"] {
  background: #243d50;
  border-color: #65bfe3;
  color: #d8f3ff;
}
@media (max-width: 760px) {
  .modal-zoom-controls {
    padding: 7px 10px;
    gap: 6px 10px;
  }
  .modal-zoom-controls .help {
    min-width: 140px;
  }
  #modalZoomButton {
    min-width: 0;
    min-height: 36px;
  }
}
@media print {
  .modal-zoom-controls {
    display: none !important;
  }
}
