/* ============================================================
   GEKTO Reports — unified report chrome (layout from the
   Claude-Design redesign, RECONCILED to the brand palette).

   NO palette here: all colors come from gekto-theme.css brand
   tokens (deep teal --g-primary #0F766E, true green --g-success,
   true red --g-danger). We only add the chart-series vars the
   theme doesn't already define, mapped onto brand tokens.

   Everything is scoped under `.rpt-scope` and Bootstrap-colliding
   class names (.btn/.card) are renamed `.rpt-*` so none of this
   fights KaiAdmin/Bootstrap overrides in app.css.
   ============================================================ */

:root {
  /* chart series — mapped to brand tokens */
  --c-pos: var(--g-success);
  --c-pos-soft: #5EC4B5;
  --c-neg: var(--g-danger);
  --c-line: var(--g-primary);
  --c-axis: var(--g-text-tertiary);
}
[data-theme="dark"] {
  /* gekto-theme already brightens --g-success/--g-danger/--g-primary
     for dark; the chart vars inherit those automatically. Soft slice
     tint is the only one that needs a darker value. */
  --c-pos-soft: #2C7A70;
}

/* ---------- Scope root ---------- */
.rpt-scope { font-variant-numeric: normal; }
.rpt-scope .tabular { font-variant-numeric: tabular-nums; }

/* ---------- Report header ---------- */
.rpt-scope .rpt-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.rpt-scope .rpt-head-titles { min-width: 0; }
.rpt-scope .rpt-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--g-text-tertiary);
  margin-bottom: 6px;
}
.rpt-scope .rpt-title {
  font-size: 26px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--g-text-primary);
}
.rpt-scope .rpt-sub {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--g-text-secondary);
}
.rpt-scope .rpt-sub strong { color: var(--g-text-primary); font-weight: 600; }
.rpt-scope .rpt-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons (renamed to dodge Bootstrap .btn) ---------- */
/* Buttons harmonised with the app-wide .btn (8px radius, 8/16 padding,
   primary hover lift+shadow) so reports match the rest of the product. */
.rpt-scope .rpt-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--g-radius);
  padding: 8px 16px;
  border: 1px solid var(--g-border);
  background: var(--g-bg-card);
  color: var(--g-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--g-transition);
  white-space: nowrap;
}
.rpt-scope .rpt-btn:hover { background: var(--g-gray-50); color: var(--g-text-primary); border-color: var(--g-gray-300); }
.rpt-scope .rpt-btn svg { width: 15px; height: 15px; }
.rpt-scope .rpt-btn-primary { background: var(--g-primary); border-color: var(--g-primary); color: #fff; }
.rpt-scope .rpt-btn-primary:hover {
  background: var(--g-primary-dark);
  border-color: var(--g-primary-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--g-shadow);
}

/* ---------- Period / filter toolbar ---------- */
.rpt-scope .toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--g-bg-card);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  box-shadow: var(--g-shadow-sm);
  margin-bottom: 22px;
}
.rpt-scope .toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--g-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rpt-scope .toolbar .divider { width: 1px; align-self: stretch; background: var(--g-border); margin: 2px 0; }
.rpt-scope .toolbar .grow { flex: 1; }

/* Segmented control — shared component (un-scoped so dashboard + reports
   use the identical control). The single standard period selector. */
.seg {
  display: inline-flex;
  background: var(--g-gray-100);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.seg button,
.seg > a {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--g-text-secondary);
  padding: 6px 13px;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--g-transition);
  text-decoration: none;
  line-height: 1.4;
}
.seg button:hover,
.seg > a:hover { color: var(--g-text-primary); }
.seg button.active,
.seg > a.active {
  background: var(--g-bg-card);
  color: var(--g-primary);
  box-shadow: var(--g-shadow-sm);
}

