:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #d9e2ef;
  --line-strong: #c6d3e2;
  --text: #142033;
  --muted: #637083;
  --blue: #2367d1;
  --blue-dark: #1d54aa;
  --green: #11875d;
  --red: #ce3b43;
  --gold: #a76a16;
  --soft-blue: #e9f1ff;
  --soft-green: #e8f7ef;
  --soft-red: #fdeced;
  --shadow: 0 10px 26px rgba(20, 32, 51, 0.07);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.primary:hover {
  background: var(--blue-dark);
}

.secondary {
  background: #fff;
  border-color: var(--line-strong);
  color: #26384f;
}

.secondary:hover {
  background: #f2f6fb;
}

.danger {
  background: var(--soft-red);
  color: var(--red);
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 4px 10px 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  margin-bottom: 6px;
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.12;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--soft-green);
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
}

.status-pill.warning {
  background: #fff4dd;
  color: var(--gold);
}

.alert {
  border: 1px solid #f0c7ca;
  border-radius: 8px;
  background: #fff4f4;
  color: var(--red);
  margin-bottom: 10px;
  padding: 9px 12px;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
  gap: 10px;
  margin-bottom: 9px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
}

.panel-title h2 {
  font-size: 1rem;
}

.compact-title {
  border-bottom: 0;
  padding-bottom: 0;
}

.settings-form,
.channel-form,
.pair-form {
  display: grid;
  gap: 9px;
  padding: 12px 13px;
}

.settings-form {
  grid-template-columns: repeat(4, minmax(110px, 1fr));
}

.channel-form {
  grid-template-columns: minmax(150px, 0.55fr) minmax(0, 1.45fr);
}

.pair-form {
  grid-template-columns: 190px 190px auto;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
}

label span,
legend {
  color: #526078;
  font-size: 0.76rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 103, 209, 0.12);
}

input[readonly] {
  background: #f7f9fc;
  color: #586779;
}

.days-field {
  grid-column: span 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 8px 9px 9px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 5px;
}

.day-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbff;
  color: #526078;
  font-size: 0.76rem;
}

.day-grid input {
  width: 14px;
  min-height: 14px;
  height: 14px;
  accent-color: var(--blue);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px 10px;
}

.toggle-row small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.toggle-row.compact {
  min-height: 34px;
  padding: 7px 9px;
}

.credential-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 7px;
}

.channel-list {
  display: grid;
  gap: 7px;
  border-top: 1px solid var(--line);
  padding: 10px 13px 12px;
}

.channel-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px 9px;
}

.channel-title {
  font-weight: 800;
}

.channel-meta {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 2px;
}

.channel-actions {
  display: flex;
  gap: 5px;
}

.add-panel {
  margin-bottom: 10px;
}

.pairs-panel {
  overflow: hidden;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 10px;
  padding: 12px 13px 14px;
}

.pair-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.pair-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
}

.pair-title {
  font-weight: 900;
}

.pair-code {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--soft-blue);
  color: #204d94;
  padding: 2px 6px;
  font-size: 0.74rem;
  font-weight: 800;
}

.pair-actions,
.order-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.icon-btn {
  min-width: 30px;
  min-height: 28px;
  padding: 4px 7px;
}

.stock-info {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.stock-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #24364b;
}

.stock-name {
  font-weight: 800;
}

.stock-price {
  font-weight: 800;
}

.up {
  color: var(--red);
}

.down {
  color: var(--blue);
}

.neutral {
  color: var(--muted);
}

.ratio-display {
  border-top: 1px solid var(--line);
  background: #f8fbff;
  padding: 10px;
}

.ratio-value {
  font-size: 1.55rem;
  font-weight: 900;
}

.ratio-change {
  font-size: 0.8rem;
  font-weight: 800;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 920px) {
  .dashboard-grid,
  .settings-form,
  .channel-form,
  .pair-form,
  .credential-grid {
    grid-template-columns: 1fr;
  }

  .days-field {
    grid-column: auto;
  }

  .topbar,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
