:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --line: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, #e0f2fe 0%, var(--bg) 45%);
}

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

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
}

h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

h2 {
  margin: 0 0 12px;
}

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

.small {
  font-size: 13px;
}

.form-grid {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

label {
  font-size: 14px;
  color: var(--muted);
}

input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}

input:focus {
  outline: 2px solid #99f6e4;
  border-color: var(--accent);
}

button {
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
}

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

button.secondary {
  background: #1f2937;
}

.alert {
  background: var(--danger-bg);
  color: var(--danger-text);
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: 14px;
}

.link {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: #ffffffcc;
  backdrop-filter: blur(4px);
}

.dashboard {
  padding: 24px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  font-size: 14px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

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

.link-btn {
  display: inline-block;
  text-decoration: none;
  color: #fff;
  background: #2563eb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

.link-btn:hover {
  background: #1d4ed8;
}

.alert.success {
  background: #dcfce7;
  color: #166534;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  background: #e5e7eb;
  color: #1f2937;
}

.badge.ok {
  background: #d1fae5;
  color: #065f46;
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.badge.off {
  background: #e5e7eb;
  color: #6b7280;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form.compact {
  gap: 6px;
}

.inline-form input[type="number"],
.inline-form input[type="password"] {
  width: auto;
  min-width: 120px;
}

.inline-form button {
  margin-top: 0;
  padding: 9px 11px;
}

button.danger {
  background: #b91c1c;
}

button.danger:hover {
  background: #991b1b;
}

.actions-stack {
  display: grid;
  gap: 8px;
}

code {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 2px 6px;
}

.reports-page {
  display: grid;
  gap: 20px;
}

select {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
}

.upload-panel {
  background: linear-gradient(130deg, #ecfeff, #ffffff 42%);
}

.uploaded-files {
  margin-top: 16px;
}

.uploaded-files h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

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

.uploaded-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
}

.uploaded-file-meta {
  min-width: 0;
}

.uploaded-file-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
}

.report-builder {
  background: linear-gradient(130deg, #eff6ff, #ffffff 35%);
}

.filters-form {
  display: grid;
  gap: 14px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.filters-grid label {
  margin-bottom: -4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}

.filters-grid select,
.filters-grid input[type="date"] {
  width: 100%;
}

.filters-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.link-btn.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

.link-btn.ghost:hover {
  background: #cbd5e1;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #dbeafe;
  padding: 6px 10px;
  font-size: 12px;
  color: #1e40af;
  background: #eff6ff;
}

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

.kpi-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 42%, #ecfeff 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-height: 112px;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.kpi-small {
  font-size: 16px;
  line-height: 1.3;
}

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

.charts-grid.advanced .chart-panel {
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

.chart-panel h2 {
  margin-bottom: 14px;
}

.chart-panel canvas {
  width: 100% !important;
  min-height: 280px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

@media (max-width: 1200px) {
  .filters-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

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

  .uploaded-file-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .dashboard {
    padding: 16px;
  }

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

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