:root {
  /* Palette comes from home.css so the theme switch reaches this page.
     Redeclaring --bg and friends here would override it, because this
     stylesheet loads second. */
  /* Slightly tighter vertical rhythm across the page (~10% reduction) */
  --section-gap: 13px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 700px at 30% 10%, var(--bg-glow) 0%, var(--bg) 55%);
  color: var(--text);
}

.container {
  max-width: 1060px;
  margin: 0 auto;
  /* Add top padding so the fixed logo does not overlap content */
  /* Reduce overall container vertical footprint (additional ~15%) */
  padding: 17px 14px 23px;
}

.header h1 { margin: 0 0 5px; font-size: 26px; }
.sub { margin: 0; color: var(--muted); }

/* Header layout: text left, logo right */
.header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.header-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.header-logo {
  margin-left: auto;
  width: min(312px, 70vw);
  max-width: none;
  object-fit: contain;
  /* Fallback height (JS will sync it to title+sentence height) */
  height: 60px;
}

@media (max-width: 520px) {
  .header-bar {
    flex-direction: column;
  }
  .header-logo {
    align-self: flex-end;
    height: 52px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-top: 14px;
  box-shadow: 0 18px 50px var(--shadow);
}

/* Reduce gap between page header and first card (inputs section) */
.header + .card { margin-top: 8px; }


.card h2 { margin: 0 0 var(--section-gap); font-size: 18px; }

/* Default 3 columns for laptop/desktop; degrade to 2 then 1 on smaller screens */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}

/* Tighten vertical spacing in the main inputs area (requested) */
.inputs-grid {
  row-gap: 8px;
}
.inputs-grid .field {
  gap: 5px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
}

.field { display: grid; gap: 6px; }
.field span { color: var(--muted); font-size: 13px; }
.field input, .field select {
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(var(--ink-rgb), 0.04);
  color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus { border-color: rgba(var(--ink-rgb), 0.22); }

.hint { color: rgba(var(--text-rgb), 0.65); font-size: 12px; }

.row {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 11px;
}

.inline { min-width: 220px; }

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 13px;
  margin-bottom: var(--section-gap);
}

button {
  border: 0;
  padding: 9px 13px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}
.primary { background: var(--accent); color: white; }
.secondary { background: rgba(var(--ink-rgb), 0.08); color: var(--text); border: 1px solid var(--line); }

.disclaimer {
  margin: 11px 0 0;
  color: rgba(var(--text-rgb), 0.62);
  font-size: 12px;
  line-height: 1.4;
}

.results {
  display: grid;
  /* Desktop: 4 KPIs per row */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

/* Responsive fallbacks */
@media (max-width: 1050px) {
  .results { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .results { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 560px) {
  .results { grid-template-columns: 1fr; }
}

.kpi {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(var(--ink-rgb), 0.03);
}
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 18px; margin-top: 5px; font-weight: 750; }

.net { border-color: var(--success-line); }

/* Net salary stays within the same KPI grid (4 per row on desktop) */

hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.breakdown h3 { margin: 0 0 9px; font-size: 14px; color: var(--muted); }
.breakdown dl { margin: 0; display: grid; gap: 7px; }
.breakdown dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(var(--ink-rgb), 0.02);
}
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; font-weight: 700; }

.errors {
  border: 1px solid var(--danger-line);
  background: var(--danger-fill);
  padding: 9px 11px;
  border-radius: 12px;
  margin-bottom: 11px;
  color: var(--danger-text);
}

.footer { margin-top: 13px; color: rgba(var(--text-rgb), 0.55); }
.header-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}
.brand h1 { margin: 0; }

/* Keep the title next to the logo on the right without wrapping */
.brand h1 { white-space: nowrap; }
.logo { flex-shrink: 0; }

.header-top h1 {
  margin: 0;
}
.logo {
  height: 54px;
  width: auto;
  opacity: 0.95;
}
@media (max-width: 720px) {
  .logo { height: 44px; }
}

/* Slightly larger logo on the password (top-right) screen */
.auth-top .logo { height: 66px; }
@media (max-width: 720px) {
  .auth-top .logo { height: 54px; }
}

/* Keep field labels on one line to align inputs across the row */
.field span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Keep field labels on one line to align inputs across the row */
.field span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Password gate */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 18px 50px var(--shadow);
}
.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.auth-title h1 {
  margin: 0 0 4px;
  font-size: 22px;
}
.auth-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.auth-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}
.auth-error {
  margin-top: 10px;
  border: 1px solid var(--danger-line);
  background: var(--danger-fill);
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--danger-text);
}
.auth-note {
  margin: 12px 0 0;
  color: rgba(var(--text-rgb), 0.55);
  font-size: 12px;
  line-height: 1.4;
}

.hint-underline { text-decoration: underline; }

/* Navigation link back to iEnergy home */
.back-link {
  display: inline-block;
  margin-bottom: 7px;
  color: rgba(var(--text-rgb), 0.85);
  text-decoration: none;
  font-size: 13px;
}
.back-link:hover { text-decoration: underline; }


.actions.center { justify-content: center; }

.outputs .field input[readonly] {
  background: rgba(var(--ink-rgb), 0.02);
  opacity: 0.95;
}

/* Additional compacting: decrease overall page height by ~8% */
:root { --section-gap: 12px; }

.container { padding: 15px 14px 21px; }

.header + .card { margin-top: 6px; }

.card { padding: 15px; margin-top: 13px; }

.grid { gap: 10px; }

.inputs-grid { row-gap: 7px; }
.inputs-grid .field { gap: 4px; }

.actions { margin-top: 12px; }

button { padding: 8px 12px; }
