:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-strong: #f0f4f2;
  --line: #d9e2df;
  --text: #182421;
  --muted: #62716d;
  --primary: #1f6f5b;
  --primary-dark: #165243;
  --accent: #c57535;
  --danger: #b33c3c;
  --good: #28724f;
  --shadow: 0 18px 48px rgba(23, 42, 36, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #e7eeeb;
  color: var(--primary-dark);
}

button.secondary:hover {
  background: #dce8e4;
}

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

button.text {
  background: transparent;
  color: var(--primary-dark);
  padding: 0 6px;
}

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

.optionRow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.optionRow label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.optionRow input {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

textarea {
  resize: vertical;
}

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

.fieldLabel {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.compactLabel {
  min-width: 180px;
}

.spacerTop {
  margin-top: 14px;
}

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

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

.loginPanel h1,
.workspace h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.loginPanel p,
.workspace p {
  color: var(--muted);
}

.loginPanel form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

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

.sidebar {
  background: #17362f;
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brandMark {
  display: grid;
  gap: 4px;
}

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

.brandMark span,
.sidebar small {
  color: rgba(255, 255, 255, 0.68);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.sidebarFooter {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.workspace {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar p {
  margin: 6px 0 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.summaryGrid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 42, 36, 0.06);
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel {
  padding: 18px;
}

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

.inlineEditor {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.moveBox {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(280px, 1.2fr);
  gap: 14px;
  align-items: end;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.moveForm {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

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

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

.tableWrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

.compactTables th,
.compactTables td {
  padding: 8px 10px;
}

.compactTables button {
  min-height: 34px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: var(--panel-strong);
}

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

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7eeeb;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.pill.warn {
  background: #fff1df;
  color: #80501f;
}

.pill.good {
  background: #e2f3ec;
  color: var(--good);
}

.pill.dangerPill {
  background: #fff0f0;
  color: var(--danger);
}

.warningPanel {
  border-color: #e5b1b1;
}

.warningList {
  display: grid;
  gap: 10px;
}

.warningItem {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid #ebc7c7;
  border-radius: 8px;
  background: #fff7f7;
  color: var(--danger);
}

.automatsGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.automatPanel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.automatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.automatHeader h3 {
  margin: 0;
  font-size: 17px;
}

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

.marginOutput {
  display: flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #e2f3ec;
  color: var(--good);
  font-weight: 800;
}

.marginOutput.low {
  background: #fff0f0;
  color: var(--danger);
  border-color: #ebc7c7;
}

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

.compactActions {
  flex-wrap: nowrap;
  gap: 4px;
}

.iconButton {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}

.banner {
  padding: 12px 14px;
  border-radius: 8px;
  background: #e7eeeb;
  color: var(--primary-dark);
  border: 1px solid var(--line);
}

.banner.error {
  background: #fff0f0;
  color: var(--danger);
  border-color: #ebc7c7;
}

.importLayout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 16px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.empty {
  color: var(--muted);
  padding: 18px;
  background: var(--panel-strong);
  border-radius: 8px;
}

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

  .sidebar {
    min-height: unset;
  }

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

  .summaryGrid,
  .formGrid,
  .importLayout,
  .automatsGrid,
  .moveBox,
  .moveForm {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    flex-direction: column;
  }
}
