/* One dark stylesheet for every page (NF-8). Layout follows the screenshots. */

:root {
  color-scheme: dark;
  --bg: #0e1116;
  --sidebar: #171a21;
  --topbar: #12151b;
  --panel: #141820;
  --panel-2: #1c212b;
  --line: #2a3140;
  --text: #e7ebf2;
  --muted: #9aa3b2;
  --accent: #3d7eff;
  --accent-ink: #08111f;
  --green: #2fce73;
  --red: #ff5d5d;
  --amber: #e6b450;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 12px 18px;
}

.menu { list-style: none; margin: 0; padding: 0; }
.menu a {
  display: block;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
}
.menu a:hover { background: var(--panel-2); text-decoration: none; }
.menu a[aria-current="page"] { background: #243049; color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.notifications { display: flex; align-items: center; gap: 8px; color: var(--muted); }
#notification-count {
  min-width: 1.6em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  text-align: center;
  font-weight: 650;
}

.user-menu { position: relative; }
.user-menu summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel-2);
}
.user-menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 2;
}
.menu-panel a, .menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--panel-2); text-decoration: none; }

.content { padding: 22px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 12px 22px;
  background: #3a2e12;
  color: var(--amber);
  border-bottom: 1px solid #6b5420;
}
.banner p { margin: 0; }

.notice, .error {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 16px;
}
.notice { background: #143224; color: var(--green); }
.error, .field-error { color: var(--red); }
.field-error { margin: 4px 0 0; font-size: 13px; }

form.stack, .stack { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.field-name { display: flex; align-items: center; gap: 6px; }
label.with-hint { position: relative; }
.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 11px;
  cursor: help;
}
.hint-text {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 5;
  width: 18rem;
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
}
label.with-hint:hover .hint-text,
label.with-hint:focus-within .hint-text {
  opacity: 1;
  visibility: visible;
}
input, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
input[readonly] { color: var(--muted); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  line-height: normal;
  color: white;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
a.button:hover { text-decoration: none; }
button.quiet, .button.quiet { background: var(--panel-2); color: var(--text); }
button.danger { background: #8d2d2d; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.switch {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  padding: 0;
  background: #3a4150;
  position: relative;
}
.switch.on { background: var(--green); }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
}
.switch.on::after { left: 23px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0.03em; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.status-bad { color: var(--red); }
.status-ok { color: var(--green); }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; }
.confirm { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { margin: 0 0 8px; font-size: 22px; }
.qr { background: white; padding: 8px; width: fit-content; border-radius: 8px; }
.qr svg { display: block; width: 180px; height: 180px; }

.section-title { margin: 28px 0 12px; font-size: 16px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar h2 { margin: 0; }

.bots { display: flex; gap: 16px; align-items: flex-start; }
.bot-list { width: 280px; flex: none; }
.bot-detail { flex: 1; min-width: 0; }
.bot-list ul, .bot-accounts { list-style: none; margin: 12px 0 0; padding: 0; }
.bot-list li + li { margin-top: 4px; }
.bot-list a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  color: var(--text);
}
.bot-list a:hover { background: var(--panel-2); text-decoration: none; }
.bot-list a[aria-current="page"] { background: #243049; }
.bot-name { font-weight: 650; }
.pnl-up { color: var(--green); }
.pnl-down { color: var(--red); }
.pnl-flat { color: var(--muted); }
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  list-style: none;
  margin: 12px 0;
  padding: 0;
}
.button-row > li { display: flex; align-items: flex-start; }
.button-row form { display: flex; margin: 0; }
.delete-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}
#history-delete .delete-row { margin: 12px 0 0; }
.delete-row label { flex-direction: row; align-items: center; gap: 6px; }
.stop-bot { display: flex; flex-direction: column; align-items: flex-start; }
.stop-bot summary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  line-height: normal;
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
}
.stop-bot summary::-webkit-details-marker { display: none; }
.stop-bot[open] {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
.tabs { display: flex; gap: 8px; margin: 8px 0 16px; }
.tabs a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
}
.tabs a[aria-current="page"] { background: var(--accent); color: white; }
.tabs a:hover { text-decoration: none; }
.bot-form { max-width: 560px; }
.bot-form h3 { margin: 8px 0 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.8fr);
  gap: 16px;
  align-items: start;
}
.setting-groups h4 { margin: 16px 0 8px; }
.setting-groups section:first-child h4 { margin-top: 0; }
.settings, .stats { margin: 0; }
.settings div, .stats div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.settings dt, .stats dt { color: var(--muted); }
.settings dd, .stats dd { margin: 0; text-align: right; }
.stats {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 4px 12px;
}

.summary-controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: start;
}
.chart-box { min-height: 240px; }
#summary-empty { color: var(--muted); margin: 48px 0; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0; }
.filters label { min-width: 160px; }
.table-wrap { overflow-x: auto; }
.warning { color: var(--amber); font-weight: 650; margin: 4px 0 0; }
.row-warn td { background: rgba(230, 180, 80, 0.08); }
.close-all { margin: 0 0 16px; }
.confirm-note { margin: 0 0 8px; max-width: 40rem; }
.row-actions { display: flex; flex-direction: column; gap: 8px; min-width: 16rem; }
.row-actions form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.row-actions input[name="margin"],
.row-actions input[name="percent"],
.row-actions input[name="stop_loss"],
.row-actions input[name="take_profit"],
.row-actions input[name="breakeven"],
.row-actions input[name="trailing_trigger"],
.row-actions input[name="trailing"] { width: 5.5rem; }
.result-price { color: var(--muted); }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
legend { padding: 0 6px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input:disabled, select:disabled { opacity: 0.7; }
