/* Mercury Bot dashboard — тёмная тема, минимализм. */

:root {
  --bg: #0f1115;
  --surface: #161922;
  --surface-2: #1c2030;
  --border: #2a2e36;
  --text: #e6e6e6;
  --muted: #a1a8b3;
  --accent: #8b5cf6;
  --success: #10b981;
  --warn: #f59e0b;
  --error: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
.mono { font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace; font-size: 0.92em; }
.muted { color: var(--muted); }
.muted.small { font-size: 0.85em; margin-top: 4px; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.moon { display: inline-block; transform: translateY(-1px); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); }
.period-switch { display: flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: 8px; }
.period-switch a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}
.period-switch a:hover { color: var(--text); text-decoration: none; }
.period-switch a.active { background: var(--accent); color: white; }

/* Main */
.main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.footer { text-align: center; padding: 24px; color: var(--muted); font-size: 12px; }

/* KPI */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 32px; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-hint { color: var(--muted); font-size: 12px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.card h2 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-3 .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.grid-2 .card { margin-bottom: 0; }

.chart-wrap { position: relative; height: 220px; }
.chart-wide { height: 320px; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .err-msg {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--error);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  font-style: italic;
}
.empty.success { color: var(--success); font-style: normal; }

/* Settings */
.settings-wrap { max-width: 760px; margin: 0 auto; }
.settings-wrap h1 { margin: 0 0 6px; font-size: 22px; }
.settings-wrap > p { margin-bottom: 24px; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.flash.success { background: rgba(16, 185, 129, 0.12); border: 1px solid var(--success); color: var(--success); }
.flash.error { background: rgba(239, 68, 68, 0.12); border: 1px solid var(--error); color: var(--error); }

.settings-form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.setting-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-of-type { border-bottom: none; }
.setting-meta h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }

select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
}
input[type="text"]:focus, input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input::placeholder { color: var(--muted); }

.reset-form { display: flex; gap: 12px; align-items: center; max-width: 460px; }
.reset-form input { flex: 1; width: auto; }

.badge.success { color: var(--success); border-color: var(--success); }
.badge.fail { color: var(--error); border-color: var(--error); }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  align-items: center;
}
button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
button:hover { background: #7c3aed; }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: flex; gap: 6px; align-items: center; margin: 0; }
.row-actions select { width: auto; padding: 5px 8px; font-size: 12px; }
.btn-link { color: var(--muted); }

/* Адаптив для маленьких экранов */
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .setting-row { grid-template-columns: 1fr; gap: 12px; }
}

.table-scroll { overflow-x: auto; }

@media (max-width: 600px) {
  .main { padding: 16px; }
  .data-table { white-space: nowrap; }
  .data-table .err-msg { max-width: none; }
}
