:root {
  --brand-navy: #072130;
  --brand-navy-2: #122a3f;
  --brand-blue: #216587;
  --brand-gold: #e99f2e;

  --line-dark: rgba(123, 165, 194, 0.32);
  --line-light: #d2dde8;

  --text-light: #edf5fb;
  --text-dark: #122a3f;
  --muted-light: #a6c0d5;
  --muted-dark: #5e7890;

  --danger: #c63333;
  --danger-soft: #ffe7e7;

  --shadow: 0 14px 36px rgba(2, 12, 23, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Urbanist", "Inter", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 16% -8%, rgba(88, 135, 166, 0.35) 0%, transparent 42%),
    radial-gradient(circle at 86% -12%, rgba(33, 101, 135, 0.24) 0%, transparent 38%),
    linear-gradient(180deg, var(--brand-navy) 0%, #051a28 100%);
  color: var(--text-light);
}

body {
  min-height: 100vh;
}

.app-shell {
  width: calc(100% - 20px);
  margin: 10px auto 20px;
  display: grid;
  gap: 14px;
}

.hero {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  color: var(--text-dark);
  border: 1px solid #d3e0ec;
  border-bottom: 3px solid var(--brand-gold);
  border-radius: 14px;
  box-shadow: 0 12px 26px rgba(2, 15, 28, 0.16);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

h1 {
  margin: 4px 0 8px;
  font-size: clamp(1.45rem, 2.2vw, 2.15rem);
  line-height: 1.14;
  font-weight: 800;
  color: var(--brand-navy-2);
}

.hero-copy {
  margin: 0;
  max-width: 78ch;
  color: var(--muted-dark);
  line-height: 1.45;
  font-weight: 500;
}

.hero-actions {
  display: grid;
  gap: 8px;
}

.action-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: end;
  gap: 8px;
}

.input-group {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-dark);
}

.input-group.small select {
  min-width: 140px;
}

select,
.input-money,
.input-text {
  border: 1px solid #bdd0df;
  background: #f7fbff;
  color: #10324d;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.input-text {
  min-width: 210px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(145deg, #f0b443 0%, var(--brand-gold) 100%);
  color: #24344b;
  box-shadow: 0 8px 20px rgba(233, 159, 46, 0.32);
}

.btn.ghost {
  background: linear-gradient(150deg, #f3f8fd 0%, #e8f2f9 100%);
  color: var(--brand-blue);
  border: 1px solid #bdd0df;
  box-shadow: none;
}

.file-btn {
  display: inline-block;
}

.kpis {
  background: linear-gradient(165deg, rgba(13, 45, 69, 0.96) 0%, rgba(18, 42, 63, 0.96) 100%);
  border: 1px solid var(--line-dark);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.kpi {
  background: linear-gradient(165deg, rgba(25, 62, 90, 0.88) 0%, rgba(16, 45, 68, 0.88) 100%);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  padding: 12px;
}

.kpi p {
  margin: 0;
  color: var(--muted-light);
  font-size: 12px;
  font-weight: 700;
}

.kpi h3 {
  margin: 7px 0 0;
  font-size: 1.18rem;
  color: #f5fbff;
}

.chart-card {
  background: linear-gradient(165deg, rgba(11, 41, 63, 0.97) 0%, rgba(7, 33, 48, 0.97) 100%);
  border: 1px solid var(--line-dark);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.table-card {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  border: 1px solid #cbd9e6;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(5, 21, 35, 0.2);
  padding: 14px;
  color: var(--text-dark);
}

.notes-card {
  background: linear-gradient(180deg, #f7fbff 0%, #f2f8fd 100%);
  border: 1px solid #cbd9e6;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(5, 21, 35, 0.16);
  padding: 14px;
  color: var(--text-dark);
}

.card-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.card-head p {
  margin: 4px 0 0;
  color: var(--muted-light);
  font-size: 13px;
}

.table-card .card-head p,
.notes-card .card-head p {
  color: var(--muted-dark);
}

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(247, 251, 255, 0.92) 100%);
  padding-bottom: 10px;
}

#trendCanvas {
  display: block;
  width: 100%;
  height: 340px;
  border-radius: 12px;
  border: 1px solid var(--line-dark);
  background: linear-gradient(180deg, #123b59 0%, #0a2b43 100%);
  margin-top: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: 68vh;
  border: 1px solid var(--line-light);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1320px;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  background: #eaf2f8;
  z-index: 10;
  color: var(--brand-navy-2);
}

th,
td {
  border-bottom: 1px solid var(--line-light);
  border-right: 1px solid var(--line-light);
  padding: 8px;
  vertical-align: middle;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th:first-child,
td:first-child {
  width: 360px;
  position: sticky;
  left: 0;
  z-index: 8;
  background: #ffffff;
}

thead th:first-child {
  z-index: 18;
  background: #eaf2f8;
}

tbody td {
  font-size: 13px;
}

tbody tr.section-head td {
  background: #dce9f4;
  color: #143554;
  font-weight: 800;
}

tbody tr.calc-row td {
  background: #eef5fb;
  color: #163a57;
  font-weight: 700;
}

tbody tr.warning-row td {
  background: #fff4de;
}

tbody tr.negative td.value-cell.calc {
  background: var(--danger-soft);
  color: var(--danger);
}

.row-label {
  font-weight: 700;
}

.value-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.value-cell .input-money {
  width: 100%;
  text-align: right;
  padding: 6px 8px;
  border-radius: 8px;
}

.value-cell.calc {
  background: #f4f9fd;
}

.value-cell.percent {
  font-family: "IBM Plex Mono", monospace;
}

.notes-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted-dark);
  line-height: 1.45;
}

@media (max-width: 1000px) {
  .app-shell {
    width: calc(100% - 10px);
    margin: 6px auto 14px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-wrap: wrap;
  }

  th:first-child,
  td:first-child {
    width: 240px;
  }
}
