/* Business console. Source Serif 4 + Source Sans 3. White field. */
:root {
  --ink: #1b1f24;
  --muted: #5c6570;
  --line: #e6e9ee;
  --paper: #f4f6f8;
  --white: #ffffff;
  --brand: #0c6b4d;
  --brand-soft: #e7f4ee;
  --danger: #b42318;
  --warn: #b54708;
  --warn-soft: #fff4e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body {
  font-family: "Source Sans 3", "Noto Sans SC", sans-serif;
  display: grid;
  grid-template-columns: 228px 1fr;
}

a { color: inherit; }
.mono, code { font-family: "IBM Plex Mono", "Noto Sans SC", monospace; }
svg.ic { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; flex: none; }

.rail {
  background: var(--white);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  padding: 28px 18px;
  position: sticky;
  top: 0;
}
.brand {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 4px;
}
.brand small {
  display: block;
  font-family: "Source Sans 3", "Noto Sans SC", sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
}
.rail nav { display: flex; flex-direction: column; gap: 2px; margin-top: 28px; }
.rail a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.rail a.active, .rail a:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.rail .foot {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rail .who a {
  display: inline;
  padding: 0;
  color: var(--brand);
  font-size: 11px;
}
.rail .who a:hover { background: none; }

.main { padding: 24px 28px 64px; min-width: 0; background: var(--paper); }
.kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.ticket {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin: 0 0 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.ticket h1 {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-size: 28px;
  font-weight: 600;
  margin: 4px 0 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.ticket h1::after { display: none; }
.ticket-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.meta { text-align: right; font-size: 13px; color: var(--muted); line-height: 1.5; }

.flash {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #cfe6da;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  border-radius: 6px;
}
.err { color: var(--danger); margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

.stats {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) repeat(5, minmax(110px, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}
.stats.group-pnl {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 0 16px;
}
.up { color: var(--brand); }
.down { color: var(--danger); }
.rate-pair em { color: var(--muted); font-style: normal; padding: 0 4px; }
.stat {
  background: var(--white);
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stat.hero { border-color: #cfe6da; background: var(--white); }
.stat.hero b { color: var(--brand); }
.stat b {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
}
.stat span { color: var(--muted); font-size: 12px; }
.stat a { text-decoration: none; }

.toolbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 14px; }
.toolbar.tight { margin-bottom: 8px; align-items: end; }
.toolbar h2 {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-weight: 600;
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.editor {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px 16px;
  margin: 0 0 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
}
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.form-grid input, .form-grid select { width: 100%; min-width: 0; }
.actions.end { justify-content: flex-end; align-items: end; }

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding: 4px 2px 2px;
}
.chip {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 8px 10px 8px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-weight: 500;
  color: var(--ink);
}
.chip input {
  position: absolute;
  left: 8px;
  top: 11px;
  width: 14px;
  height: 14px;
  min-width: 14px;
}
.chip b { font-size: 13px; font-weight: 600; line-height: 1.2; }
.chip i {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
  font-family: "IBM Plex Mono", monospace;
}
.chip:has(input:checked) {
  border-color: #9cc9b6;
  background: var(--brand-soft);
}
.chip.dim { opacity: 0.48; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
form.inline, .stack { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.stack { flex-direction: column; align-items: stretch; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.check {
  flex-direction: row;
  align-items: center;
  font-weight: 400;
  font-size: 13px;
  color: var(--ink);
  gap: 8px;
}
.check input { min-width: auto; width: 15px; height: 15px; }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  background: var(--white);
  border: 1px solid #d5dae1;
  color: var(--ink);
  padding: 8px 10px;
  min-width: 132px;
  border-radius: 6px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(12, 107, 77, 0.12);
}
textarea { min-width: 240px; min-height: 68px; }
button, .btn {
  font: inherit;
  border: 0;
  background: var(--brand);
  color: var(--white);
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  font-weight: 600;
}
button.ghost, .btn.ghost {
  background: var(--white);
  color: var(--ink);
  border: 1px solid #d5dae1;
}
button.danger { background: var(--danger); color: var(--white); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
td.actions input { min-width: 96px; width: 110px; }

.sheet {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}
table { width: 100%; border-collapse: collapse; background: var(--white); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fafbfc;
  font-weight: 600;
}
td.num, th.num { text-align: right; font-family: "IBM Plex Mono", monospace; }
td.today-in { line-height: 1.45; white-space: nowrap; }
td.today-in .sub { margin-top: 8px; color: var(--muted); font-size: 12px; }
tr:hover td { background: #f8fafb; }
tr.dim td { color: var(--muted); }
tr.next td { background: var(--brand-soft); }
tr.selected td { box-shadow: inset 3px 0 0 var(--brand); }

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: #eef0f3;
  color: var(--muted);
}
.pill.ok { background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: #fde8e6; color: var(--danger); }
.pill.wait { background: var(--warn-soft); color: var(--warn); }
.pill.mute { background: #eef0f3; color: var(--muted); }

.split {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 18px;
  align-items: start;
}
.drawer, .panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 18px 22px;
}
.drawer .kicker, .drawer label { color: var(--muted); }
.drawer input, .drawer select, .drawer textarea { width: 100%; min-width: 0; }
.drawer .hint { color: var(--muted); }
.drawer h2 {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-weight: 600;
  margin: 4px 0 16px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.barwrap { display: flex; flex-direction: column; gap: 12px; }
.bar {
  display: grid;
  grid-template-columns: minmax(120px, 1.5fr) 1fr 88px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.bar i {
  display: block;
  height: 6px;
  background: #eef0f3;
  border-radius: 99px;
  overflow: hidden;
}
.bar i em {
  display: block;
  height: 100%;
  background: var(--brand);
}
.empty {
  padding: 32px 20px;
  text-align: left;
  background: var(--white);
}
.empty h3 {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  margin: 0 0 8px;
  font-weight: 600;
}

html:has(body.login) { height: 100%; }
body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100vh;
  margin: 0;
  background: #f3f4f6;
}
.login-col {
  width: min(400px, calc(100% - 40px));
}
.login-col header {
  text-align: left;
  margin: 0 0 20px;
}
.login-col .mark {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  margin: 0 0 8px;
  color: var(--brand);
}
.login-col h1 {
  font-family: "Source Serif 4", "Noto Sans SC", serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 6px;
}
.login-col .lede {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.login-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px 24px 28px;
}
.login-card .err {
  background: #fdecea;
  border: 1px solid #f4c7c3;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 6px;
  margin: 0 0 16px;
  font-size: 13px;
}
.login-card form { display: flex; flex-direction: column; }
.login-card label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--ink);
}
.login-card label + input,
.login-card .field { margin-bottom: 14px; }
.login-card #totp-wrap { margin-bottom: 14px; }
.login-card #totp-wrap label { margin-bottom: 6px; }
.login-card input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  font-size: 15px;
}
.login-card .field { position: relative; display: block; }
.login-card .field input { padding-right: 52px; margin-bottom: 0; }
.login-card .peek {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  color: var(--muted);
  border: 0;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
}
.login-card .peek:hover { color: var(--brand); background: none; }
.login-card .go {
  width: 100%;
  height: 42px;
  justify-content: center;
  margin-top: 4px;
  font-size: 15px;
}
#totp-wrap[hidden] { display: none !important; }
.qr-box {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.qr-box img {
  width: 180px;
  height: 180px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.secret {
  font-size: 12px;
  word-break: break-all;
  color: var(--ink);
  margin: 0 0 12px;
}

@media (max-width: 1080px) {
  .stats, .stats.group-pnl { grid-template-columns: 1fr 1fr; }
  .split, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2, .form-grid .span3 { grid-column: auto; }
  .ticket { flex-direction: column; align-items: start; }
  .ticket-side { align-items: flex-start; }
  .meta { text-align: left; }
}
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .rail { min-height: auto; position: relative; }
}
