:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --sidebar: #1a2e1a;
  --sidebar-text: #c8d4c0;
  --sidebar-active: #ffffff;
  --text: #1a2418;
  --text-secondary: #5c6b58;
  --text-muted: #8a9686;
  --border: #dde4d8;
  --accent: #3d6b2f;
  --accent-light: #e8f0e4;
  --accent-dark: #2d5016;
  --positive: #2d7a3a;
  --warning: #b8860b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(26, 36, 24, 0.06);
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-name {
  margin: 0;
  color: var(--sidebar-active);
  font-weight: 600;
  font-size: 0.95rem;
}

.brand-url {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.7;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-active);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--sidebar-active);
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.meta-label {
  margin: 0 0 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
}

.meta-value {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  color: var(--sidebar-active);
}

.sample-badge {
  display: inline-block;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(184, 134, 11, 0.25);
  color: #f0d878;
  font-size: 0.75rem;
  font-weight: 500;
}

.main {
  padding: 32px 40px 48px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.notice {
  background: var(--accent-light);
  border: 1px solid #c5d9bc;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.9rem;
  color: var(--accent-dark);
  margin-bottom: 28px;
}

.notice strong {
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card.accent {
  border-color: #b8d4ae;
  background: linear-gradient(180deg, #f8fbf6 0%, var(--surface) 100%);
}

.stat-label {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-delta {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-delta.positive {
  color: var(--positive);
}

.section-head {
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.section-head p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-row .chart-section {
  margin-bottom: 0;
}

.chart-row.wide-narrow {
  grid-template-columns: 2fr 1fr;
}

.chart-wrap {
  position: relative;
  height: 220px;
}

.chart-wrap.tall {
  height: 260px;
}

.chart-wrap.donut {
  height: 240px;
  max-width: 280px;
  margin: 0 auto;
}

.table-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

.table-section,
.panel-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

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

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

td:nth-child(2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #f8faf6;
}

.device-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

.device-row {
  display: grid;
  grid-template-columns: 72px 1fr 40px;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
}

.device-row span:first-child {
  color: var(--text-secondary);
}

.device-row span:last-child {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bar-fill.mobile { background: var(--accent); }
.bar-fill.desktop { background: #5a8a72; }
.bar-fill.tablet { background: #a8b89a; }

.today-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 16px 18px;
}

.today-title {
  margin: 0 0 12px;
  font-weight: 600;
  font-size: 0.9rem;
}

.today-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.today-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.today-stats span:last-child {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.today-num {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.today-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .chart-row,
  .table-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  html,
  body {
    background: #fff;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .layout {
    display: block;
    min-height: auto;
  }

  .sidebar {
    display: none;
  }

  .main {
    max-width: none;
    padding: 0;
  }

  .page-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
  }

  .page-header::before {
    content: "Hardiman Trädvård · hardiman.se · GA4: G-7D1XJL0DVL";
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
  }

  .header-actions {
    display: none;
  }

  .notice {
    margin-bottom: 16px;
    padding: 10px 14px;
    font-size: 0.82rem;
  }

  .stats-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 12px 14px;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .chart-section,
  .table-section,
  .panel-section {
    box-shadow: none;
    padding: 14px 16px;
    margin-bottom: 12px;
  }

  .chart-row,
  .table-row {
    gap: 12px;
    margin-bottom: 12px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .table-row {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .table-section table {
    font-size: 0.82rem;
  }

  .table-section th,
  .table-section td {
    padding: 7px 10px;
  }

  .device-bars {
    gap: 10px;
    margin-bottom: 14px;
  }

  .today-box {
    padding: 12px 14px;
  }

  .today-num {
    font-size: 1.1rem;
  }

  .chart-wrap {
    height: 160px;
  }

  .chart-wrap.tall {
    height: 170px;
  }

  .chart-wrap.donut {
    height: 160px;
  }

  .section-head {
    margin-bottom: 10px;
  }

  .section-head h2 {
    font-size: 0.95rem;
  }

  tbody tr:hover {
    background: transparent;
  }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 16px 20px;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .sidebar-footer {
    margin-top: 0;
    border-top: none;
    width: 100%;
  }

  .main {
    padding: 24px 20px 40px;
  }

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

  .page-header {
    flex-direction: column;
  }
}
