:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2ff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-strong: #3730a3;
  --danger: #dc2626;
  --border: #e5e7eb;
  --success: #059669;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.dark {
  --bg: #0f172a;
  --surface: #111827;
  --surface-2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #818cf8;
  --primary-strong: #a5b4fc;
  --danger: #f87171;
  --border: #374151;
  --success: #34d399;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 74px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar a {
  text-decoration: none;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
}

.sidebar a:hover {
  background: var(--surface-2);
}

.content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.grid {
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 1rem;
}

.section-card h2 {
  margin-top: 0;
}

.metric {
  margin: 0.3rem 0 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.92rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.55rem 0.65rem;
}

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
}

.btn:hover {
  background: var(--primary-strong);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.daily-inputs {
  margin: 1rem 0;
  display: grid;
  gap: 0.8rem;
}

.daily-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 0.8rem;
  align-items: center;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.chart-card {
  background: var(--surface-2);
  border-radius: 0.8rem;
  padding: 0.9rem;
  min-height: 340px;
  display: flex;
  flex-direction: column;
}

.chart-card h3 {
  margin: 0 0 0.75rem;
}

.chart-card canvas {
  width: 100% !important;
  height: 260px !important;
}

.summary-list {
  margin-top: 1rem;
  display: grid;
  gap: 0.6rem;
}

.summary-item {
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
}

.success {
  color: var(--success);
  font-weight: 600;
}

.warning {
  color: var(--danger);
  font-weight: 600;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .daily-row {
    grid-template-columns: 1fr;
  }
}
