:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #263449;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.app-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

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

.field label, .field-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

select, input[type="text"], input[type="password"] {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  min-width: 180px;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button {
  font-family: inherit;
}

.primary {
  background: var(--accent-dim);
  border: 1px solid var(--accent-dim);
  color: #04121c;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
}

.primary:hover { background: var(--accent); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented-btn {
  background: var(--surface-alt);
  border: none;
  color: var(--text-dim);
  padding: 9px 18px;
  cursor: pointer;
  font-size: 0.9rem;
}

.segmented-btn.active {
  background: var(--accent-dim);
  color: #04121c;
  font-weight: 600;
}

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  padding-bottom: 9px;
}

.switch input { width: 16px; height: 16px; }

.status-area {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}

.status-area.info { color: var(--accent); border-color: var(--accent-dim); }
.status-area.error { color: var(--danger); border-color: var(--danger); }
.status-area.loading { color: var(--warn); border-color: var(--warn); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  white-space: nowrap;
}

thead {
  background: var(--surface-alt);
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.06);
}

.empty-row {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  white-space: normal;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-badge.ok { background: rgba(74, 222, 128, 0.15); color: var(--ok); }
.status-badge.warn { background: rgba(251, 191, 36, 0.15); color: var(--warn); }
.status-badge.danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.status-badge.neutral { background: rgba(148, 163, 184, 0.15); color: var(--text-dim); }

.app-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.app-footer a { color: var(--accent); }

@media (max-width: 640px) {
  main { padding: 16px; }
  .controls { flex-direction: column; align-items: stretch; }
  select, input[type="text"] { min-width: 0; width: 100%; }
}
