:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --red: #dc2626;
  --blue: #2563eb;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.topbar {
  background: #111827;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 38px; height: 38px; border-radius: 9px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; }
.brand p { margin: 0; font-size: 12px; color: #9ca3af; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  white-space: nowrap;
}
.badge.offline { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(330px, 380px) 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: 2px solid rgba(29, 78, 216, 0.25);
  border-color: var(--accent);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.topbar .btn { color: #fff; border-color: #374151; }
.topbar .btn:hover { background: #1f2937; }

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

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f9fafb;
}
.card-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.card-hint { font-size: 11px; color: var(--muted); margin-top: 2px; min-height: 15px; }

.chart-wrap { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; }
.chart-head h2 { font-size: 14px; margin: 0; }
.chart-legend { font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 3px 0 8px; }
.dot.red { background: var(--red); }
.dot.blue { background: var(--blue); }
.canvas-holder { position: relative; height: 260px; margin-top: 8px; }
#chart { width: 100%; height: 100%; display: block; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.5;
  z-index: 2;
}

.table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
th:first-child, td:first-child { text-align: left; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.down { color: var(--red); }
td.up { color: #059669; }
td.right { color: var(--blue); }
td.left { color: #7c3aed; }

.disclaimer { font-size: 11px; color: var(--muted); margin: 14px 0 0; }

dialog {
  border: none;
  border-radius: 14px;
  padding: 20px;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(17, 24, 39, 0.45); }
dialog h3 { margin: 0 0 14px; font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
