/* ============================================================
   Veil — GHG Emissions Dashboard Styles
   ============================================================ */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #e2e0d8;
  --text: #1a1a18;
  --text-mid: #5c5c52;
  --text-light: #90908a;
  --s1: #c0392b;
  --s1-bg: #fdf0ee;
  --s2: #2980b9;
  --s2-bg: #edf6fd;
  --accent: #27ae60;
  --accent-bg: #e9f7ef;
  --nav-bg: #1a1a18;
  --nav-text: #f5f4f0;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --font-head: 'Fraunces', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}

/* Nav */
.nav {
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}
.nav-logo {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.nav-tag {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
}
.nav-right { display: flex; align-items: center; gap: 12px; }

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* Page header */
.page-header { margin-bottom: 32px; }
.page-header h1 {
  font-family: var(--font-head);
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.subtitle {
  color: var(--text-mid);
  font-size: 15px;
}

/* Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 36px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 8px;
}
.card-value {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  margin-bottom: 4px;
}
.card-unit {
  font-size: 13px;
  color: var(--text-mid);
}
.card-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}
.scope1-card { border-top: 3px solid var(--s1); }
.scope2-card { border-top: 3px solid var(--s2); }
.combined-card { border-top: 3px solid var(--accent); }
.entries-card { border-top: 3px solid var(--text-mid); }
.scope3-card { border-top: 3px solid #8b5cf6; }

/* Scope 3 category cards */
#scope3-cat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.cat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px 16px;
}
.cat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 8px;
}
.cat-value {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.cat-unit {
  font-size: 12px;
  color: var(--text-light);
}

/* Section */
.section { margin-bottom: 40px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}
.section-header .section-title { margin-bottom: 0; }

/* Table */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead tr {
  background: #f0efe8;
  border-bottom: 1px solid var(--border);
}
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mid);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafaf7; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-row { text-align: center; color: var(--text-light); padding: 40px !important; }

.scope-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.scope-badge.scope1 { background: var(--s1-bg); color: var(--s1); }
.scope-badge.scope2 { background: var(--s2-bg); color: var(--s2); }
.scope-badge.scope3 { background: #f3f0ff; color: #8b5cf6; }

.btn-delete {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-delete:hover { background: #fee; color: var(--s1); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--text); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-mid); border: 1px solid var(--border); }
.btn-ai {
  background: linear-gradient(135deg, #1a5e3a 0%, #27ae60 100%);
  color: #fff;
  font-weight: 600;
}
.btn-small { padding: 5px 12px; font-size: 12px; }

/* CSRD Section */
.csrd-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 32px;
}
.csrd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.csrd-desc { color: var(--text-mid); font-size: 14px; margin-top: 4px; }
.csrd-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.csrd-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-mid);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.csrd-controls input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.btn-ai-icon { font-size: 16px; }

.csrd-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-mid);
  padding: 20px 0;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.csrd-output { margin-top: 8px; }
.csrd-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.csrd-output-header h3 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
}
.csrd-output-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-light); }
.csrd-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
}

.past-reports-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-light); margin-top: 24px; margin-bottom: 10px; }
.past-reports-list { display: flex; flex-wrap: wrap; gap: 8px; }
.past-report-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font-body);
  color: var(--text-mid);
  cursor: pointer;
}
.past-report-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Chart */
.chart-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
}
.chart-placeholder { color: var(--text-light); text-align: center; padding: 32px 0; font-size: 14px; }
.bar-chart { font-size: 12px; }
.chart-legend { display: flex; gap: 16px; margin-bottom: 16px; font-size: 12px; }
.leg-s1 { color: var(--s1); }
.leg-s2 { color: var(--s2); }
.bars { display: flex; align-items: flex-end; gap: 8px; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar-stack { display: flex; gap: 2px; align-items: flex-end; height: 160px; width: 100%; }
.bar { width: 14px; border-radius: 3px 3px 0 0; transition: opacity 0.2s; cursor: default; }
.bar:hover { opacity: 0.8; }
.bar-s1 { background: var(--s1); }
.bar-s2 { background: var(--s2); }
.bar-label { font-size: 10px; color: var(--text-light); }

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 32px;
  width: 100%;
  max-width: 540px;
  margin: 16px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* Form */
form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row:has(> label:last-child) input[type="text"] { width: 100%; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-mid); }
input, select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.factor-hint {
  background: var(--accent-bg);
  color: #1a5e3a;
  font-size: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  line-height: 1.4;
}
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

@media (max-width: 768px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .csrd-header { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
}