:root {
  --bg: #eef1ef;
  --surface: #fbfcfa;
  --surface-2: #f5f7f4;
  --ink: #17201c;
  --muted: #66736c;
  --line: #d8ded8;
  --green: #0f8a5f;
  --red: #b93c35;
  --amber: #a36a14;
  --teal: #176d78;
  --shadow: 0 10px 24px rgba(26, 36, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #123f32;
  background: #174c3d;
  color: white;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: #0f3f31;
}

button.ghost {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

button.danger {
  border-color: #82302c;
  background: #a43731;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(23, 109, 120, 0.14);
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  font-weight: 720;
}

#statusLine {
  color: var(--muted);
  margin-top: 3px;
}

.toolbar {
  display: grid;
  grid-template-columns: 170px 92px;
  align-items: end;
  gap: 10px;
}

.login {
  display: none;
  gap: 10px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7e8;
}

.login.visible {
  display: grid;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(180px, 260px) 96px;
  gap: 10px;
  align-items: end;
}

.hidden {
  display: none;
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 20px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.main-column,
.side-panel,
.stack {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px;
}

.account-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  padding: 12px;
}

.account-card .name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 720;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e3eee8;
  color: #1d6c4e;
  font-size: 12px;
}

.tag.warn {
  background: #f7e8c9;
  color: var(--amber);
}

.tag.bad {
  background: #f5d8d6;
  color: var(--red);
}

.balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.balances span {
  color: var(--muted);
  font-size: 12px;
}

.balances strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  background: #f8faf7;
}

td {
  font-variant-numeric: tabular-nums;
}

tr:last-child td {
  border-bottom: 0;
}

.num-pos {
  color: var(--green);
}

.num-neg {
  color: var(--red);
}

.side-long {
  color: var(--green);
  font-weight: 750;
}

.side-short {
  color: var(--red);
  font-weight: 750;
}

.side-panel .panel {
  padding-bottom: 14px;
}

.side-panel .stack {
  padding: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkline {
  display: flex;
  align-items: end;
  gap: 8px;
  padding-bottom: 7px;
}

.checkline input {
  width: 18px;
  min-height: 18px;
}

.checkline span {
  margin: 0;
  color: var(--ink);
}

.log {
  height: 220px;
  overflow: auto;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.log div {
  padding: 5px 0;
  border-bottom: 1px solid #edf0ec;
}

.empty {
  padding: 18px 14px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1600px);
    padding-top: 14px;
  }

  .topbar,
  .toolbar,
  .login,
  .login-form,
  .market-strip,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: stretch;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }
}
