/* Tradingtool – dunkles, kompaktes Design im Stil einer Handelsoberfläche */
:root {
  --bg: #0b0e14;
  --bg-2: #0f131b;
  --card: #121722;
  --card-2: #182031;
  --line: #1f2839;
  --line-2: #2a3548;
  --text: #dfe5ef;
  --muted: #7d8aa3;
  --accent: #f7931a;         /* Bitcoin-Orange */
  --accent-2: #ffb454;
  --blue: #5b8cff;
  --pos: #16c784;
  --neg: #ea3943;
  --warn: #f5a524;
  --radius: 6px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
h1 { font-size: 1.05rem; margin: 0; font-weight: 600; letter-spacing: 0; }
h2 {
  font-size: .7rem; margin: 0 0 8px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
}
code, .mono { font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num, td.r, th.r { font-variant-numeric: tabular-nums; }

/* Layout */
.shell { display: grid; grid-template-columns: 176px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  padding: 12px 10px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 650; font-size: .95rem; display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.brand.big { font-size: 1.15rem; justify-content: center; }
.brand-mark {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px;
  background: var(--accent); color: #111; font-weight: 800; font-size: .8rem;
}
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a { color: var(--muted); padding: 6px 8px; border-radius: 4px; }
.sidebar nav a:hover { background: var(--card); color: var(--text); }
.sidebar nav a.on { background: var(--card-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.logout { margin-top: auto; }
.content { padding: 14px 18px 24px; width: 100%; min-width: 0; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.topbar p { margin: 2px 0 0; font-size: .78rem; }
.topbar-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 .card { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.grid-3 .card { margin-bottom: 0; }
.chart-box { position: relative; height: 240px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
}
.kpi-label { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; }
.kpi-value { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Badges & alerts */
.badge {
  padding: 2px 7px; border-radius: 4px; font-size: .68rem; font-weight: 600;
  letter-spacing: .05em; border: 1px solid transparent; text-transform: uppercase;
}
.badge.demo { background: rgba(245, 165, 36, .1); color: var(--warn); border-color: rgba(245, 165, 36, .3); }
.badge.live { background: rgba(234, 57, 67, .12); color: #ff7b83; border-color: rgba(234, 57, 67, .4); }
.badge.ok { background: rgba(22, 199, 132, .1); color: #4fdca6; border-color: rgba(22, 199, 132, .3); }
.badge.off { background: transparent; color: var(--muted); border-color: var(--line-2); }
.alert { padding: 6px 10px; border-radius: 4px; margin-bottom: 10px; border: 1px solid; font-size: .85rem; }
.alert.inline { margin: 0; padding: 4px 8px; }
.alert.ok { background: rgba(22, 199, 132, .08); border-color: rgba(22, 199, 132, .3); color: #8ce8c3; }
.alert.warn { background: rgba(245, 165, 36, .08); border-color: rgba(245, 165, 36, .3); color: #f8cf85; }
.alert.danger { background: rgba(234, 57, 67, .08); border-color: rgba(234, 57, 67, .35); color: #ffa3a8; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--card-2); color: var(--text);
  padding: 5px 12px; border-radius: 4px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 3px 8px; font-size: .78rem; }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--neg); color: #fff; border-color: var(--neg); letter-spacing: .04em; }
.btn.ghost { background: transparent; }

/* Forms */
label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: .75rem; }
input, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 4px;
  padding: 5px 8px; font: inherit; font-size: .85rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.hint { font-size: .72rem; color: var(--muted); }
.settings > .btn { margin-bottom: 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.danger-zone { border-color: rgba(234, 57, 67, .35); }

/* Tables */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { padding: 5px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  color: var(--muted); font-weight: 600; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--bg-2); position: sticky; top: 0;
}
tbody tr:hover { background: rgba(255, 255, 255, .02); }
td.r, th.r { text-align: right; }
.side { padding: 1px 6px; border-radius: 3px; font-size: .72rem; font-weight: 600; }
.side.buy { background: rgba(22, 199, 132, .12); color: #4fdca6; }
.side.sell { background: rgba(234, 57, 67, .12); color: #ff7b83; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(320px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 18px; }
.login-card label { text-align: left; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form.sep { border-top: 1px solid var(--line); padding-top: 10px; }
.passkey-add { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 6px; }

/* Live-Kurs oben auf jeder Seite */
.tickerbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: -14px -18px 12px; padding: 6px 18px; color: var(--text); min-height: 32px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.tickerbar:hover { background: var(--card); }
.tb-sym { font-weight: 650; color: var(--accent); font-size: .8rem; }
.tb-last { font-weight: 650; transition: color .6s; }
.tb-last.up { color: var(--pos); } .tb-last.down { color: var(--neg); }
.tb-chg { font-weight: 600; font-size: .8rem; }
.tb-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.tb-dot.on { background: var(--pos); }
.tb-dot.err { background: var(--neg); }

/* Live-Ansicht: passt ohne Scrollen in den Bildschirm */
.live-grid {
  display: grid; gap: 10px;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(260px, 1fr) minmax(150px, 30%);
  grid-template-areas: "chart side" "bottom bottom";
  height: calc(100vh - 32px - 14px - 12px - 44px - 14px);
  min-height: 560px;
}
.live-grid > .card { margin: 0; min-height: 0; }
.live-chart { grid-area: chart; display: flex; flex-direction: column; }
.live-side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }
h2.sub { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.live-side .card { margin: 0; }
.live-bottom { grid-area: bottom; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 0; }
.live-bottom > .card { margin: 0; min-height: 0; }
.live-bottom .feed { display: flex; flex-direction: column; overflow: hidden; }
.feed-body { overflow: auto; flex: 1; min-height: 0; }
.feed-title { padding: 8px 10px 6px; margin: 0; }
.price-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.price-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.price-big { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.price-sub { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.price-sub b { color: var(--text); font-weight: 600; }
.ranges { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; }
.ranges button {
  background: transparent; border: 0; border-right: 1px solid var(--line-2); color: var(--muted);
  font: inherit; font-size: .75rem; font-weight: 600; padding: 3px 9px; cursor: pointer;
}
.ranges button:last-child { border-right: 0; }
.ranges button:hover { color: var(--text); background: var(--card-2); }
.ranges button.on { background: var(--card-2); color: var(--accent); }
.range-chg { justify-content: flex-end; margin-top: 4px; }
.live-chart .chart-box { flex: 1; height: auto; min-height: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: .8rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.test-order { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: end; }
.test-order .btn { grid-column: 1 / -1; }
.test-order + p { margin: 6px 0 0; }
#lv-error:empty { display: none; }
#lv-error { margin: 4px 0 0; }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
  .live-grid {
    height: auto; grid-template-columns: 1fr; grid-template-rows: none;
    grid-template-areas: "chart" "side" "bottom";
  }
  .live-bottom { grid-template-columns: 1fr; }
  .live-chart .chart-box { height: 300px; flex: none; }
  .live-bottom .feed { max-height: 320px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin: 0 0 0 auto; }
  .content { padding: 12px 12px 24px; }
  .tickerbar { margin: -12px -12px 10px; padding: 6px 12px; }
  .grid-2 { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }
