:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-2: #f9fbfb;
  --text: #17211d;
  --muted: #5f6f69;
  --line: #dfe6e2;
  --accent: #0f8b63;
  --accent-2: #0e7490;
  --danger: #c2413a;
  --warn: #a16207;
  --shadow: 0 10px 25px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

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

.login-panel p {
  margin: 8px 0 18px;
  color: var(--muted);
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 246, 0.94);
  backdrop-filter: blur(12px);
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 15px;
}

.subline,
.panel-head span,
.stat span,
.logs {
  color: var(--muted);
}

.subline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 5px;
  font-size: 13px;
}

.mode-strip,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.badge {
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.badge.good {
  border-color: rgba(15, 139, 99, 0.25);
  background: rgba(15, 139, 99, 0.1);
  color: var(--accent);
}

.badge.live {
  border-color: rgba(194, 65, 58, 0.25);
  background: rgba(194, 65, 58, 0.1);
  color: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 24px 28px;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

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

.panel {
  overflow: hidden;
}

.controls-panel {
  position: sticky;
  top: 94px;
  align-self: start;
  padding: 16px;
}

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

.controls-panel .panel-head {
  padding: 0 0 14px;
  border-bottom: 0;
  background: transparent;
}

.token-input {
  width: min(160px, 50%);
}

.button-row {
  margin-bottom: 16px;
}

button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #b8c8c1;
  background: #eef5f2;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(14, 116, 144, 0.18);
  border-color: var(--accent-2);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5faf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.scope-row strong {
  color: var(--accent);
  font-size: 13px;
  text-align: right;
}

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

.notice {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(14, 116, 144, 0.2);
  background: rgba(14, 116, 144, 0.08);
  color: var(--accent-2);
  font-size: 13px;
}

.notice.error {
  border-color: rgba(194, 65, 58, 0.25);
  background: rgba(194, 65, 58, 0.08);
  color: var(--danger);
}

.hidden {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px;
}

.stat span {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.1;
}

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

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

th,
td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

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

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

.symbol {
  font-weight: 800;
}

.drop {
  color: var(--danger);
  font-weight: 800;
}

.side {
  color: var(--accent-2);
  font-weight: 800;
}

.skip {
  color: var(--warn);
  font-weight: 800;
}

.sent {
  color: var(--danger);
  font-weight: 800;
}

.bar {
  position: relative;
  width: 150px;
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #e7ece9;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--danger));
}

.logs {
  display: grid;
  max-height: 300px;
  overflow: auto;
  padding: 8px 16px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.log-row {
  display: grid;
  grid-template-columns: 150px 58px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.log-row:last-child {
  border-bottom: 0;
}

.log-error {
  color: var(--danger);
}

.log-warn {
  color: var(--warn);
}

.empty {
  color: var(--muted);
}

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

  .controls-panel {
    position: static;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  h1 {
    font-size: 18px;
  }

  .subline {
    font-size: 12px;
  }

  .mode-strip,
  .button-row {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .badge,
  button {
    width: 100%;
    min-width: 0;
  }

  .token-input {
    width: 100%;
  }

  .controls-panel {
    padding: 12px;
  }

  .config-grid,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .check-row {
    grid-column: 1 / -1;
  }

  .panel-head {
    padding: 12px;
  }

  .controls-panel .panel-head {
    padding-bottom: 10px;
  }

  .stat {
    padding: 12px;
  }

  .stat strong {
    font-size: 18px;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    margin: 10px 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid #eef2f0;
    white-space: normal;
    text-align: right;
  }

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

  td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
  }

  td.empty {
    display: block;
    text-align: left;
  }

  td.empty::before {
    display: none;
  }

  .bar {
    width: min(150px, 52vw);
  }

  .logs {
    padding: 6px 12px 12px;
  }

  .log-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