.rpt-scope .field { display: inline-flex; flex-direction: column; gap: 3px; }
.rpt-scope .field label { font-size: 11px; color: var(--g-text-tertiary); font-weight: 500; }
.rpt-scope .field input, .rpt-scope .field select {
  font: inherit; font-size: 13px;
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius-sm);
  padding: 6px 10px;
  background: var(--g-bg-card);
  color: var(--g-text-primary);
}
.rpt-scope .field input:focus, .rpt-scope .field select:focus {
  outline: none; border-color: var(--g-primary);
  box-shadow: 0 0 0 3px var(--g-primary-50);
}

/* ---------- KPI strip ---------- */
.rpt-scope .kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.rpt-scope .kpi {
  background: var(--g-bg-card);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius);
  padding: 16px 18px;
  box-shadow: var(--g-shadow-sm);
  position: relative;
  overflow: hidden;
}
.rpt-scope .kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--g-primary); opacity: 0; transition: opacity var(--g-transition);
}
.rpt-scope .kpi.accent::before { opacity: 1; }
.rpt-scope .kpi-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--g-text-tertiary); margin-bottom: 8px;
}
.rpt-scope .kpi-value {
  font-size: 23px; font-weight: 620; letter-spacing: -0.02em;
  color: var(--g-text-primary); line-height: 1.15;
}
.rpt-scope .kpi-value .cur { font-size: 13px; font-weight: 500; color: var(--g-text-tertiary); margin-left: 4px; }
.rpt-scope .kpi-foot { margin-top: 7px; font-size: 12.5px; color: var(--g-text-secondary); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.rpt-scope .delta { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.rpt-scope .delta.up { color: var(--g-success); }
.rpt-scope .delta.down { color: var(--g-danger); }
.rpt-scope .delta svg { width: 13px; height: 13px; }

/* ---------- Cards (renamed to dodge Bootstrap .card) ---------- */
.rpt-scope .rpt-card {
  background: var(--g-bg-card);
  border: 1px solid var(--g-border);
  border-radius: var(--g-radius-lg);
  box-shadow: var(--g-shadow-sm);
  margin-bottom: 22px;
  overflow: hidden;
}
.rpt-scope .rpt-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--g-border-light);
}
.rpt-scope .rpt-card-head h3 { margin: 0; font-size: 15px; font-weight: 640; letter-spacing: -0.01em; color: var(--g-text-primary); }
.rpt-scope .rpt-card-head .hint { font-size: 12.5px; color: var(--g-text-tertiary); font-weight: 400; margin-top: 2px; }
.rpt-scope .rpt-card-body { padding: 8px 10px; }
.rpt-scope .rpt-card-body.pad { padding: 20px 22px; }

.rpt-scope .cols { display: grid; gap: 22px; }
.rpt-scope .cols-2-1 { grid-template-columns: 2fr 1fr; }
.rpt-scope .cols-1-1 { grid-template-columns: 1fr 1fr; }

/* ---------- Statement table ---------- */
.rpt-scope .stmt { width: 100%; border-collapse: collapse; }
.rpt-scope .stmt td { padding: 9px 22px; font-size: 14px; vertical-align: middle; color: var(--g-text-primary); }
.rpt-scope .stmt .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 180px; }
.rpt-scope .stmt .pct { text-align: right; width: 72px; color: var(--g-text-tertiary); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.rpt-scope .stmt tr.group { cursor: pointer; }
.rpt-scope .stmt tr.group td { font-weight: 600; }
.rpt-scope .stmt tr.group:hover td { background: var(--g-gray-50); }
.rpt-scope .stmt tr.subtotal td { border-top: 1px solid var(--g-border); font-weight: 680; }
.rpt-scope .stmt tr.total td {
  border-top: 1.5px solid var(--g-gray-400);
  border-bottom: 1.5px solid var(--g-gray-400);
  font-weight: 740; font-size: 15.5px; padding-top: 13px; padding-bottom: 13px;
}
.rpt-scope .stmt tr.total.pos .num { color: var(--g-primary); }
.rpt-scope .stmt tr.detail td { padding-top: 7px; padding-bottom: 7px; color: var(--g-text-secondary); font-size: 13.5px; }
.rpt-scope .stmt tr.detail td:first-child { padding-left: 46px; }
.rpt-scope .stmt tr.detail.nav { cursor: pointer; }
.rpt-scope .stmt tr.detail.nav:hover td { background: var(--g-primary-50); }
.rpt-scope .stmt tr.detail.nav:hover td:first-child { color: var(--g-primary); }
.rpt-scope .stmt .neg { color: var(--g-danger); }
.rpt-scope .stmt .spacer td { padding: 5px 0; border: none; }
.rpt-scope .chev {
  display: inline-block; width: 14px; transition: transform var(--g-transition);
  color: var(--g-text-tertiary); margin-right: 8px; font-size: 11px;
}
.rpt-scope .chev.open { transform: rotate(90deg); }
.rpt-scope .stmt .sec-label td {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--g-text-tertiary); padding-top: 16px; padding-bottom: 4px;
}

