:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #14211b;
  --muted: #6c7973;
  --border: #dbe3df;
  --accent: #067342;
  --accent-dark: #045f36;
  --orange: #d96b1c;
  --shadow: 0 16px 40px rgba(18, 33, 27, 0.08);
}

* {
  box-sizing: border-box;
}

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

.sidebar {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e4f3ea;
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
}

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

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
}

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

.config-form {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
}

.form-scroll {
  min-height: 0;
  display: grid;
  flex: 1;
  gap: 22px;
  padding-top: 22px;
  padding-right: 2px;
  overflow-y: auto;
}

section h2 {
  margin-bottom: 12px;
  font-size: 12px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #2b3a33;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 650;
  color: #34433d;
}

fieldset {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px 4px;
}

legend {
  padding: 0 4px;
  color: #34433d;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfb;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: #69a885;
  box-shadow: 0 0 0 3px rgba(6, 115, 66, 0.12);
}

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

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-grid.compact {
  gap: 7px;
}

.route-list {
  display: grid;
  max-height: 260px;
  gap: 7px;
  overflow-y: auto;
  padding-right: 2px;
}

.route-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 9px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfcfb;
}

.route-option input {
  width: 18px;
  height: 18px;
}

.route-option span {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
  font-weight: 700;
}

.route-option small {
  grid-column: 2;
  font-size: 12px;
  font-weight: 600;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
}

.check-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-pill span {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfb;
  color: #46554f;
  font-size: 13px;
  font-weight: 650;
}

.check-pill input:checked + span {
  border-color: #b5d9c4;
  background: #e8f5ed;
  color: var(--accent-dark);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-row input {
  width: 20px;
  height: 20px;
}

.date-panel {
  transition: opacity 0.15s ease;
}

.date-panel.is-disabled {
  opacity: 0.46;
}

.date-panel.is-disabled input {
  cursor: not-allowed;
}

.primary-button,
.primary-inline-button,
.secondary-button,
.ghost-button {
  height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 750;
}

.primary-button {
  width: 100%;
  flex: 0 0 auto;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(6, 115, 66, 0.18);
}

.primary-inline-button {
  color: #fff;
  background: var(--accent);
}

.primary-button:hover,
.primary-inline-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  color: #fff;
  background: #1f7a50;
}

.ghost-button {
  border-color: var(--border);
  background: #fff;
  color: #34433d;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-button:disabled,
.primary-inline-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.topbar h2 {
  margin-top: 4px;
  font-size: 26px;
}

.section-label {
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--accent);
}

.status {
  min-width: 120px;
  border: 1px solid #b5d9c4;
  border-radius: 8px;
  padding: 10px 12px;
  background: #eaf6ef;
  color: var(--accent-dark);
  text-align: center;
  font-size: 13px;
  font-weight: 750;
}

.status.busy {
  border-color: #f0c69d;
  background: #fff2e7;
  color: var(--orange);
}

.status.error {
  border-color: #efb6b6;
  background: #fff0f0;
  color: #b32626;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid article,
.panel,
.telegram-panel,
.monitor-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-grid article {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 28px;
  line-height: 1;
}

.panel {
  overflow: hidden;
}

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

.panel-head h3,
.telegram-panel h3 {
  margin-top: 5px;
  font-size: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #fbfcfb;
  color: #5c6862;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.deal-level {
  display: inline-flex;
  border-radius: 8px;
  padding: 6px 8px;
  background: #e8f5ed;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.deal-level.watch {
  background: #fff2e7;
  color: var(--orange);
}

.price {
  font-weight: 850;
  color: var(--accent-dark);
}

.ticket-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 120px;
}

.ticket-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #b5d9c4;
  border-radius: 8px;
  padding: 0 10px;
  background: #e8f5ed;
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.ticket-link:hover {
  border-color: var(--accent);
  background: #d9f0e3;
}

.subline {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.empty-row td {
  padding: 38px 18px;
  text-align: center;
  color: var(--muted);
}

.telegram-panel,
.monitor-panel {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 520px);
  gap: 24px;
  margin-top: 18px;
  padding: 22px;
}

.telegram-form {
  display: grid;
  grid-template-columns: 1fr 1fr 170px;
  gap: 10px;
  align-items: center;
}

.monitor-actions {
  display: grid;
  grid-template-columns: 1fr 140px 120px 130px;
  gap: 10px;
  align-items: center;
}

.run-window {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
  border: 1px solid #b5d9c4;
  border-radius: 8px;
  padding: 12px 14px;
  background: #eaf6ef;
  color: var(--accent-dark);
}

.run-window[hidden] {
  display: none;
}

.run-window strong {
  font-size: 14px;
}

.run-window span {
  color: #46554f;
  font-size: 13px;
  font-weight: 650;
}

.monitor-log {
  grid-column: 1 / -1;
  max-height: 130px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfb;
  color: #46554f;
  white-space: pre-wrap;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.env-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfb;
  color: #46554f;
  font-size: 13px;
  font-weight: 700;
}

.ok-dot,
.missing-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.ok-dot {
  background: var(--accent);
}

.missing-dot {
  background: #d96b1c;
}

code {
  border-radius: 5px;
  background: #eef4f1;
  padding: 2px 5px;
  color: #2b3a33;
  font-size: 0.92em;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .form-scroll {
    overflow: visible;
  }

  .summary-grid,
  .telegram-panel,
  .monitor-panel {
    grid-template-columns: 1fr 1fr;
  }

  .monitor-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 18px;
  }

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

  .summary-grid,
  .telegram-panel,
  .monitor-panel,
  .telegram-form,
  .monitor-actions {
    grid-template-columns: 1fr;
  }
}
