:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --ink: #17262e;
  --muted: #5f6f79;
  --line: #d7e0e6;
  --line-strong: #b8c6cf;
  --primary: #0e7490;
  --primary-strong: #0b5e76;
  --primary-soft: #e0f2f7;
  --accent: #2563eb;
  --accent-soft: #e3ecfd;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf1dd;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --violet: #6d28d9;
  --violet-soft: #f0eafa;
  --shadow-sm: 0 1px 2px rgba(16, 30, 40, 0.08);
  --shadow-md: 0 8px 24px rgba(16, 30, 40, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --header-h: 60px;
  --tab-h: 48px;
  --font: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

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

a {
  color: var(--primary);
}

.noscript {
  max-width: 720px;
  margin: 40px auto;
  padding: 20px;
  background: var(--warn-soft);
  border: 1px solid #f0d9a8;
  border-radius: var(--radius);
}

/* ---------- shell ---------- */

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #0e7490, #2563eb);
  color: #fff;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.header-spacer {
  flex: 1 1 auto;
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  min-width: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.icon-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-strong);
}

.icon-btn .btn-label {
  font-size: 12px;
  font-weight: 600;
}

/* ---------- tabs ---------- */

.tab-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  height: var(--tab-h);
  display: flex;
  gap: 4px;
  align-items: stretch;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.tab-btn::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
}

.tab-btn.active {
  color: var(--primary-strong);
}

.tab-btn.active::after {
  background: var(--primary);
}

.tab-btn .tab-icon {
  display: inline-flex;
}

/* ---------- content ---------- */

.content {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 20px 48px;
  flex: 1 1 auto;
}

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

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

.page-title small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.section {
  margin-bottom: 22px;
}

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

