:root {
  color-scheme: light;
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface-2: #e8f1f7;
  --ink: #0a263c;
  --muted: #607789;
  --line: #d4e1ea;
  --primary: #003a63;
  --primary-2: #0b4f7d;
  --accent: #b94b36;
  --warning: #b97719;
  --good: #1e7a68;
  --shadow: 0 18px 45px rgba(0, 58, 99, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--primary);
  color: #f4f9fc;
  padding: 24px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary);
  font-weight: 800;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #bfd6e6;
  margin-top: 3px;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d6e8f3;
  text-align: left;
}

.nav-tab span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #9fc4db;
}

.nav-tab.is-active,
.nav-tab:hover {
  background: #0a4d7a;
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.16rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.range-form {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(160px, auto) minmax(110px, auto) minmax(220px, auto) auto;
  align-items: end;
  gap: 10px;
}

.period-field.is-hidden {
  display: none;
}

.period-summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 900;
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
}

.icon-button,
.text-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  background:
    linear-gradient(rgba(0, 58, 99, 0.86), rgba(0, 58, 99, 0.86)),
    url("/assets/rtg-logo.png") center 38% / 360px auto no-repeat,
    var(--primary);
}

.login-shell {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand .eyebrow {
  margin-bottom: 2px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form button {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 800;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.secondary {
  background: #ffffff;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.connector-card,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 1.55rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.liquidity-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
}

.panel,
.connector-card {
  padding: 18px;
}

.visual-panel {
  margin-bottom: 18px;
}

.chart-panel {
  min-height: 380px;
}

.bar-chart {
  display: flex;
  align-items: end;
  gap: 22px;
  min-height: 285px;
  padding-top: 24px;
  overflow-x: auto;
}

.bar-group {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  min-width: 78px;
  height: 240px;
}

.bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 8px;
  height: 205px;
  border-bottom: 1px solid var(--line);
}

.bar {
  width: 24px;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
}

.bar.revenue {
  background: var(--good);
}

.bar.expense {
  background: var(--accent);
}

.bar-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.leaderboard {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.leader-row,
.rank-list,
.rank-row {
  display: grid;
  gap: 8px;
}

.rank-list {
  margin-top: 16px;
}

.leader-line,
.rank-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.rank-line span {
  color: var(--primary);
  font-weight: 900;
  white-space: nowrap;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.section-heading {
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.compact-select {
  min-width: 230px;
}

.compact-select input,
.compact-select select {
  width: 100%;
}

.table-wrap {
  overflow: auto;
}

.employee-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.employee-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.employee-card.is-risk {
  border-color: rgba(185, 75, 54, 0.35);
}

.employee-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.employee-card-top h3 {
  margin: 8px 0 4px;
  font-size: 1.1rem;
}

.employee-card-top p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.employee-card-actions,
.action-cell {
  display: flex;
  gap: 8px;
}

.employee-card-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.employee-card-kpis div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.employee-card-kpis span,
.employee-card-kpis strong {
  display: block;
}

.employee-card-kpis span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.employee-card-kpis strong {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.employee-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 14px 0 0;
}

.employee-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.employee-breakdown dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.employee-breakdown dd {
  margin: 0;
  font-weight: 900;
  text-align: right;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.feature-list span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 900;
}

.icon-button.danger {
  border-color: rgba(185, 75, 54, 0.35);
  color: var(--accent);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-weight: 800;
}

.compact-table table {
  min-width: 620px;
}

.donut-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  margin-top: 18px;
}

.donut-chart {
  display: grid;
  place-items: center;
  align-content: center;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  position: relative;
  background: var(--surface-2);
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 48px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-chart span,
.donut-chart small {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
}

.donut-chart span {
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
}

.donut-chart small {
  color: var(--muted);
  font-weight: 800;
}

.chart-legend {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend-row strong {
  overflow-wrap: anywhere;
}

.legend-row em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.timeline-list {
  display: grid;
  gap: 0;
  margin-top: 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  position: relative;
  min-width: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7px;
  width: 2px;
  background: var(--line);
}

.timeline-item:first-child::before {
  top: 14px;
}

.timeline-item:last-child::before {
  bottom: calc(100% - 14px);
}

.timeline-marker {
  z-index: 1;
  width: 16px;
  height: 16px;
  margin-top: 12px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--line);
}

.timeline-item.is-urgent .timeline-marker {
  background: var(--accent);
}

.timeline-card {
  min-width: 0;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.timeline-main,
.timeline-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timeline-main span {
  color: var(--primary);
  font-weight: 900;
  white-space: nowrap;
}

.timeline-meta {
  flex-wrap: wrap;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.budget-bars {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.budget-bar-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(240px, 1.4fr) 70px;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.budget-bar-label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.budget-bar-label strong {
  overflow-wrap: anywhere;
}

.budget-bar-label span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.budget-track {
  position: relative;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.budget-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--good);
}

.budget-fill.is-over {
  background: var(--accent);
}

.budget-track i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 100%;
  width: 2px;
  background: var(--ink);
  opacity: 0.35;
}

.budget-bar-meta {
  font-weight: 900;
  text-align: right;
}

.forecast-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.forecast-row {
  display: grid;
  grid-template-columns: 120px minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.forecast-label {
  display: grid;
  gap: 4px;
}

.forecast-label span {
  font-size: 0.9rem;
  font-weight: 900;
}

.forecast-bars {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.cash-bar {
  display: flex;
  align-items: center;
  min-width: 52px;
  height: 20px;
  padding-left: 8px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
}

.cash-bar.in {
  background: var(--good);
}

.cash-bar.out {
  background: var(--accent);
}

.cash-bar i {
  font-style: normal;
  white-space: nowrap;
}

.open-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.open-summary div,
.issue-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.open-summary div {
  padding: 12px;
}

.open-summary span,
.open-summary strong {
  display: block;
}

.open-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.open-summary strong {
  margin-top: 5px;
  color: var(--ink);
}

.issue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.issue-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.issue-card.is-hot {
  border-color: rgba(185, 75, 54, 0.35);
  background: #fff4f1;
}

.issue-card strong,
.issue-card small {
  overflow-wrap: anywhere;
}

.issue-card div {
  font-size: 1.6rem;
  font-weight: 900;
}

.issue-card small {
  color: var(--muted);
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.person-cell strong,
.person-cell small {
  display: block;
}

.person-cell small,
.muted {
  color: var(--muted);
}

.amount-cell {
  text-align: right;
}

.negative {
  color: var(--accent);
}

.positive {
  color: var(--good);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary-2);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.is-warning {
  background: #fff4f1;
  color: var(--accent);
}

.connector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.connector-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.connector-card p {
  color: var(--muted);
}

.connector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--primary-2);
  font-weight: 900;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

dl {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

dl div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
}

dt {
  color: var(--muted);
  font-weight: 900;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.rules-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.rule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.insight-summary {
  display: grid;
  min-width: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.insight-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.insight-summary strong {
  margin-top: 4px;
  font-size: 1.25rem;
}

.tips-list {
  display: grid;
  gap: 12px;
}

.tip-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tip-card p {
  margin-bottom: 8px;
  color: var(--muted);
}

.tip-card h3,
.tip-card p,
.tip-card small {
  overflow-wrap: anywhere;
}

.tip-card small {
  color: var(--primary-2);
  font-weight: 800;
}

.tip-impact {
  display: grid;
  align-content: center;
  min-width: 140px;
  text-align: left;
}

.tip-impact span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tip-impact strong {
  color: var(--good);
  font-size: 1.2rem;
}

dialog {
  width: min(780px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 36, 33, 0.4);
}

.dialog-form {
  display: grid;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav-tabs {
    display: flex;
    overflow-x: auto;
  }

  .nav-tab {
    flex: 0 0 auto;
    width: auto;
  }

  .workspace {
    padding: 20px;
  }

  .kpi-grid,
  .dashboard-grid,
  .analysis-grid,
  .liquidity-grid,
  .employee-grid,
  .issue-grid,
  .connector-grid,
  .rules-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar,
  .topbar-actions,
  .section-heading,
  .panel-heading,
  .range-form {
    align-items: stretch;
    flex-direction: column;
  }

  .range-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .period-summary {
    justify-content: center;
  }

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

  .section-actions,
  .tip-card,
  .donut-layout,
  .budget-bar-row,
  .forecast-row,
  .open-summary,
  .employee-card-kpis,
  .employee-breakdown {
    grid-template-columns: 1fr;
  }

  .tip-impact {
    text-align: left;
  }

  .budget-bar-meta {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .range-form {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .metric-card strong {
    font-size: 1.3rem;
  }
}
