:root {
  --bg: #f6f4ef;
  --panel: rgba(255, 255, 255, 0.82);
  --text: #1f2023;
  --muted: #59606f;
  --accent: #ff6b35;
  --accent-2: #1c7c54;
  --line: #d9d5cc;
  --shadow: 0 20px 45px rgba(19, 31, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 12% 18%, #ffd6c2 0%, #f6f4ef 45%),
    radial-gradient(circle at 82% 20%, #d8f7df 0%, transparent 35%),
    linear-gradient(120deg, #f7f5ef 0%, #f2eee3 100%);
}

.background-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(transparent 96%, rgba(80, 92, 111, 0.08) 96%);
  background-size: 100% 30px;
}

.layout {
  width: min(1200px, 94vw);
  margin: 2.5rem auto 3rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: rise-in 0.5s ease both;
}

.hero {
  grid-column: 1 / -1;
  background: linear-gradient(115deg, #fff 0%, #fff8f4 40%, #f4fff7 100%);
}

.hero-nav {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

h1,
h2 {
  margin: 0 0 0.65rem;
}

h1 {
  font-size: clamp(1.5rem, 3.5vw, 2.4rem);
}

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

a {
  color: #0f6f4f;
  font-weight: 600;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7.2rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid #b7d6c8;
  text-decoration: none;
  color: #15553d;
  background: rgba(244, 255, 247, 0.95);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(28, 124, 84, 0.2);
  background: #fff;
}

.nav-btn-primary {
  background: #1c7c54;
  border-color: #1c7c54;
  color: #fff;
}

.nav-btn-primary:hover {
  box-shadow: 0 8px 20px rgba(28, 124, 84, 0.32);
}

.nav-btn-active {
  background: #1c7c54;
  border-color: #1c7c54;
  color: #fff;
  pointer-events: none;
}

.nav-btn-active:hover {
  transform: none;
  box-shadow: none;
  background: #1c7c54;
}

.grid-form {
  display: grid;
  gap: 0.8rem;
}

.actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.7rem;
}

.top-form {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
  gap: 0.5rem;
}

.top-form > label {
  min-width: 0;
  font-size: 0.76rem;
  line-height: 1.1;
  gap: 0.2rem;
}

.top-form > label > input {
  padding: 0.42rem 0.5rem;
}

.top-form > button[type="submit"] {
  white-space: nowrap;
  min-width: 0;
  width: 100%;
  grid-column: auto;
  justify-self: stretch;
  align-self: end;
  margin-top: 0;
  line-height: 1.1;
}

.latest-panel,
.month-panel {
  grid-column: 1 / -1;
}

.kpi-panel {
  grid-column: 1 / -1;
}

.bill-panel {
  grid-column: 1 / -1;
}

label {
  font-size: 0.88rem;
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.55rem 0.65rem;
  background: #fff;
}

select {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.55rem 0.65rem;
  background: #fff;
}

button {
  border: 0;
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(255, 107, 53, 0.3);
}

.danger-btn {
  background: #b42318;
}

.danger-btn:hover {
  box-shadow: 0 8px 20px rgba(180, 35, 24, 0.3);
}

.inline-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.message {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--accent-2);
  min-height: 1rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.6rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: right;
  padding: 0.45rem 0.35rem;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th:last-child,
td:last-child {
  text-align: center;
}

.row-edit-btn {
  padding: 0.2rem 0.4rem;
  min-width: 1.6rem;
  border-radius: 0.45rem;
  font-size: 0.82rem;
  line-height: 1;
  background: #f2eee3;
  color: #2f3a4a;
  border: 1px solid #cfc8b8;
}

.row-edit-btn:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(47, 58, 74, 0.18);
}

.summary-row td {
  font-weight: 700;
  background: #f8f4ea;
}

.stats {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.4rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.86rem;
}

.stats-grid {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.75rem 0.8rem;
}

.stat-card h3 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  margin-top: 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.stat-subtle {
  margin-top: 0.22rem;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
}

.quality-list {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.5rem;
}

.quality-item {
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.84);
  padding: 0.55rem 0.7rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.quality-item strong {
  color: var(--text);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.52rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.status-closed {
  background: rgba(28, 124, 84, 0.14);
  color: #15553d;
  border-color: rgba(28, 124, 84, 0.35);
}

.status-high {
  background: rgba(246, 189, 22, 0.2);
  color: #7a5b00;
  border-color: rgba(197, 146, 4, 0.35);
}

.status-missing {
  background: rgba(180, 35, 24, 0.14);
  color: #8a2018;
  border-color: rgba(180, 35, 24, 0.35);
}

.status-open {
  background: rgba(92, 140, 214, 0.16);
  color: #1f4e85;
  border-color: rgba(92, 140, 214, 0.35);
}

.status-neutral {
  background: rgba(100, 110, 128, 0.12);
  color: #465066;
  border-color: rgba(100, 110, 128, 0.3);
}

.kpi-trend {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.kpi-up {
  color: #1c7c54;
}

.kpi-down {
  color: #b42318;
}

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

.chart-wrap {
  position: relative;
  height: 340px;
  margin-top: 0.4rem;
}

.weekday-heatmap {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.heatmap-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.heatmap-header div {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.heatmap-cell {
  border-radius: 0.45rem;
  min-height: 2rem;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.78rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.heatmap-empty {
  background: rgba(100, 110, 128, 0.12);
  border: 1px dashed rgba(100, 110, 128, 0.3);
}

.charts-layout .hero,
.charts-layout .panel,
.charts-layout .chart-panel {
  grid-column: 1 / -1;
}

.admin-layout .hero,
.admin-layout .panel {
  grid-column: 1 / -1;
}

.admin-layout .panel {
  padding: 1.1rem 1.15rem;
}

.admin-layout .grid-form {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  align-items: end;
}

.admin-layout .grid-form > button[type="submit"] {
  min-height: 2.5rem;
  width: 100%;
}

.admin-layout .table-wrap {
  margin-top: 0.75rem;
}

.admin-layout .inline-row {
  flex-wrap: wrap;
}

.bill-card {
  border: 1px solid #c8c8c8;
  background: #f2f2f2;
  width: 50%;
  max-width: 50%;
  min-width: 0;
}

.bill-header {
  background: #4a2a8b;
  color: #fff;
  padding: 0.7rem 0.9rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.bill-meta {
  padding: 0.6rem 0.9rem 0.2rem;
  color: #4a4a4a;
  font-size: 0.85rem;
}

.bill-lines,
.bill-row-total {
  padding: 0.3rem 0.9rem 0.6rem;
}

.bill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #333;
  font-size: 0.95rem;
}

.bill-row-strong {
  font-weight: 700;
}

.bill-row-total {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  border-top: 2px solid #000;
  font-weight: 700;
  font-size: 1.05rem;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .layout {
    width: min(1100px, 96vw);
    margin-top: 1rem;
  }

  .top-form {
    grid-template-columns: 1fr;
  }

  .bill-card {
    width: 100%;
    min-width: 0;
  }

  .chart-wrap {
    height: 280px;
  }

  .nav-btn {
    min-width: 0;
    flex: 1 1 auto;
  }

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

  .actions-row button {
    width: 100%;
  }

  .admin-layout .grid-form {
    grid-template-columns: 1fr;
  }
}