.section-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.section-title .section-count {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

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

.panel-pad {
  padding: 18px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

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

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #991b1b;
}

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

.btn-soft:hover {
  background: #cde9f2;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-xs {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

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

.btn-icon-only.btn-sm {
  width: 34px;
}

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.required-mark {
  color: var(--danger);
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.15);
}

textarea.input {
  height: auto;
  min-height: 82px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.input.invalid {
  border-color: var(--danger);
}

.input-suffix {
  position: relative;
}

.input-suffix .input {
  padding-right: 46px;
}

.input-suffix .suffix {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

.input-keypad-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.input-keypad-btn:hover {
  background: #cde9f2;
}

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

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

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

.field-error {
  display: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
}

.field-error.visible {
  display: block;
}

.form-errors {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.form-errors.hidden {
  display: none;
}

/* ---------- stats ---------- */

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

.stat-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-card .stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-value .unit {
  margin-left: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.stat-card .stat-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.trend-up {
  color: var(--danger);
}

.trend-down {
  color: var(--accent);
}

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

/* ---------- segmented ---------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.seg-btn {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- table ---------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

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

.data-table th {
  position: sticky;
  top: 0;
  background: #eef3f6;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: #f8fbfc;
}

.data-table .num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.data-table .memo-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 220px;
}

.search-box .input {
  padding-left: 36px;
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* ---------- chart ---------- */

.chart-panel {
  padding: 16px 18px 18px;
}

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

.chart-wrap {
  width: 100%;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-tip {
  position: fixed;
  z-index: 120;
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(23, 38, 46, 0.94);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.chart-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: -1px;
}

/* ---------- evaluation ---------- */

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

.eval-list {
  display: flex;
  flex-direction: column;
}

.eval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.eval-row:last-child {
  border-bottom: 0;
}

.eval-row .eval-label {
  font-size: 13px;
  color: var(--muted);
}

.eval-row .eval-value {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.eval-message {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  line-height: 1.6;
}

.eval-message.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.eval-message.disclaimer {
  margin-top: 8px;
  border-left-color: var(--line-strong);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
}

/* ---------- history / logs ---------- */

.log-list {
  display: flex;
  flex-direction: column;
}

.log-item {
  display: grid;
  grid-template-columns: 130px 92px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.log-item:last-child {
  border-bottom: 0;
}

.log-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.log-level {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.log-level.info { color: var(--accent); }
.log-level.warn { color: var(--warn); }
.log-level.error { color: var(--danger); }

.log-message {
  min-width: 0;
  overflow-wrap: anywhere;
}

.log-detail {
  color: var(--muted);
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- dev mode ---------- */

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

.dev-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.dev-card .dev-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.dev-card .dev-value {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.dev-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.switch-row:last-child {
  border-bottom: 0;
}

.switch-label {
  font-size: 13px;
  font-weight: 600;
}

.switch-label small {
  display: block;
  font-weight: 500;
  color: var(--muted);
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: var(--line-strong);
  transition: background 0.15s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.switch input:checked + .track {
  background: var(--primary);
}

.switch input:checked + .track::after {
  transform: translateX(20px);
}

.test-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.test-count {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
}

.test-count .n {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.test-count .l {
  font-size: 11px;
  color: var(--muted);
}

.test-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
  margin: 12px 0;
}

.test-progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.2s ease;
}

.test-list {
  margin-top: 12px;
}

.test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.test-row:last-child {
  border-bottom: 0;
}

.test-status {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.test-status.ok { background: var(--success-soft); color: var(--success); }
.test-status.fail { background: var(--danger-soft); color: var(--danger); }
.test-status.warn { background: var(--warn-soft); color: var(--warn); }
.test-status.wait { background: var(--bg); color: var(--muted); }

.test-detail {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(13, 26, 35, 0.48);
}

.modal {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
}

.modal-close:hover {
  background: var(--line);
}

.modal-body {
  font-size: 14px;
}

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

/* ---------- keypad ---------- */

.keypad {
  position: fixed;
  z-index: 300;
  width: min(320px, calc(100vw - 24px));
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

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

.keypad-key {
  height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, transform 0.05s ease;
}

.keypad-key:hover {
  background: var(--bg);
}

.keypad-key:active {
  background: var(--primary-soft);
  transform: scale(0.97);
}

.keypad-key.fn {
  background: var(--bg);
  color: var(--muted);
  font-size: 15px;
}

.keypad-key.ok {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-size: 15px;
}

.keypad-key.ok:hover {
  background: var(--primary-strong);
}

.keypad-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
}

.keypad-current strong {
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- toast / id tooltip ---------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: #1b2c36;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.22s ease;
}

.toast.success { border-left: 4px solid #34d399; }
.toast.error { border-left: 4px solid #f87171; }
.toast.info { border-left: 4px solid #60a5fa; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-id-tooltip {
  position: fixed;
  z-index: 600;
  padding: 5px 8px;
  border-radius: 5px;
  background: #101c24;
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  max-width: 300px;
  overflow-wrap: anywhere;
}

.ui-context-menu {
  position: fixed;
  z-index: 700;
  min-width: 150px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.ui-context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.ui-context-item:hover {
  background: var(--bg);
}

/* ---------- auth ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.auth-panel .field {
  margin-bottom: 14px;
}

.auth-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.auth-error.hidden {
  display: none;
}

.auth-hint {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- responsive ---------- */

/* ---------- dashboard responsive ---------- */

@media (max-width: 720px) {
  .header-modules {
    max-width: 220px;
    overflow-x: auto;
  }

  .header-modules .seg-btn {
    padding: 0 8px;
  }
}

@media (max-width: 480px) {
  .header-modules {
    max-width: 170px;
  }
}

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .eval-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  :root {
    --header-h: 56px;
  }

  .app-header {
    padding: 0 12px;
  }

  .content {
    padding: 14px 12px 40px;
  }

  .page-title {
    font-size: 20px;
  }

  .brand-sub {
    display: none;
  }

  .header-actions .btn-label {
    display: none;
  }

  .icon-btn {
    padding: 0;
  }

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

  .form-grid .field-wide {
    grid-column: auto;
  }

  .test-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .log-item {
    grid-template-columns: 92px 70px minmax(0, 1fr);
  }

  .log-detail {
    display: none;
  }

  .keypad {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    border-radius: var(--radius);
  }

  .keypad-key {
    height: 56px;
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card .stat-value {
    font-size: 20px;
  }

  .page-head {
    flex-direction: column;
  }

  .page-head .btn {
    width: 100%;
  }

  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 0;
  }

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

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

  .auth-panel {
    padding: 22px 18px;
  }

  .data-table {
    min-width: 640px;
  }
}
/* ---------- module switch ---------- */

.header-modules {
  flex: 0 0 auto;
}

.header-modules .seg-btn {
  height: 34px;
}
/* ---------- dashboard ---------- */

.dashboard-module-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.dashboard-card {
  min-width: 0;
}

.dashboard-value {
  margin: 8px 0 4px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.dashboard-spark {
  margin-top: 10px;
  width: 100%;
  height: 64px;
}

.dashboard-spark svg {
  width: 100%;
  height: 64px;
  display: block;
}

@media (max-width: 960px) {
  .dashboard-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .dashboard-module-grid {
    grid-template-columns: 1fr;
  }
}
/* ---------- evaluation AI ---------- */

.evaluation-module-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.evaluation-card {
  min-width: 0;
}

.evaluation-card .eval-row {
  padding: 8px 0;
}

@media (max-width: 960px) {
  .evaluation-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .evaluation-module-grid {
    grid-template-columns: 1fr;
  }
}