:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --ink: #1b2b24;
  --muted: #66756d;
  --accent-gce: #1e7f54;
  --accent-ch: #2c5f8a;
  --accent: var(--accent-gce);
  --line: #dbe5df;
  --soft: #e4f1ea;
  --soft-ch: #e4ecf4;
  --danger: #c0392b;
  --warn: #e67e22;
  --success: #27ae60;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 16px;
}

a { color: inherit; text-decoration: none; }

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.container--narrow { max-width: 480px; margin: 0 auto; padding: 0 20px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

/* Header */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header__apt {
  font-size: 0.875rem;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { opacity: 0.9; }

.btn--outline {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.btn--outline:hover { background: var(--soft); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 14px; font-size: 0.875rem; }
.btn--full { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 20px; }

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.input:focus { outline: none; border-color: var(--accent); }
.input--pin {
  letter-spacing: 0.5em;
  font-size: 1.25rem;
  text-align: center;
}

.select {
  width: 100%;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--card);
  cursor: pointer;
}

/* KPI Row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.kpi-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.kpi-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.kpi-card__value--accent { color: var(--accent); }
.kpi-card__value--danger { color: var(--danger); }
.kpi-card__value--warn { color: var(--warn); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge--green { background: #d4f5e4; color: #1a7a45; }
.badge--red { background: #fde8e6; color: #c0392b; }
.badge--orange { background: #fef0e4; color: #d35400; }
.badge--blue { background: #e4ecf4; color: #2c5f8a; }
.badge--grey { background: var(--soft); color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 2px solid var(--line);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Line items comparison */
.line-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.line-compare__col-header {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--line);
}

.line-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9375rem;
}
.line-item:last-child { border-bottom: none; }
.line-item--mismatch { color: var(--warn); }

/* Chart */
.chart-wrap {
  height: 220px;
  position: relative;
  margin-top: 16px;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink);
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.alert--error { background: #fde8e6; color: #c0392b; border: 1px solid #f5b7b1; }
.alert--success { background: #d4f5e4; color: #1a7a45; border: 1px solid #a9dfbf; }
.alert--warn { background: #fef0e4; color: #d35400; border: 1px solid #f0c27a; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone.drag-over { border-color: var(--accent); background: var(--soft); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-weight: 500;
  font-size: 0.9375rem;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
}

.tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* Gauge */
.gauge-wrap {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.5s ease;
}
.gauge-fill--red { background: var(--danger); }
.gauge-fill--warn { background: var(--warn); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}
.modal__title { font-size: 1.25rem; font-weight: 700; margin-bottom: 16px; }

/* Utility */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 8px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.875rem; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .line-compare { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  body { font-size: 15px; }
  .card { padding: 16px; }
}
