:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --line: #d7dee5;
  --text: #111827;
  --muted: #667085;
  --green: #087443;
  --red: #c0332b;
  --blue: #1f5eff;
  --amber: #a15c08;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-brand {
  color: var(--text);
  margin-bottom: 22px;
}

.login-brand small {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #101820;
  color: #f8fafc;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #20c997;
  color: #052e22;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand small,
.sidebar-status {
  color: #aebaca;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
}

.nav-item.active,
.nav-item:hover {
  background: #22303d;
  color: #ffffff;
}

.sidebar-status {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  line-height: 1.5;
}

main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
  margin-top: 18px;
}

.topbar p,
.panel-head span,
.metric span,
.metric small,
td,
label span {
  color: var(--muted);
}

.topbar-actions,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 650;
}

.primary {
  background: var(--blue);
  color: white;
}

.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert.warning {
  background: #fff8eb;
  border-color: #ffd69b;
  color: #5f3800;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

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

.metric {
  min-height: 120px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric strong {
  font-size: 26px;
  letter-spacing: 0;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 16px;
}

.panel + .panel {
  margin-top: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.market-list,
.asset-list,
.hotlist {
  display: grid;
  gap: 10px;
}

.market-row,
.asset-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) repeat(5, minmax(80px, 1fr));
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.asset-row {
  grid-template-columns: 1fr 1fr 1fr;
}

.hotlist-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) repeat(4, minmax(100px, 0.6fr));
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.market-row:first-child,
.asset-row:first-child,
.hotlist-row:first-child {
  border-top: 0;
}

.row-label {
  font-weight: 700;
}

.kv small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kv strong {
  font-size: 14px;
}

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

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

th,
td {
  text-align: left;
  padding: 11px 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  vertical-align: top;
}

th {
  color: #475467;
  font-weight: 750;
  background: var(--surface-2);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fafc;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.badge.EXECUTED {
  background: #dcfce7;
  color: #166534;
}

.badge.DRY_RUN {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge.HOLD {
  background: #f1f5f9;
  color: #334155;
}

.badge.BLOCKED,
.badge.ERROR {
  background: #fee2e2;
  color: #991b1b;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

label.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  padding: 16px 0;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.toggle-row input {
  width: 16px;
}

.text-panel {
  max-width: 980px;
  line-height: 1.75;
}

.text-panel p,
.text-panel li {
  color: #344054;
}

dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-body {
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 120px);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #f1f5f9;
  font-size: 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.detail-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.detail-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101820;
  color: white;
  box-shadow: var(--shadow);
}

.hidden {
  display: none;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar-status {
    margin-top: 0;
    margin-left: auto;
    min-width: 190px;
  }

  nav {
    display: flex;
  }

  .metrics-grid,
  .split-layout,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  main {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .metrics-grid,
  .split-layout,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .topbar-actions button {
    flex: 1 1 150px;
  }

  .market-row {
    grid-template-columns: 1fr 1fr;
  }

  .hotlist-row {
    grid-template-columns: 1fr 1fr;
  }

  .sidebar {
    padding: 14px;
  }

  .brand small,
  .sidebar-status {
    display: none;
  }
}
