/* ===== VARIABLES ===== */
:root {
  --navy: #0f2b5b;
  --navy-light: #1a3d7c;
  --green: #00c853;
  --green-dark: #00a844;
  --red: #e53935;
  --white: #fff;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-400: #9aa0a6;
  --gray-600: #5f6368;
  --gray-800: #3c4043;
  --shadow: 0 2px 8px rgba(15,43,91,0.09);
  --shadow-h: 0 6px 20px rgba(15,43,91,0.14);
  --r: 12px;
  --r-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 56px;
  --tab-h: 48px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; min-height: 100vh; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ===== NAVBAR ===== */
.navbar {
  background: var(--navy);
  height: var(--nav-h);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; height: 100%;
  padding: 0 16px; display: flex; align-items: center; justify-content: space-between;
}
.logo { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -0.4px; user-select: none; }
.logo-accent { color: var(--green); }
.currency-wrapper { text-align: right; }
.currency-select {
  background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff; padding: 6px 30px 6px 10px; border-radius: 7px; font-size: 14px;
  font-weight: 600; outline: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='white' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  transition: border-color 0.2s;
}
.currency-select option { background: #0f2b5b; color: #fff; }
.currency-select:focus { border-color: var(--green); }
.auto-detect-text { font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 2px; text-align: right; }

/* ===== TAB BAR ===== */
.tab-bar {
  background: #fff; border-bottom: 2px solid var(--gray-200);
  position: sticky; top: var(--nav-h); z-index: 90;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; min-width: max-content; }
.tab-btn {
  background: none; border: none; padding: 14px 22px;
  font-size: 14px; font-weight: 500; color: var(--gray-600);
  white-space: nowrap; position: relative; transition: color 0.2s;
}
.tab-btn::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 3px; background: var(--navy); transform: scaleX(0);
  transition: transform 0.2s ease; border-radius: 2px 2px 0 0;
}
.tab-btn.active { color: var(--navy); font-weight: 700; }
.tab-btn.active::after { transform: scaleX(1); }
.tab-btn:hover:not(.active) { color: var(--navy-light); }

/* ===== MAIN ===== */
main { padding: 24px 0 48px; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.tool-section { display: none; }
.tool-section.active { display: block; animation: fadeIn 0.22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.tool-layout { display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }

/* ===== INPUTS PANEL ===== */
.inputs-panel {
  width: 100%; background: #fff; border-radius: var(--r); padding: 24px; box-shadow: var(--shadow);
}
.panel-title { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--gray-100); }
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--gray-400); }

/* Prefix input */
.input-prefix-wrap {
  display: flex; align-items: stretch; border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm); overflow: hidden; transition: border-color 0.2s, box-shadow 0.2s;
}
.input-prefix-wrap:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,43,91,0.09); }
.cs-prefix {
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px; background: var(--gray-50); border-right: 1.5px solid var(--gray-200);
  font-weight: 700; color: var(--gray-600); font-size: 14px; white-space: nowrap; min-width: 38px;
}
.input-prefix-wrap input { flex: 1; border: none; outline: none; padding: 10px 12px; font-size: 15px; color: var(--gray-800); width: 0; min-width: 0; background: transparent; }

/* Select */
.input-select {
  width: 100%; border: 1.5px solid var(--gray-200); border-radius: var(--r-sm);
  padding: 10px 36px 10px 12px; font-size: 15px; color: var(--gray-800); outline: none;
  background: #fff; cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10'%3E%3Cpath fill='%235f6368' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: border-color 0.2s;
}
.input-select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,43,91,0.09); }

/* Slider row */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider {
  flex: 1; -webkit-appearance: none; appearance: none; height: 5px;
  border-radius: 3px; background: var(--gray-200); outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--navy); cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2); transition: transform 0.15s, box-shadow 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.18); box-shadow: 0 0 0 5px rgba(15,43,91,0.15); }
.slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--navy); border: none; cursor: pointer; }

.input-unit-wrap {
  display: flex; align-items: stretch; border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm); overflow: hidden; width: 116px; flex-shrink: 0; transition: border-color 0.2s;
}
.input-unit-wrap:focus-within { border-color: var(--navy); }
.input-short { border: none; outline: none; padding: 8px 6px 8px 8px; font-size: 14px; width: 0; flex: 1; min-width: 0; text-align: right; color: var(--gray-800); background: transparent; }
.unit-suffix { display: flex; align-items: center; padding: 0 7px; background: var(--gray-50); font-size: 11px; color: var(--gray-600); font-weight: 600; border-left: 1px solid var(--gray-200); white-space: nowrap; }

