:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e2e2e0;
  --text: #1c1c1a;
  --text-dim: #6b6b67;
  --accent: #3b5d50;
  --accent-soft: #eef2f0;
  --amber: #8a6d1d;
  --amber-soft: #faf3df;
  --red: #9c3b34;
  --red-soft: #fbeceb;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: "Consolas", "SFMono-Regular", Menlo, monospace; font-variant-numeric: tabular-nums; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 14px 48px;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

.header h1 .version {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
  vertical-align: middle;
  margin-left: 2px;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
}

.status-group {
  display: flex;
  gap: 8px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b5b5b0;
}

.status-pill.ok .dot { background: #4a7a63; }
.status-pill.error .dot { background: var(--red); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

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

.panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

details[open] summary::after {
  transform: rotate(45deg);
}

.details-body {
  margin-top: 14px;
}

.panel-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
  flex: 1 1 130px;
}

.field-wide {
  flex: 1 1 260px;
}

.panel-row-secondary {
  margin-top: 14px;
}

.field label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field .value {
  font-size: 13.5px;
}

/* Monitoring panel */
.monitor-panel {
  display: flex;
  justify-content: center;
}

.monitor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.monitor[hidden] {
  display: none;
}

.monitor-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
}

.monitor-pulse::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.25;
  animation: monitor-breathe 2.4s ease-in-out infinite;
}

@keyframes monitor-breathe {
  0% { transform: scale(0.7); opacity: 0.35; }
  50% { transform: scale(1.6); opacity: 0.08; }
  100% { transform: scale(0.7); opacity: 0.35; }
}

.monitor-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.monitor-active {
  animation: monitor-fade-in 0.35s ease-out;
}

@keyframes monitor-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
}

.live-dot::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.22;
  animation: monitor-breathe 1.4s ease-in-out infinite;
}

.monitor-active-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.monitor-active-price {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.monitor-active-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* Chart */
.tab-group {
  display: flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}

.tab {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 11.5px;
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.chart-wrap {
  width: 100%;
  height: 150px;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  transition: filter 0.2s ease;
}

.chart-wrap svg.is-placeholder {
  filter: blur(7px);
}

.chart-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.38);
}

.chart-placeholder span {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
}

.chart-axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 4px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th {
  text-align: left;
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  white-space: nowrap;
}

.table tr:last-child td { border-bottom: none; }

.control-row {
  display: flex;
  gap: 8px;
}

input[type="number"] {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.control-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
}

button:hover { background: #f0f0ee; }
button:active { background: #e6e6e3; }

.hint {
  margin: 14px 2px 0;
  font-size: 12px;
  color: var(--text-dim);
}

.hint code {
  background: #f0f0ee;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: "Consolas", monospace;
}

.footer {
  font-size: 11.5px;
  color: var(--red);
  min-height: 16px;
}

.logout-row {
  display: flex;
  justify-content: center;
  margin: 4px 0 14px;
}

.logout-btn {
  color: var(--text-dim);
  font-size: 12px;
}

.logout-btn:hover {
  color: var(--red);
  border-color: var(--red-soft);
}

/* Login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-page {
  width: 100%;
  max-width: 360px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}

.login-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.login-title .version {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
}

.login-subtitle {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  letter-spacing: 0.04em;
}

/* Visually masks input as dots without using type="password", which is
   what triggers browser/password-manager save prompts and autofill. */
.masked-input {
  -webkit-text-security: disc;
  text-security: disc;
}

.login-form button {
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  font-weight: 600;
}

.login-form button:hover {
  opacity: 0.92;
}

.login-error {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--red);
}

/* Tablet / desktop */
@media (min-width: 600px) {
  .page { max-width: 880px; padding: 32px 20px 60px; }

  .header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

  .header h1 { font-size: 20px; }
  .subtitle { font-size: 12.5px; }

  .panel { padding: 18px 20px; }

  .table th, .table td { padding: 9px 10px; font-size: 13.5px; }

  .chart-wrap { height: 200px; }
}
