/* Trading bot dashboard. Phone first; dark and light follow the device. Blue = good/active, orange = attention,
   grey = quiet; every colour also has a word or a shape (R-011: colour-blind safe, never red/green alone). */
:root {
  --bg: #0d1117; --panel: #161b22; --panel-2: #1c232d; --line: #2a3340; --text: #e6edf3; --muted: #8b98a8;
  --blue: #4c9aff; --blue-soft: rgba(76, 154, 255, .14); --orange: #ff9f43; --orange-soft: rgba(255, 159, 67, .15);
  --grey: #5b6675; --radius: 14px; --shadow: 0 1px 0 rgba(255,255,255,.03), 0 8px 24px rgba(0,0,0,.25);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa; --panel: #ffffff; --panel-2: #f0f3f7; --line: #dde3ea; --text: #17202b; --muted: #5b6878;
    --blue: #1f6fd1; --blue-soft: rgba(31, 111, 209, .10); --orange: #c25e00; --orange-soft: rgba(194, 94, 0, .10);
    --grey: #9aa5b3; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 16px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
       border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
               border-radius: 10px; padding: 7px 12px; cursor: pointer; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; width: 100%; padding: 11px; font-weight: 600; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0; font-size: 17px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.tag.warn { color: var(--orange); border-color: var(--orange); background: var(--orange-soft); font-weight: 600; }
.sentence { font-size: 20px; line-height: 1.35; font-weight: 600; margin: 4px 0 6px; }
.next { color: var(--muted); margin: 0 0 14px; }

/* Numbers */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--panel-2); border-radius: 12px; padding: 12px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; }

/* Health strip */
.health { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
@media (min-width: 760px) { .health { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.health .h { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 12px; padding: 10px 12px; }
.health .h .t { font-size: 12px; color: var(--muted); }
.health .h .b { font-weight: 600; font-variant-numeric: tabular-nums; }
.pip { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--grey); }
.pip.ok { background: var(--blue); } .pip.warn { background: var(--orange); }

/* One square per daily run (status page style) */
.runs { display: flex; flex-wrap: wrap; gap: 3px; margin: 8px 0 4px; }
.sq { width: 12px; height: 12px; border-radius: 3px; background: var(--grey); opacity: .55; }
.sq.done { background: var(--blue); opacity: 1; }
.sq.no-trade { background: var(--grey); opacity: .9; }
.sq.blocked, .sq.partial, .sq.kill { background: var(--orange); opacity: 1; }
.legend { color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--grey); }
.legend .l-done::before { background: var(--blue); } .legend .l-warn::before { background: var(--orange); }

/* Tables */
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; }
.vote-on { color: var(--blue); font-weight: 600; } .vote-off { color: var(--muted); }
.scroll { overflow-x: auto; }
.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.events .lvl-warn, .events .lvl-error { color: var(--orange); font-weight: 600; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password] { width: 100%; font: inherit; color: var(--text); background: var(--panel-2);
       border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.err { color: var(--orange); background: var(--orange-soft); border-radius: 10px; padding: 9px 12px; margin-top: 12px; font-size: 14px; }
.foot { color: var(--muted); font-size: 12px; text-align: center; margin: 24px 0; }
.actions { margin-top: 18px; }
.sub { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Links that look like text; breadcrumb */
a.brand, a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: underline; }
.crumb { margin: 4px 0 12px; font-size: 14px; }
.crumb a { text-decoration: none; }
.small { font-size: 13px; }
.btn { display: inline-block; text-decoration: none; font-size: 14px; }
a.sq { display: inline-block; }
a.sq:hover { outline: 2px solid var(--blue); outline-offset: 1px; }

/* Detail page: two columns on desktop */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-2 .card h2, section.card > h2 { margin-bottom: 4px; }
tr.total td { font-weight: 700; border-bottom: 0; }

/* Safety limits */
.limits { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.lim { background: var(--panel-2); border-radius: 12px; padding: 10px 12px; border-left: 3px solid var(--blue); }
.lim-warn, .lim-hit { border-left-color: var(--orange); }
.lim-head { display: flex; align-items: center; gap: 8px; }
.lim-tag { margin-left: auto; font-size: 11px; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.lim-warn .lim-tag, .lim-hit .lim-tag { color: var(--orange); }
.lim-rule { color: var(--muted); font-size: 13px; margin-top: 2px; }
.lim-now { font-size: 14px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Decision log */
.log { display: grid; gap: 8px; margin-top: 10px; }
details.day { background: var(--panel-2); border-radius: 12px; border: 1px solid transparent; }
details.day[open] { border-color: var(--line); }
details.day:target { border-color: var(--blue); }
details.day summary { list-style: none; cursor: pointer; display: flex; align-items: flex-start; gap: 10px; padding: 11px 32px 11px 12px; position: relative; }
details.day summary::-webkit-details-marker { display: none; }
details.day summary::after { content: "▸"; position: absolute; right: 12px; top: 11px; color: var(--muted); transition: transform .15s; }
details.day[open] summary::after { transform: rotate(90deg); }
details.day summary .sq { margin-top: 4px; flex: none; }
.day-date { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; min-width: 88px; }
.day-text { font-size: 14px; }
.day-body { padding: 0 12px 12px; }
.reason { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.reason p { margin: 8px 0; font-size: 14px; }
.reason-head { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); color: var(--muted); }
.chip.on { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); font-weight: 600; }
.chip.changed { border-style: dashed; border-color: var(--orange); }
.did { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.did li { margin: 2px 0; }
.meta { margin-top: 4px; }
@media (max-width: 520px) { details.day summary { flex-wrap: wrap; } .day-text { flex-basis: 100%; } }
