:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #edf2f4;
  --text: #182027;
  --muted: #697780;
  --border: #d8e0e5;
  --accent: #007f73;
  --accent-strong: #005f56;
  --danger: #b3261e;
  --warning: #a15c00;
  --shadow: 0 12px 32px rgba(24, 32, 39, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button {
  background: var(--panel-soft);
  color: var(--text);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

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

.login-panel h1 {
  max-width: 100%;
  font-size: clamp(2rem, 3.2vw, 2.65rem);
  overflow-wrap: anywhere;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.04;
}

h2 {
  font-size: 1.1rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

.dashboard-view {
  display: grid;
  gap: 18px;
}

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

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

.last-updated {
  color: var(--muted);
  font-size: 0.9rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.custom-range[hidden] {
  display: none;
}

.status-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
}

.info-panel {
  border: 1px solid rgba(0, 127, 115, 0.22);
  border-radius: 8px;
  background: #f8fffd;
  padding: 0;
  overflow: hidden;
}

.info-panel summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 13px 16px;
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
  list-style-position: inside;
}

.info-panel summary:focus-visible {
  outline: 3px solid rgba(0, 127, 115, 0.28);
  outline-offset: -3px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border-top: 1px solid rgba(0, 127, 115, 0.16);
  padding: 16px;
}

.info-grid section {
  display: grid;
  gap: 8px;
}

.info-grid h2 {
  font-size: 0.98rem;
  color: var(--text);
}

.info-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.data-notice,
.loading-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(0, 127, 115, 0.25);
  border-radius: 8px;
  background: #ecfffb;
  padding: 14px 16px;
}

.data-notice {
  display: block;
}

.data-notice.stale {
  border-color: rgba(161, 92, 0, 0.35);
  background: #fff8eb;
}

.data-notice.incomplete {
  border-color: rgba(179, 38, 30, 0.38);
  background: #fff2f0;
}

.data-notice.incomplete strong {
  color: var(--danger);
}

.data-notice.loading {
  border-color: rgba(0, 127, 115, 0.35);
  background: #ecfffb;
}

.data-notice strong,
.loading-banner strong {
  display: block;
  margin-bottom: 4px;
}

.data-notice p,
.loading-banner p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.loading-banner {
  border-width: 2px;
  box-shadow: var(--shadow);
}

.spinner {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 4px solid rgba(0, 127, 115, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

.period-summary div {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.period-summary span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.period-summary strong {
  font-size: 1.02rem;
}

.error-text,
.error-banner {
  color: var(--danger);
}

.error-text {
  min-height: 20px;
  margin: 0;
}

.error-banner {
  margin: 0;
  border: 1px solid rgba(179, 38, 30, 0.25);
  border-radius: 8px;
  background: #fff2f0;
  padding: 12px 14px;
  font-weight: 700;
}

.tax-notice {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(161, 92, 0, 0.28);
  border-radius: 8px;
  background: #fff8eb;
  padding: 14px 16px;
}

.tax-notice strong {
  color: #774400;
}

.tax-notice p {
  margin: 0;
  color: var(--text);
}

.tax-notice small {
  color: var(--muted);
  line-height: 1.45;
}

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

.kpi-card {
  min-height: 146px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.kpi-card.primary {
  border-color: rgba(0, 127, 115, 0.35);
}

.kpi-card span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.kpi-card strong {
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1;
}

.kpi-card small {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.audit-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

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

.section-heading span {
  min-width: 32px;
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 4px 10px;
  text-align: center;
  font-weight: 800;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.audit-item strong {
  color: var(--warning);
}

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

@media (max-width: 920px) {
  .filters,
  .info-grid,
  .kpi-grid,
  .period-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1 1 170px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px;
  }

  .login-panel {
    padding: 22px;
  }

  .filters,
  .info-grid,
  .kpi-grid,
  .period-summary {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: 124px;
  }

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

  .last-updated {
    order: 3;
  }
}
