:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #66717f;
  --line: #dfe4ea;
  --accent: #126a6f;
  --accent-2: #b94d35;
  --good: #177245;
  --warn: #b7791f;
  --bad: #b42318;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.auth-state {
  overflow: hidden;
}

body.auth-state .app {
  display: none !important;
}

body.dashboard-state .login-screen {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.link-button {
  min-height: auto;
  border-radius: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover {
  color: #0c4f53;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(24, 32, 42, 0.08);
}

.login-panel h1,
.topbar h1 {
  margin: 4px 0 0;
}

.login-panel label {
  display: grid;
  gap: 8px;
  margin: 24px 0 16px;
  color: var(--muted);
}

.login-panel button {
  width: 100%;
}

.error {
  min-height: 20px;
  color: var(--bad);
}

.app {
  display: block;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.select-label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

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

.kpi small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
  overflow-x: auto;
}

.tab {
  color: var(--text);
  background: #e9edf1;
}

.tab.active {
  color: #fff;
  background: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.chart-panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.chart-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.chart {
  width: 100%;
  height: 360px;
}

.target-chart {
  height: 320px;
}

.chart.tall {
  height: 460px;
}

.revenue-targets-panel {
  margin-top: 14px;
}

.production-panel {
  margin-bottom: 14px;
}

.production-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.production-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.production-card span,
.production-plan {
  color: var(--muted);
  font-size: 13px;
}

.production-card strong {
  display: block;
  margin: 8px 0;
  font-size: 22px;
}

.production-table {
  margin-top: 12px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-heading h2 {
  margin: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 14px;
}

.section-note {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.production-select {
  min-width: 260px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) minmax(150px, 210px);
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar input {
  width: 100%;
}

.table-wrap {
  overflow: auto;
  padding: 0;
}

.compact-table {
  margin-top: 10px;
  border-radius: 6px;
}

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

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

.compact-table th,
.compact-table td {
  padding: 10px 12px;
  white-space: nowrap;
}

.deviation-positive {
  color: var(--good);
  font-weight: 700;
}

.deviation-negative {
  color: var(--bad);
  font-weight: 700;
}

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

.target-total-row {
  background: #f1f5f7;
  font-weight: 700;
}

.target-under-row {
  background: #fff7f5;
}

.target-over-row {
  background: #f2fbf6;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.good {
  background: var(--good);
}

.status-pill.bad {
  background: var(--bad);
}

.progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe4ea;
}

.progress-track span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.progress-track span.good {
  background: var(--good);
}

.progress-track span.bad {
  background: var(--bad);
}

th {
  position: sticky;
  top: 0;
  background: #f0f3f5;
  z-index: 1;
}

.risk {
  display: inline-block;
  min-width: 72px;
  border-radius: 999px;
  padding: 4px 8px;
  text-align: center;
  background: #edf2f7;
}

.risk.high {
  color: #fff;
  background: var(--bad);
}

.risk.medium {
  color: #fff;
  background: var(--warn);
}

.risk.low {
  color: #fff;
  background: var(--good);
}

.footer {
  color: var(--muted);
  font-size: 13px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .topbar,
  .layout-two {
    grid-template-columns: 1fr;
    display: grid;
  }

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

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

@media (max-width: 560px) {
  .app {
    padding: 14px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .production-grid {
    grid-template-columns: 1fr;
  }

  .production-select {
    min-width: 0;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }
}
