/* KimiXL design system — light mode. Chart series colors are the validated
   dataviz palette slots (blue #2a78d6, orange #eb6834); app chrome is navy. */
:root {
  --ink: #16222e;
  --ink-2: #46525e;
  --muted: #6e7b87;
  --line: #e3e8ee;
  --line-strong: #c9d2db;
  --accent: #0b5cad;
  --accent-dark: #094a8a;
  --accent-wash: #eaf2fb;
  --bg: #f4f6f9;
  --card: #ffffff;
  --chart-surface: #fcfcfb;
  --nav-1: #0d2b45;
  --nav-2: #14406a;
  --good: #006300;
  --bad: #b3261e;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 34, 51, 0.06), 0 2px 8px rgba(16, 34, 51, 0.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
main { max-width: 1180px; margin: 0 auto; padding: 24px 28px 56px; }
h1 { font-size: 23px; font-weight: 650; letter-spacing: -0.2px; margin: 10px 0 6px; }
h2 { font-size: 16px; font-weight: 650; margin: 28px 0 8px; }
p { margin: 8px 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2f6; border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }

/* ---------- top navigation ---------- */
.topnav {
  display: flex; gap: 4px; align-items: center;
  background: linear-gradient(90deg, var(--nav-1), var(--nav-2));
  color: #fff; padding: 0 20px; min-height: 52px;
  box-shadow: 0 1px 3px rgba(9, 24, 38, 0.25);
  position: sticky; top: 0; z-index: 50;
  flex-wrap: wrap;
}
.topnav a {
  color: #b8cde0; text-decoration: none; padding: 15px 10px 13px;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.topnav a:hover { color: #fff; text-decoration: none; }
.topnav a.active { color: #fff; border-bottom-color: #7db4e8; }
.topnav .brand {
  font-weight: 700; color: #fff; font-size: 17px; letter-spacing: 0.2px;
  display: inline-flex; align-items: center; gap: 9px; margin-right: 14px; padding-left: 0;
  border-bottom-color: transparent !important;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #2a78d6, #123a5c);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.nav-user { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav-user .who { color: #8fa9c2; font-size: 12px; padding: 0 8px; }
.topnav button.link { color: #b8cde0; text-decoration: none; padding: 4px 8px; }
.topnav button.link:hover { color: #fff; }

.footer {
  color: var(--muted); font-size: 12px; border-top: 1px solid var(--line);
  margin-top: 40px; padding: 12px 28px; max-width: 1180px; margin-left: auto; margin-right: auto;
}

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; background: var(--card); margin-top: 12px;
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { border-style: hidden; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 12px; text-align: left; }
th {
  background: #f7f9fb; font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--ink-2);
}
tbody tr:hover td { background: #f7fafd; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bold { font-weight: 700; }
.muted { color: var(--muted); }

/* financial statement grid */
table.report td { padding: 6px 12px; }
table.report tbody tr:hover td { background: var(--accent-wash); }
.row-header td { background: #eef3f9; font-weight: 650; color: #123a5c; }
.row-subtotal td { border-top: 2px solid var(--line-strong); font-variant-numeric: tabular-nums; }
.dept-row td { background: #fafbfc; color: var(--ink-2); }

/* ---------- buttons & links ---------- */
.btn {
  display: inline-block; padding: 6px 14px; border: 1px solid var(--accent);
  border-radius: 6px; color: var(--accent); background: var(--card); text-decoration: none;
  cursor: pointer; font: inherit; font-weight: 500; margin: 2px 6px 2px 0;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--accent-wash); text-decoration: none; box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
button.link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  padding: 0; font: inherit;
}
button.link:hover { text-decoration: underline; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.actions a, .actions form { margin-right: 10px; }

/* ---------- forms ---------- */
form.filters {
  margin: 14px 0; display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow);
}
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius); margin: 16px 0;
  background: var(--card); padding: 14px 18px 16px; box-shadow: var(--shadow);
}
legend { font-weight: 650; padding: 0 6px; font-size: 13px; color: var(--ink-2); }
fieldset label { display: block; margin: 8px 0; }
input, select {
  font: inherit; padding: 5px 8px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #9ec5f4; outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

.flash {
  background: #eef9ee; border: 1px solid #bfe3bf; border-left: 4px solid #2e9e2e;
  padding: 10px 14px; border-radius: 6px; margin: 10px 0;
}
.error {
  background: #fdf0ee; border: 1px solid #f0c4bf; border-left: 4px solid #d03b3b;
  color: #8c2420; padding: 10px 14px; border-radius: 6px; margin: 10px 0;
}
.error-text { color: #8c2420; }

/* ---------- dashboard ---------- */
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head .spacer { flex: 1; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 14px 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 12px; box-shadow: var(--shadow);
}
.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.4px; margin: 4px 0 2px; }
.stat .delta { font-size: 12px; color: var(--muted); }
.stat .delta .up { color: var(--good); font-weight: 600; }
.stat .delta .down { color: var(--bad); font-weight: 600; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px 0 18px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--chart-surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 8px; box-shadow: var(--shadow);
}
.chart-card h3 { margin: 0 0 2px; font-size: 13.5px; font-weight: 650; }
.chart-card .sub { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-card .bar { transition: opacity 0.1s; }
.chart-card .bar:hover { opacity: 0.75; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 8px; font-size: 13.5px; font-weight: 650; }
.panel ul { margin: 6px 0; padding-left: 0; list-style: none; }
.panel li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.panel li:last-child { border-bottom: none; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 10px;
  padding: 1px 9px; background: var(--accent-wash); color: var(--accent-dark);
  vertical-align: middle; margin-left: 6px;
}
.tag.sap { background: #fdeee6; color: #a4431a; }

/* ---------- report library cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: box-shadow 0.12s, transform 0.12s;
}
.card:hover { box-shadow: 0 4px 14px rgba(16, 34, 51, 0.12); transform: translateY(-1px); }
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 650; }
.card h3 a { color: var(--ink); }
.card h3 a:hover { color: var(--accent); text-decoration: none; }
.card .desc { color: var(--muted); font-size: 12.5px; flex: 1; margin: 0 0 10px; }
.card .card-actions { display: flex; gap: 12px; align-items: center; font-size: 13px; }

/* ---------- report designer rows ---------- */
.rrow { display: flex; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px dotted var(--line); flex-wrap: wrap; }
.rrow .f-label input { width: 260px; }
.rrow .f-eps input { width: 110px; }
.rtype-header .f-range, .rtype-header .f-ranges, .rtype-header .f-sign, .rtype-header .f-basis,
.rtype-header .f-subtotal, .rtype-header .f-eps, .rtype-header .f-indent, .rtype-header .f-bold { display: none; }
.rtype-subtotal .f-range, .rtype-subtotal .f-ranges, .rtype-subtotal .f-sign, .rtype-subtotal .f-basis,
.rtype-subtotal .f-eps { display: none; }
.rtype-eps .f-range, .rtype-eps .f-ranges, .rtype-eps .f-sign, .rtype-eps .f-basis,
.rtype-eps .f-subtotal, .rtype-eps .f-bold { display: none; }
.rtype-accounts .f-label, .rtype-accounts .f-ranges, .rtype-accounts .f-sign, .rtype-accounts .f-basis,
.rtype-accounts .f-subtotal, .rtype-accounts .f-eps, .rtype-accounts .f-indent, .rtype-accounts .f-bold { display: none; }
.rtype-data .f-range, .rtype-data .f-subtotal, .rtype-data .f-eps { display: none; }

/* ---------- auth ---------- */
.login-body {
  background: linear-gradient(160deg, #0d2b45 0%, #14406a 55%, #1c5c94 100%);
  min-height: 100vh; margin: 0;
}
.login-page {
  max-width: 400px; margin: 9vh auto 40px; background: var(--card);
  border-radius: 12px; padding: 30px 34px 26px;
  box-shadow: 0 12px 40px rgba(5, 18, 31, 0.45);
}
.login-page h1 { display: flex; align-items: center; gap: 10px; margin-top: 0; }
.login-page h1 .brand-mark { width: 32px; height: 32px; font-size: 17px; }
.login-form label { display: block; margin: 12px 0; }
.login-form input { width: 100%; padding: 8px 10px; }
.login-form .btn { width: 100%; margin-top: 14px; padding: 9px; }
form.inline { display: inline; }
.token-box {
  display: inline-block; padding: 10px 14px; background: #f4f6f8;
  border: 1px solid var(--line-strong); border-radius: 6px; font-size: 14px; user-select: all;
}
.demo-accounts { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 14px; }
.demo-accounts form { margin: 8px 0; }
.demo-btn {
  width: 100%; text-align: left; padding: 9px 13px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 6px; background: #fbfcfe; font: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.demo-btn:hover { background: var(--accent-wash); border-color: var(--accent); }
.demo-btn .muted { font-weight: normal; font-size: 12px; }

/* ---------- data sources ---------- */
.source-form label { display: block; margin: 8px 0; }
.source-form input[type="text"], .source-form input[type="password"], .source-form input[type="number"] { min-width: 260px; }
