:root {
  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #eef4f4;
  --text: #17201f;
  --muted: #657371;
  --line: #d9e2e1;
  --accent: #087f75;
  --accent-dark: #055f58;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(26, 42, 39, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

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

.brand {
  font-size: 24px;
  font-weight: 750;
  margin: 0 0 6px;
}

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

.form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  background: #fff;
}

.primary-btn,
.ghost-btn,
.primary-link {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn,
.primary-link {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover,
.primary-link:hover {
  background: var(--accent-dark);
}

.ghost-btn {
  background: var(--surface-2);
  color: var(--text);
}

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

.error-panel {
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--danger);
  padding: 14px 16px;
  line-height: 1.5;
}

.warning-banner {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fff8e6;
  color: #7a4b00;
  font-size: 14px;
  line-height: 1.45;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.meta-strip span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
}

.meta-strip .meta-ok {
  border-color: #bce4d7;
  background: #e7f7f1;
  color: #06684d;
  font-weight: 800;
}

.meta-strip .meta-warn {
  border-color: #f0c36d;
  background: #fff8e6;
  color: #7a4b00;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  background: #101918;
  color: #dfe9e7;
  padding: 22px 18px;
}

.sidebar-title {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 28px;
}

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

.nav button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 11px;
  text-align: left;
  background: transparent;
  color: #b6c3c1;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  background: #20302e;
  color: #fff;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.mobile-nav {
  display: none;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.content {
  padding: 26px 28px 36px;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.source-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.filter-bar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.compact-field {
  display: grid;
  gap: 6px;
  min-width: 160px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-field input,
.compact-field select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
}

.course-field {
  min-width: 260px;
  flex: 1 1 320px;
}

.selected-course-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  color: #065f58;
  font-size: 13px;
  font-weight: 750;
}

.selected-course-strip span {
  border: 1px solid #bce4d7;
  border-radius: 8px;
  background: #e7f7f1;
  padding: 8px 10px;
}

.loading-panel {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 750;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #d4e1df;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(22, 35, 33, 0.03);
}

.card {
  padding: 18px;
}

.label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.value {
  font-size: 27px;
  font-weight: 800;
}

.system-value {
  font-size: 18px;
  line-height: 1.25;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pass {
  background: #e7f7f1;
  color: #06684d;
}

.status-fail {
  background: #fff0ed;
  color: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.section-gap {
  margin-top: 18px;
}

.chart {
  min-height: 300px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-top: 36px;
  padding-bottom: 42px;
}

.empty-state {
  width: 100%;
  align-self: center;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.bar-item {
  flex: 1;
  min-width: 22px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: end;
  position: relative;
}

.bar {
  background: linear-gradient(180deg, #12a89a, #087f75);
  border-radius: 6px 6px 0 0;
}

.bar-h-1 { height: 12px; }
.bar-h-2 { height: 22px; }
.bar-h-3 { height: 33px; }
.bar-h-4 { height: 43px; }
.bar-h-5 { height: 54px; }
.bar-h-6 { height: 64px; }
.bar-h-7 { height: 75px; }
.bar-h-8 { height: 85px; }
.bar-h-9 { height: 96px; }
.bar-h-10 { height: 106px; }
.bar-h-11 { height: 117px; }
.bar-h-12 { height: 127px; }
.bar-h-13 { height: 138px; }
.bar-h-14 { height: 148px; }
.bar-h-15 { height: 159px; }
.bar-h-16 { height: 169px; }
.bar-h-17 { height: 180px; }
.bar-h-18 { height: 190px; }
.bar-h-19 { height: 201px; }
.bar-h-20 { height: 210px; }

.bar-value {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.bar-date,
.bar-orders {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bar-date {
  bottom: -23px;
  font-weight: 750;
}

.bar-orders {
  bottom: -42px;
  font-size: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

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

.num {
  text-align: right;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.report-text {
  margin-top: 14px;
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.65;
}

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

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }

  .mobile-nav button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 8px;
    padding: 9px 11px;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 700;
  }

  .mobile-nav button.active,
  .mobile-nav button:hover {
    background: var(--accent);
    color: #fff;
  }

  .kpis,
  .grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .page-head {
    align-items: start;
    flex-direction: column;
  }

  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-field {
    min-width: 0;
  }
}