/* ---------- Plain data table ---------- */
.rpt-scope .tbl { width: 100%; border-collapse: collapse; }
.rpt-scope .tbl thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--g-text-tertiary);
  padding: 10px 16px; border-bottom: 1px solid var(--g-border);
  white-space: nowrap;
}
.rpt-scope .tbl thead th.num, .rpt-scope .tbl tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rpt-scope .tbl tbody td { padding: 11px 16px; font-size: 13.5px; border-bottom: 1px solid var(--g-border-light); color: var(--g-text-primary); }
.rpt-scope .tbl tbody tr:last-child td { border-bottom: none; }
.rpt-scope .tbl tbody tr.clickable { cursor: pointer; }
.rpt-scope .tbl tbody tr.clickable:hover td { background: var(--g-primary-50); }
.rpt-scope .tbl .muted { color: var(--g-text-tertiary); }
.rpt-scope .tbl .pos { color: var(--g-success); }
.rpt-scope .tbl .neg { color: var(--g-danger); }
.rpt-scope .tbl tr.row-total td { font-weight: 680; border-top: 1px solid var(--g-border); }
.rpt-scope .tbl .cell-sub { font-size: 12px; color: var(--g-text-tertiary); margin-top: 2px; }

.rpt-scope .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

/* ---------- Chart ---------- */
.rpt-scope .chart { width: 100%; }

/* ---------- Badge / pill ---------- */
.rpt-scope .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.rpt-scope .pill-ok { background: color-mix(in srgb, var(--g-success) 14%, transparent); color: var(--g-success); }
.rpt-scope .pill-warn { background: color-mix(in srgb, var(--g-warning) 16%, transparent); color: var(--g-warning); }
.rpt-scope .pill svg { width: 14px; height: 14px; }

/* ---------- Empty / error ---------- */
.rpt-scope .rpt-empty { padding: 40px 20px; text-align: center; color: var(--g-text-tertiary); font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .rpt-scope .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .rpt-scope .cols-2-1, .rpt-scope .cols-1-1 { grid-template-columns: 1fr; }
}
@media (max-width: 575px) {
  .rpt-scope .kpi-grid { grid-template-columns: 1fr; }
  .rpt-scope .field, .rpt-scope .field input, .rpt-scope .field select { width: 100%; }
  .rpt-scope .toolbar { gap: 10px; }
  .rpt-scope .stmt td { padding-left: 14px; padding-right: 14px; }
  .rpt-scope .stmt tr.detail td:first-child { padding-left: 30px; }
}

/* Wide tables scroll horizontally on small screens */
.rpt-scope .rpt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rpt-scope .rpt-scroll .tbl, .rpt-scope .rpt-scroll .stmt { min-width: 560px; }

/* Drill-down: a document reference inside a report row that opens the source
   document. Kept subtle — color + hover underline, like a link. */
.rpt-scope .doc-link { cursor: pointer; color: var(--g-brand, #17827c); }
.rpt-scope .doc-link:hover { text-decoration: underline; }

/* Report body while the next dataset loads: dim + freeze interactions. */
.rpt-scope.is-loading { opacity: 0.55; pointer-events: none; transition: opacity 0.15s ease; }