/* Toggle buttons */
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.toggle-group { display: flex; border: 1.5px solid var(--gray-200); border-radius: 6px; overflow: hidden; }
.toggle-btn { padding: 4px 12px; font-size: 12px; font-weight: 600; background: #fff; border: none; color: var(--gray-600); transition: all 0.15s; }
.toggle-btn.active { background: var(--navy); color: #fff; }
.toggle-btn:not(.active):hover { background: var(--gray-100); }

/* Validation/warning messages */
.validation-msg { display: none; background: #fff8e1; border: 1px solid #ffca28; color: #795548; padding: 9px 13px; border-radius: 7px; font-size: 13px; margin-top: 10px; }
.warning-msg { display: none; background: #fce4e4; border: 1px solid #ef9a9a; color: #b71c1c; padding: 9px 13px; border-radius: 7px; font-size: 13px; margin-top: 10px; }

/* ===== RESULTS PANEL ===== */
.results-panel { width: 100%; }

/* Summary Cards */
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.summary-card {
  background: #fff; border-radius: var(--r); padding: 18px 14px; box-shadow: var(--shadow);
  text-align: center; border-top: 3px solid var(--gray-200); transition: transform 0.2s, box-shadow 0.2s;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-h); }
.a-navy { border-top-color: var(--navy); }
.a-green { border-top-color: var(--green); }
.a-red { border-top-color: var(--red); }
.sc-label { font-size: 11px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 7px; }
.sc-value { font-size: 20px; font-weight: 700; color: var(--navy); line-height: 1.2; word-break: break-all; transition: color 0.3s; }
.v-green { color: var(--green-dark) !important; }
.v-red { color: var(--red) !important; }

/* Card */
.card { background: #fff; border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 14px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header .card-title { margin-bottom: 0; }

/* Chart */
.chart-wrap { position: relative; height: 300px; width: 100%; }

/* Tables */
.table-scroll { overflow-x: auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 380px; }
thead th {
  background: var(--navy); color: #fff; padding: 10px 14px; font-size: 12px; font-weight: 600;
  text-align: right; white-space: nowrap; position: sticky; top: 0; z-index: 1; letter-spacing: 0.3px;
}
thead th:first-child { text-align: left; }
tbody td { padding: 9px 14px; font-size: 13px; text-align: right; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); white-space: nowrap; }
tbody td:first-child { text-align: left; font-weight: 500; }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* Extra note */
.extra-note { display: none; background: #e8f5e9; border: 1px solid #a5d6a7; color: #1b5e20; padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-top: 12px; }

/* Text link button */
.btn-text { background: none; border: none; color: var(--navy); font-size: 13px; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; }
.btn-text:hover { color: var(--navy-light); }

/* ===== HERO NUMBERS (RETIREMENT) ===== */
.hero-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.hero-card { background: #fff; border-radius: var(--r); padding: 22px 16px; box-shadow: var(--shadow); text-align: center; border-top: 4px solid var(--navy); transition: transform 0.2s; }
.hero-card:hover { transform: translateY(-2px); }
.hero-label { font-size: 12px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 9px; }
.hero-value { font-size: 26px; font-weight: 800; color: var(--navy); line-height: 1.1; word-break: break-all; transition: color 0.3s; }

/* ===== BANNERS ===== */
.banner { border-radius: 10px; padding: 14px 18px; font-size: 14px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; }
.banner-green { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.banner-red { background: #fce4e4; color: #b71c1c; border: 1px solid #ef9a9a; }
.banner-icon { font-size: 18px; flex-shrink: 0; line-height: 1.4; }

/* ===== COMPARISON CARDS (DEBT) ===== */
.comparison-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.comp-card { background: #fff; border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); border-top: 3px solid var(--gray-200); }
.comp-card.comp-highlight { border-top-color: var(--green); }
.comp-title { font-size: 12px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--gray-100); }
.comp-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 9px; }
.comp-item:last-child { margin-bottom: 0; }
.comp-item-label { font-size: 12px; color: var(--gray-600); font-weight: 500; }
.comp-item-value { font-size: 14px; font-weight: 700; color: var(--navy); text-align: right; }

/* Savings banner */
.savings-banner { display: none; background: linear-gradient(135deg, #00c853, #00a844); color: #fff; border-radius: 10px; padding: 14px 18px; font-size: 14px; margin-bottom: 16px; text-align: center; line-height: 1.6; }

/* ===== ACTION BUTTONS ===== */
.actions-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.btn { padding: 10px 18px; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.btn-copy { background: var(--gray-100); color: var(--gray-800); border: 1.5px solid var(--gray-200); }
.btn-copy:hover { background: var(--gray-200); }
.btn-share { background: var(--navy); color: #fff; }
.btn-share:hover { background: var(--navy-light); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(70px);
  background: #1c1c1c; color: #fff; padding: 11px 26px;
  border-radius: 28px; font-size: 14px; font-weight: 500;
  transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
  pointer-events: none; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== FOOTER ===== */
footer { background: var(--navy); color: rgba(255,255,255,0.65); text-align: center; padding: 22px 16px; font-size: 13px; line-height: 1.6; }
footer p { max-width: 640px; margin: 0 auto; }

/* ===== LOADING STATE ===== */
.app-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 40vh; gap: 16px; color: var(--gray-600);
}
.app-loading-spinner {
  width: 40px; height: 40px; border: 3px solid var(--gray-200);
  border-top-color: var(--navy); border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .tool-layout { flex-direction: row; align-items: flex-start; }
  .inputs-panel { width: 340px; flex-shrink: 0; position: sticky; top: calc(var(--nav-h) + var(--tab-h) + 24px); }
  .results-panel { flex: 1; min-width: 0; }
}
@media (min-width: 1024px) {
  .inputs-panel { width: 360px; }
}
@media (max-width: 600px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .hero-numbers { grid-template-columns: 1fr; }
  .comparison-cards { grid-template-columns: 1fr; }
  .hero-value { font-size: 22px; }
  .sc-value { font-size: 17px; }
}
@media (max-width: 400px) {
  .summary-cards { grid-template-columns: 1fr; }
  .tab-btn { padding: 12px 14px; font-size: 13px; }
  .inputs-panel, .card { padding: 16px; }
  .btn { padding: 9px 14px; font-size: 13px; }
}
