@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --side: #0f1419;
  --side-2: #161d26;
  --side-hover: #1c2633;
  --side-border: #243040;
  --accent: #e8a838;
  --accent-dim: #c48920;
  --blue: #2a7de1;
  --blue-soft: #e8f2fc;
  --teal: #0d9488;
  --teal-soft: #e6f7f5;
  --text: #1a2332;
  --text-2: #3d4a5c;
  --muted: #7a8698;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --bg: #e9eef5;
  --bg-2: #f4f7fb;
  --card: #ffffff;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 20, 25, 0.04), 0 8px 24px rgba(15, 20, 25, 0.06);
  --shadow-lg: 0 16px 48px rgba(15, 20, 25, 0.18);
  --font: "DM Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dbe7f5 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f3e9d4 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.err { color: var(--danger); min-height: 1.2em; font-size: 13px; }
b { color: var(--text); font-weight: 600; }
code { color: var(--blue); }
code, pre { font-family: var(--mono); font-size: 12px; }
pre {
  background: var(--bg-2);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow: auto;
  border: 1px solid var(--line);
  color: var(--text-2);
}
a.link, .link {
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
a.link:hover, .link:hover { text-decoration: underline; }

/* ----- login ----- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(232, 168, 56, 0.18), transparent 50%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(42, 125, 225, 0.16), transparent 45%),
    linear-gradient(160deg, #0a0e14 0%, #121a24 45%, #0d1218 100%);
}
.login-card {
  width: min(400px, 94vw);
  background: rgba(255, 255, 255, 0.97);
  border-radius: 18px;
  padding: 32px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}
.login-card .brand {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.login-card > .muted { margin: 0 0 8px; }
.login-card label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  font-weight: 500;
}
input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: #c5d0de; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(42, 125, 225, 0.15);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s, border-color 0.12s;
}
.btn:hover {
  border-color: #c5d0de;
  box-shadow: 0 2px 8px rgba(15, 20, 25, 0.06);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #3a8aef 0%, var(--blue) 100%);
  border-color: #1f6bc4;
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 4px 14px rgba(42, 125, 225, 0.35); }
.btn.orange {
  background: linear-gradient(180deg, #f0b84a 0%, var(--accent) 100%);
  border-color: var(--accent-dim);
  color: #1a1408;
}
.btn.orange:hover { filter: brightness(1.04); box-shadow: 0 4px 14px rgba(232, 168, 56, 0.35); }
.btn.ghost { background: transparent; }
.btn.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ----- shell ----- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 248px;
  background: linear-gradient(180deg, var(--side-2) 0%, var(--side) 100%);
  color: #a8b4c4;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--side-border);
}
.side-brand {
  padding: 22px 18px 16px;
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.side-brand span {
  color: #8b9aab;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.18em;
  margin: 0;
}
.side-menu-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px 6px;
  font-size: 10px;
  color: #5c6b7d;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
}
.side nav { display: flex; flex-direction: column; padding: 2px 10px 8px; gap: 2px; }
.nav {
  text-align: left;
  background: transparent;
  border: none;
  color: #c2ccd8;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.nav:hover { background: var(--side-hover); color: #fff; }
.nav.active {
  color: #0f1419;
  background: linear-gradient(90deg, var(--accent) 0%, #f0c56a 100%);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(232, 168, 56, 0.25);
}
.nav.active .chev { opacity: 0.7; color: #0f1419; }
.nav .chev { opacity: 0.35; font-size: 11px; }
.side-foot {
  margin-top: auto;
  padding: 14px 18px 18px;
  font-size: 11px;
  color: #5c6b7d;
  border-top: 1px solid var(--side-border);
  font-family: var(--mono);
}
.side-foot.ok { color: #34d399; }

.shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
}
.topbar {
  height: 58px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .burger {
  border: none;
  background: var(--bg-2);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-2);
}
.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}
.top-actions b { color: var(--text); }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.toggle input { width: auto; accent-color: var(--ok); }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn:hover { background: var(--bg-2); }
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--teal-soft);
  color: var(--ok);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #a7f3d0;
}
.live-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.main { flex: 1; padding: 20px 22px 48px; overflow: auto; }

/* ----- home / hints ----- */
.hint-box {
  background: linear-gradient(135deg, #fff 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.hint-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  border-bottom: 1px dashed var(--line-soft);
}
.hint-row:last-child { border-bottom: none; padding-bottom: 2px; }
.hint-row:first-child { padding-top: 2px; }
.hint-row .ico {
  color: var(--accent);
  font-weight: 700;
  margin-top: 2px;
  flex-shrink: 0;
}
.hint-row .title { font-weight: 600; margin-right: 6px; color: var(--text); }

.bal-card {
  background: linear-gradient(135deg, #1a2332 0%, #243447 100%);
  border: none;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.bal-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 168, 56, 0.25), transparent 70%);
}
.bal-card .bal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #a8b4c4;
  position: relative;
  z-index: 1;
}
.bal-card .link { color: var(--accent); }
.bal-value {
  font-size: 38px;
  font-weight: 700;
  color: #fff;
  margin: 10px 0 6px;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
}
.bal-sub { font-size: 13px; color: #9aabbc; position: relative; z-index: 1; }
.bal-sub b { color: var(--accent); font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr; }
  .side { width: 220px; }
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
}
.stat-card .sh {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}
.stat-card .sh .ico { margin-right: 6px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  font-size: 13px;
  border-top: 1px dashed var(--line);
  color: var(--text-2);
}
.stat-row:first-of-type { border-top: none; }
.stat-row .v { color: var(--blue); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-row .v.big { font-size: 22px; letter-spacing: -0.02em; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.panel.form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 5px;
  font-weight: 500;
}
.panel.form label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-2);
}
.panel.form label.check input { width: auto; accent-color: var(--blue); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.gap { flex-wrap: wrap; }

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.num-pos { color: #059669; font-weight: 700; }
.num-neg { color: #dc2626; font-weight: 700; }
.month-day-table tfoot .total-row td {
  border-top: 2px solid var(--line);
  background: var(--bg-2);
  position: sticky;
  bottom: 0;
}
.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.on { background: #d1fae5; color: #047857; }
.badge.off { background: #f1f5f9; color: #64748b; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card .k { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.card .v {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.ctrl-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.ctrl-list b { color: var(--text); }

.chip-edit-row { display: flex; gap: 10px; margin: 8px 0 12px; }
.chip-preview {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.chip-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }

.modal {
  position: fixed; inset: 0; background: rgba(15, 20, 25, 0.45);
  display: grid; place-items: center; z-index: 50; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 22px;
  width: min(520px, 96vw); max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.modal-card h3 { margin: 0 0 10px; }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }

.docs ol { line-height: 1.7; font-size: 14px; color: var(--text-2); }
.key-box {
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  margin: 6px 0 12px;
}
.copy-row { display: flex; gap: 8px; align-items: center; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar h3 { font-size: 16px; letter-spacing: -0.02em; }
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-row input, .filter-row select { width: auto; min-width: 160px; }

.num-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}
@media (max-width: 1100px) { .num-cards { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .num-cards { grid-template-columns: 1fr; } }
.num-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.num-card::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: #94a3b8;
}
.num-card.pool::before { background: linear-gradient(90deg, #2a7de1, #60a5fa); }
.num-card.tax::before { background: linear-gradient(90deg, #059669, #34d399); }
.num-card.chips::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.num-card.jp::before { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.num-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.num-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 12px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.num-card.pool .num-value { color: var(--blue); }
.num-card.tax .num-value { color: var(--ok); }
.num-card.jp .num-value { color: var(--teal); }
.num-card.chips pre { color: var(--text); font-size: 13px; background: transparent; border: none; padding: 0; }

/* ----- control center ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--blue);
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(15, 20, 25, 0.08); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.ok { border-left-color: var(--ok); }
.kpi.danger { border-left-color: var(--danger); }
.kpi .k {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.kpi .v {
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}
.panel-head h3 { margin: 0; }
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 1000px) { .grid-3 { grid-template-columns: 1fr; } }
.ctrl-map {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.ctrl-map b { color: var(--text); }
@media (max-width: 800px) { .ctrl-map { grid-template-columns: 1fr; } }
.phase {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.phase.bet { background: var(--blue-soft); color: #1d4ed8; }
.phase.run { background: #fff7ed; color: #c2410c; }
.phase.final { background: var(--teal-soft); color: #0f766e; }
.phase.stop { background: #f1f5f9; color: #64748b; }
.mode-feed { color: var(--ok); font-weight: 600; }
.mode-loss { color: var(--danger); font-weight: 600; }
.mode-none { color: var(--muted); }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .side {
    width: 100%;
    max-height: none;
  }
  .side.hidden { display: none !important; }
  .main { padding: 14px 12px 40px; }
  .topbar { padding: 0 12px; }
}
