@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg: #0c0f12;
  --bg-elev: #12171d;
  --fg: #e7ebf0;
  --muted: #8b949e;
  --card: #151b22;
  --line: #2a3340;
  --line-soft: #1e2630;
  --accent: #3dd6c6;
  --accent-dim: rgba(61, 214, 198, 0.14);
  --warn-bg: #2a2112;
  --warn-fg: #f0c674;
  --danger: #f07178;
  --ok: #7fd99a;
  --num: #d7dee8;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 214, 198, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(112, 146, 190, 0.07), transparent 50%),
    var(--bg);
  color: var(--fg);
  line-height: 1.45;
  min-height: 100vh;
}

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

.top {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(12, 15, 18, 0.88);
  backdrop-filter: blur(10px);
}
.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.brand:hover { text-decoration: none; color: var(--accent); }
nav {
  display: flex;
  gap: 0.15rem;
  flex: 1;
  flex-wrap: wrap;
}
nav a {
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.92rem;
}
nav a:hover {
  color: var(--fg);
  background: var(--bg-elev);
  text-decoration: none;
}
nav a.active {
  color: var(--fg);
  background: var(--accent-dim);
}

.logout button, button, .btn {
  background: var(--accent);
  color: #041210;
  border: 0;
  border-radius: 8px;
  padding: 0.42rem 0.85rem;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
}
button.danger, .btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(240, 113, 120, 0.45);
}
button:hover { filter: brightness(1.05); }

main {
  padding: 1.35rem 1.25rem 2.5rem;
  max-width: 1180px;
  margin: 0 auto;
}

h1 {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--fg);
  letter-spacing: 0.01em;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.15rem;
}
.page-head .lede { color: var(--muted); margin: 0; font-size: 0.92rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}
.card.warn {
  background: var(--warn-bg);
  border-color: rgba(240, 198, 116, 0.35);
}
.card.warn h2 { color: var(--warn-fg); }

.grid.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.grid.two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.grid.three {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}
.stat .label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.stat strong {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat .sub {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--muted); }
.flash {
  background: var(--accent-dim);
  border: 1px solid rgba(61, 214, 198, 0.35);
  color: var(--fg);
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  border: 1px solid var(--line);
  background: var(--bg-elev);
}
.chip.s0 { color: var(--ok); border-color: rgba(127, 217, 154, 0.35); }
.chip.s1 { color: var(--warn-fg); border-color: rgba(240, 198, 116, 0.4); }
.chip.s2, .chip.s3 { color: var(--danger); border-color: rgba(240, 113, 120, 0.4); }
.chip.ok { color: var(--ok); }
.chip.bad { color: var(--danger); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
th, td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.9rem;
  vertical-align: middle;
}
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
}
td.num, th.num {
  text-align: right;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--num);
  white-space: nowrap;
}
td.ticker {
  font-weight: 600;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.02em;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(61, 214, 198, 0.04); }
.stat strong.pos { color: var(--ok); }
.stat strong.neg { color: var(--danger); }
.pnl-board h2 { margin-bottom: 0.35rem; }

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  margin: 0;
  line-height: 1.5;
}
pre.prompt {
  max-height: 280px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 0.75rem;
}

dl.kv {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.4rem 0.85rem;
  margin: 0;
}
dl.kv dt { color: var(--muted); font-size: 0.85rem; }
dl.kv dd {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.stack { display: grid; gap: 0.55rem; }
.stack label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.stack input, .stack select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.9rem;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.list-plain {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-plain li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.list-plain li:last-child { border-bottom: 0; }

.day-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 1rem;
}
.day-pills a {
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
}
.day-pills a.active, .day-pills a:hover {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--accent-dim);
  text-decoration: none;
}

.softlist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.softlist span {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
}

body.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
body.login .card {
  max-width: 440px;
  margin: 1rem;
}

.en {
  font-size: 0.72em;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.01em;
  margin-left: 0.2em;
}
nav a .en { font-size: 0.68em; }
h1 .en, h2 .en { font-weight: 400; }

@media (max-width: 720px) {
  main { padding: 1rem 0.85rem 2rem; }
  dl.kv { grid-template-columns: 1fr; gap: 0.15rem; }
  dl.kv dd { margin-bottom: 0.45rem; }
}
