:root {
  color-scheme: light;
  --paper: #f4f5ef;
  --white: #fff;
  --ink: #202923;
  --muted: #78817a;
  --line: #e6e9e1;
  --green: #246b50;
  --green-soft: #e5f1e9;
  --coral: #d66c4d;
  --blue: #4e87a0;
  --yellow: #e3bb63;
  --serif: "DM Serif Display", Georgia, serif;
  --sans: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; display: flex; width: 236px; flex-direction: column; padding: 27px 17px 22px; background: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 9px 44px; font-size: 20px; font-weight: 700; letter-spacing: 0; }
.brand-mark { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 10px 10px 10px 3px; background: var(--green); color: #fff; font-family: var(--serif); font-size: 21px; font-weight: 400; }
.brand-period { color: var(--coral); }
.side-label, .breadcrumb, .eyebrow, .metric-label, th { font-size: 10px; font-weight: 700; letter-spacing: 0; }
.side-label { padding: 0 11px; color: #929b94; }
.main-nav { display: grid; gap: 5px; margin-top: 11px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 41px; padding: 0 11px; border-radius: 6px; color: #69736c; font-weight: 500; }
.nav-link:hover { background: #f6f8f4; color: var(--ink); }
.nav-link.active { background: var(--green-soft); color: var(--green); font-weight: 700; }
.nav-symbol { width: 18px; font-size: 17px; text-align: center; }
.sidebar-bottom { margin-top: auto; }
.source-card { display: flex; align-items: center; gap: 10px; margin: 11px 3px 0; padding: 12px 9px; border: 1px solid var(--line); border-radius: 6px; }
.source-dot, .metric-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.source-card strong, .source-card small { display: block; }
.source-card strong { font-size: 12px; font-weight: 600; }
.source-card small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.sidebar-note { margin: 12px 9px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.main-content { max-width: 1600px; min-height: 100vh; margin-left: 236px; padding: 0 42px; }
.topbar { display: flex; height: 64px; align-items: center; justify-content: space-between; border-bottom: 1px solid #e4e7df; }
.breadcrumb { color: #78817a; }
.breadcrumb span { padding: 0 7px; color: #b4bbb4; }
.topbar-right { display: flex; align-items: center; gap: 13px; }
.demo-pill, .mini-tag { padding: 6px 8px; border: 1px solid #eadfbf; border-radius: 3px; background: #faf5e6; color: #937337; font-size: 9px; font-weight: 700; letter-spacing: 0; }
.avatar { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 50%; background: #dce9df; color: var(--green); font-size: 12px; font-weight: 700; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 34px 0 24px; }
.eyebrow { margin: 0 0 9px; color: #8b958d; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: var(--serif); font-size: 36px; font-weight: 400; line-height: 1.13; letter-spacing: 0; }
.heading-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.button { display: inline-flex; min-height: 39px; align-items: center; justify-content: center; gap: 12px; padding: 0 15px; border: 0; border-radius: 5px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; }
.button-dark { background: var(--ink); color: #fff; }
.button-dark:hover { background: var(--green); }
.button-light { background: #fff; color: var(--ink); }
.button-light:hover { background: #edf3ed; }
.import-banner { display: flex; align-items: center; gap: 16px; min-height: 112px; padding: 18px 21px; border-radius: 7px; background: var(--green); color: #fff; }
.import-icon { display: grid; width: 43px; height: 43px; flex: 0 0 auto; place-items: center; border: 1px solid #ffffff65; border-radius: 50%; color: #e9d38f; font-size: 21px; }
.import-copy { flex: 1; }
.import-copy .eyebrow { margin-bottom: 6px; color: #bdd3c2; }
.import-copy h2 { margin: 0 0 4px; font-family: var(--serif); font-size: 20px; font-weight: 400; letter-spacing: 0; }
.import-copy p:last-child { margin: 0; color: #d6e2d8; font-size: 11px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.import-feedback { min-height: 30px; margin: 9px 0 14px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 15px; }
.overview-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card, .panel { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.metric-card { min-height: 114px; padding: 15px 17px 13px; }
.metric-label { display: flex; align-items: center; gap: 8px; color: #7d877f; }
.metric-dot { width: 7px; height: 7px; }
.metric-dot.green { background: var(--green); }
.metric-dot.coral { background: var(--coral); }
.metric-dot.blue { background: var(--blue); }
.metric-value { overflow: hidden; margin-top: 13px; font-size: 25px; font-weight: 600; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.metric-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; color: var(--muted); font-size: 10px; }
.metric-note { color: #a3aaa3; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(250px, 1fr); gap: 15px; }
.panel { padding: 18px 19px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-heading .eyebrow { margin-bottom: 6px; }
h2 { margin-bottom: 0; font-family: var(--serif); font-size: 20px; font-weight: 400; line-height: 1.2; letter-spacing: 0; }
.text-link { margin-top: 6px; color: var(--green); font-size: 11px; font-weight: 600; white-space: nowrap; }
.text-link span { margin-left: 4px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 17px; margin-top: 21px; color: #66716a; font-size: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 8px; height: 8px; border-radius: 50%; }
.egp-swatch { background: var(--green); }
.usd-swatch { background: var(--coral); }
.chart-wrap { position: relative; height: 218px; margin-top: 9px; }
.chart-footnote { margin-top: 3px; color: #939b94; font-size: 10px; }
.rate-current { display: flex; align-items: baseline; gap: 8px; margin-top: 20px; }
.rate-current span { font-family: var(--serif); font-size: 32px; }
.rate-current small { color: var(--muted); font-size: 10px; }
.rate-chart-wrap { position: relative; height: 109px; margin-top: 4px; }
.muted-note { margin: 10px 0 0; color: #929b94; font-size: 10px; line-height: 1.55; }
.page-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 24px; padding: 15px 0 20px; border-top: 1px solid #e4e7df; color: #929b94; font-size: 9px; letter-spacing: 0; }
.dashboard-heading { padding-bottom: 16px; }
.dashboard-heading .button { flex: 0 0 auto; }
.dashboard-feedback { min-height: 22px; margin: 0 0 7px; }
.dashboard-metrics { margin-bottom: 15px; }
.wide-chart-panel { padding-bottom: 15px; }
.dashboard-chart { height: 276px; }
.dashboard-lower { margin-top: 15px; }
.dashboard-lower .rate-panel, .table-panel { min-height: 248px; }
.dashboard-lower .rate-current { margin-top: 14px; }
.dashboard-lower .rate-chart-wrap { height: 100px; }
.table-scroll { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 0 8px 10px; color: #909992; white-space: nowrap; }
td { padding: 11px 8px; border-top: 1px solid #edf0eb; color: #58635b; font-size: 11px; white-space: nowrap; }
td:nth-child(2) { color: var(--muted); }
td:nth-child(3) { color: var(--ink); font-weight: 600; }
td:nth-child(4) { color: var(--coral); font-weight: 600; }

/* Modal / Portal View */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(32, 41, 35, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: var(--white);
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}
.modal-overlay.active .modal-card {
  transform: translateY(0);
}
.modal-header {
  padding: 24px 30px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.modal-close {
  background: var(--paper);
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
}
.modal-close:hover {
  background: #e8ebe4;
  color: var(--ink);
}
.modal-filters {
  padding: 15px 30px;
  background: #fbfbf9;
  border-bottom: 1px solid var(--line);
}
.portal-table-wrap {
  overflow-y: auto;
  padding: 0 30px 30px;      /* ← remove top padding so nothing sits above header */
  flex: 1;
}

.portal-table-wrap table {
  border-collapse: separate;  /* ← required for reliable sticky headers */
  border-spacing: 0;
}

.portal-table-wrap table th {
  position: sticky;
  top: 0;
  z-index: 2;                 /* ← above body rows */
  padding: 14px 8px 12px;
  background: #e2e6de;        /* your gray */
  color: #4a544c;
  font-weight: 700;
  border-bottom: 1px solid #d3d9cf;
  box-shadow: 0 1px 0 #d3d9cf;/* keeps the divider visible while scrolling */
}

.portal-table-wrap table th:first-child { border-top-left-radius: 8px; }
.portal-table-wrap table th:last-child  { border-top-right-radius: 8px; }

/* Make sure body cells never paint above the header */
.portal-table-wrap table td {
  background: var(--white);
  position: relative;
  z-index: 1;
}

@media (min-width: 1500px) {
  .main-content { margin-right: auto; padding-right: 56px; padding-left: 56px; }
}
@media (max-width: 1050px) {
  .main-content { padding: 0 25px; }
  .sidebar { width: 205px; }
  .main-content { margin-left: 205px; }
  .content-grid { grid-template-columns: minmax(0, 1.35fr) minmax(230px, 1fr); gap: 11px; }
  .panel { padding: 16px; }
  .overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: auto; height: auto; flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; font-size: 18px; }
  .brand-mark { width: 29px; height: 29px; }
  .side-label, .sidebar-bottom { display: none; }
  .main-nav { display: flex; gap: 3px; margin: 0; }
  .nav-link { min-height: 36px; gap: 6px; padding: 0 9px; font-size: 11px; }
  .nav-symbol { width: auto; font-size: 14px; }
  .main-content { margin-left: 0; padding: 0 18px; }
  .topbar { height: 51px; }
  .breadcrumb { font-size: 9px; }
  .topbar-right { gap: 8px; }
  .page-heading { align-items: flex-start; padding: 26px 0 18px; }
  h1 { font-size: 31px; }
  .page-heading > .button { align-self: center; }
  .heading-copy { max-width: 500px; font-size: 12px; }
  .import-banner { gap: 12px; padding: 15px; }
  .import-icon { width: 37px; height: 37px; }
  .import-copy h2 { font-size: 18px; }
  .import-copy p:last-child { max-width: 340px; line-height: 1.45; }
  .metric-grid { gap: 9px; }
  .metric-card { min-height: 105px; padding: 13px 11px 11px; }
  .metric-label { font-size: 9px; }
  .metric-value { font-size: 22px; }
  .content-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 220px; }
  .rate-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 15px; }
  .rate-panel .panel-heading, .rate-panel .muted-note { grid-column: 1 / -1; }
  .rate-panel .rate-current { align-self: center; }
  .rate-panel .rate-chart-wrap { height: 95px; }
  .dashboard-lower .rate-panel, .table-panel { min-height: 0; }
  .dashboard-chart { height: 230px; }
}
@media (max-width: 500px) {
  .main-content { padding: 0 13px; }
  .sidebar { padding: 11px 13px; }
  .brand { gap: 7px; font-size: 16px; }
  .brand-mark { width: 26px; height: 26px; border-radius: 8px 8px 8px 3px; font-size: 18px; }
  .nav-link { gap: 4px; padding: 0 7px; font-size: 10px; }
  .nav-symbol { font-size: 12px; }
  .demo-pill { padding: 5px 6px; font-size: 8px; }
  .avatar { width: 26px; height: 26px; }
  .page-heading { gap: 8px; }
  h1 { font-size: 28px; }
  .heading-copy { max-width: 300px; font-size: 11px; }
  .page-heading > .button { gap: 6px; min-height: 35px; padding: 0 9px; font-size: 10px; }
  .import-banner { flex-wrap: wrap; gap: 10px; }
  .import-copy { min-width: calc(100% - 55px); }
  .import-banner .button { margin-left: 47px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 101px; }
  .metric-growth { grid-column: 1 / -1; min-height: 91px; }
  .metric-value { font-size: 21px; }
  .metric-foot { font-size: 9px; }
  .panel { padding: 15px 13px; }
  h2 { font-size: 18px; }
  .chart-wrap { height: 190px; }
  .dashboard-chart { height: 210px; }
  .chart-legend { gap: 11px; font-size: 9px; }
  .page-footer { flex-direction: column; gap: 7px; }
}
/* Add-entry form */
.add-form {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 16px 18px;
  margin-bottom: 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
}
.add-form label {
  display: block;
}
.add-form label span {
  display: block;
  margin-bottom: 6px;
  color: #7d877f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.add-form input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}
.add-form input:focus {
  border-color: var(--green);
}
.add-form button {
  min-height: 38px;
}
.add-feedback {
  margin: -6px 0 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  min-height: 18px;
}
.add-feedback[data-state="error"]   { color: var(--coral); }
.add-feedback[data-state="success"] { color: var(--green); }
@media (max-width: 760px) {
  .add-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .add-form { grid-template-columns: 1fr; }
}
/* Filters bar */
.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 16px 18px;
  margin-bottom: 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
}
.filters label {
  display: block;
}
.filters label span {
  display: block;
  margin-bottom: 6px;
  color: #7d877f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.filters input,
.filters select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}
.filters input:focus,
.filters select:focus {
  border-color: var(--green);
}
.filters button {
  min-height: 38px;
}

/* Total earned card gets a highlighted treatment */
.metric-card.metric-total, .metric-card.metric-total-usd {
  background: #f9fbf7;
  border-color: #d8e4da;
}
.metric-card.metric-total .metric-value {
  color: var(--green);
}
.metric-card.metric-total-usd .metric-value {
  color: var(--coral);
}

/* Metric grid: Adjust columns when the total cards are present */
.metric-grid.has-total {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1050px) {
  .metric-grid.has-total { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  .metric-grid.has-total { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}