:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --panel: #ffffff;
  --panel-2: #eef2ee;
  --text: #1c2320;
  --muted: #68726e;
  --line: #d9dfd9;
  --accent: #156c5b;
  --accent-2: #223c5f;
  --danger: #b23b3b;
  --warn: #a36b13;
  --good: #1f7a49;
  --shadow: 0 14px 34px rgba(27, 34, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.95);
}

button.secondary {
  background: #e2e8e3;
  color: var(--text);
}

button.ghost {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger);
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: #e2e8e3;
  color: var(--text);
  padding: 0 16px;
  text-decoration: none;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.login-box h1 {
  margin: 4px 0 0;
  font-size: 28px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

textarea {
  min-height: 82px;
  resize: vertical;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

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

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  background: #17211d;
  color: #fff;
  padding: 20px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d7efe5;
  color: #11392d;
  font-weight: 800;
}

.brand small {
  display: block;
  color: #aebcb6;
  margin-top: 3px;
}

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

.nav-button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: #dce6e1;
  border: 1px solid transparent;
}

.nav-button.active,
.nav-button:hover {
  background: #25322d;
  border-color: #3b4b45;
}

.full {
  width: 100%;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  background: rgba(244, 245, 242, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

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

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.period-controls {
  display: grid;
  grid-template-columns: 150px 140px 140px auto;
  gap: 8px;
  align-items: center;
}

.view {
  padding: 24px 28px 40px;
  display: grid;
  gap: 22px;
}

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

.band-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.band h3 {
  margin: 0;
  font-size: 18px;
}

.band p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.stat {
  min-height: 98px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

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

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

.stat.good strong {
  color: var(--good);
}

.stat.bad strong {
  color: var(--danger);
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid .wide {
  grid-column: span 2;
}

.form-grid .full-row {
  grid-column: 1 / -1;
}

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

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

.checkbox-pill input {
  width: auto;
  min-height: 0;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

td.number,
th.number {
  text-align: right;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e8ece9;
  color: #2c3834;
  font-size: 12px;
  font-weight: 700;
}

.status.active,
.status.manual,
.status.connected {
  background: #dcefe5;
  color: #155f3e;
}

.status.error,
.negative {
  color: var(--danger);
}

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

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

.signals {
  display: grid;
  gap: 8px;
}

.signal {
  border-left: 4px solid var(--warn);
  background: #fff8ea;
  border-radius: 8px;
  padding: 10px 12px;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(440px, calc(100vw - 44px));
  background: #1d2a25;
  color: #fff;
  border-radius: 8px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  z-index: 10;
}

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

  .sidebar {
    min-height: auto;
    position: static;
    grid-template-rows: auto auto auto;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar,
  .period-controls,
  .grid-two,
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .form-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .sidebar,
  .topbar,
  .view {
    padding-left: 14px;
    padding-right: 14px;
  }

  nav {
    grid-template-columns: 1fr;
  }

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