:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --amber-light: #fef3c7;
  --amber: #b45309;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  margin: 0;
  padding: 0 24px 40px;
  color: var(--text);
  background: #f4f6f9;
}

#app-header { padding: 20px 0 12px; }
.header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
#app-header h1 { margin: 0; font-size: 1.7em; letter-spacing: -0.02em; }
.privacy { color: var(--text-muted); font-size: 0.9em; margin: 4px 0 0; }
#status { color: var(--text-muted); font-style: italic; }

.lang-switch { display: flex; gap: 4px; margin-top: 4px; }
.lang-switch button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85em;
  color: #475569;
}
.lang-switch button.active { background: var(--blue); color: #fff; border-color: var(--blue); }

h2 { margin: 0 0 10px; font-size: 1.15em; color: #0f172a; }
h3 { margin: 0 0 4px; font-size: 1em; color: #0f172a; }
.section-title { margin: 28px 0 12px; font-size: 1.3em; }

.hint { color: var(--text-muted); font-size: 0.88em; margin: 0 0 12px; line-height: 1.5; }
.hint-inline { color: var(--text-muted); font-size: 0.85em; font-weight: normal; margin-left: 8px; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

table {
  border-collapse: collapse;
  margin-bottom: 8px;
  background: #fff;
  font-size: 0.92em;
}
.card table { margin-bottom: 0; }
td, th {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: right;
}
th, td:first-child { text-align: left; }
th { background: #f8fafc; font-weight: 600; color: #334155; }
tbody tr:nth-child(even) { background: #fbfcfe; }
tbody tr:hover { background: #eff4ff; }
tr.row-readonly td:not(:first-child) { color: #334155; }
tr.row-section td { background: #eef2ff; font-weight: 700; color: #1e3a8a; }

input[type=number], input[type=date], input[type=text] {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.95em;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
input[type=date] { width: 130px; }
.numfmt-input { width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.numfmt-input.narrow { width: 70px; }
select {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 3px;
}
.outputs td { font-variant-numeric: tabular-nums; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 0.95em;
  cursor: pointer;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

#recommendation {
  font-weight: 700;
  font-size: 1.15em;
  padding: 14px 18px;
  background: linear-gradient(90deg, #fff7ed, #fefce8);
  border: 1px solid #fde68a;
  border-radius: 10px;
  margin: 6px 0 18px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: 600;
}
.badge-pass { background: var(--green-light); color: #15803d; }
.badge-warn { background: var(--red-light); color: #b91c1c; }
.badge-good { background: var(--green-light); color: #15803d; }
.badge-bad { background: var(--red-light); color: #b91c1c; }

#kpi-cards, #cf-kpi-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
}
.kpi-card {
  flex: 1 1 160px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.kpi-value { font-size: 1.6em; font-weight: 700; color: var(--blue); letter-spacing: -0.01em; }
.kpi-label { color: var(--text-muted); font-size: 0.78em; margin-top: 6px; font-weight: 600; letter-spacing: 0.03em; }
.kpi-sub { color: #94a3b8; font-size: 0.78em; margin-top: 1px; }

.dashboard-head { margin-bottom: 14px; }
.dashboard-head .hint { margin: 4px 0 0; }
.dashboard-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

#top-nav {
  margin-bottom: 20px;
  border-bottom: 2px solid #0f172a;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
#top-nav button {
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  transition: background 0.15s;
}
#top-nav button.nav-input { background: var(--blue-light); }
#top-nav button.nav-result { background: var(--green-light); }
#top-nav button.active {
  font-weight: 700;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 -1px 0 #fff inset;
}
#npv-chart { max-height: 320px; }

.page { display: none; }
.page.active { display: block; animation: fadein 0.15s ease-in; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.table-scroll { max-height: 480px; overflow-y: auto; overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
.table-scroll.tall { max-height: 620px; }
.table-scroll table { margin-bottom: 0; }
.table-scroll th { position: sticky; top: 0; z-index: 1; }
.table-scroll td:first-child, .table-scroll th:first-child { position: sticky; left: 0; z-index: 2; background: #f8fafc; }
.table-scroll th:first-child { z-index: 3; }
