/* ===== CSS Custom Properties (matching simonkayar.com Chronus theme) ===== */
:root {
  --primary: #cc5555;
  --primary-dark: #b33c3c;
  --primary-deeper: #992222;
  --accent: #91cc56;
  --highlight: #239999;
  --text: #303030;
  --text-medium: #666;
  --text-light: #999;
  --bg: #fff;
  --bg-light: #f7f7f7;
  --bg-lighter: #f0f0f0;
  --border: #ddd;
  --border-light: #e8e8e8;
  --input-bg: #fff9c4;
  --output-bg: #e3f2fd;
  --output-text: #1565c0;
  --success: #43a047;
  --warning: #f9a825;
  --danger: #e53935;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.13);
  --radius: 8px;
  --radius-sm: 4px;
  --max-width: 1300px;
  --header-height: 70px;
  --transition: 0.25s ease;
  --font-body: 'Raleway', arial, helvetica, sans-serif;
  --font-heading: 'Rambla', arial, helvetica, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }
a { color: var(--highlight); text-decoration: none; transition: color var(--transition); }
a:hover { color: #1a7a7a; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
h1 { font-size: 1.8rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin-bottom: 0.8rem; }
ul, ol { padding-left: 1.5rem; margin-bottom: 0.8rem; }

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

#content {
  flex: 1;
  padding: 30px 0;
}

/* ===== Header ===== */
#site-header {
  background: var(--bg);
  border-bottom: 3px solid var(--highlight);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
}

.site-branding {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-link { display: flex; align-items: center; }

.site-logo {
  height: 44px;
  width: auto;
  display: block;
}

.site-title {
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: 0.5px;
}
.site-title a {
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0;
}
.site-title a:hover { color: var(--highlight); }

.site-title .logo-plus {
  color: var(--highlight);
  font-weight: 700;
  margin: 0 4px;
}

.site-title .logo-icon {
  font-size: 1.3rem;
}

.site-tagline {
  font-size: 0.85rem;
  color: var(--text-medium);
  margin: 0;
  line-height: 1.2;
  font-weight: 500;
}

/* ===== Navigation ===== */
#main-nav {
  display: flex;
  align-items: center;
}

#main-nav ul {
  list-style: none;
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
}

#main-nav ul li a {
  display: block;
  padding: 8px 14px;
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

#main-nav ul li a:hover {
  background: var(--highlight);
  color: #fff;
}

#main-nav ul li a.active {
  background: var(--highlight);
  color: #fff;
  font-weight: 700;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 26px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ===== Cards ===== */
.card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow var(--transition);
  border: 1px solid var(--border-light);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--bg-lighter);
}

.card-header h2, .card-header h3 {
  margin: 0;
  flex: 1;
}

.card-icon {
  width: 40px;
  height: 40px;
  background: var(--highlight);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.card-icon.green  { background: #2e7d32; }
.card-icon.blue   { background: #1565c0; }
.card-icon.teal   { background: var(--highlight); }
.card-icon.orange { background: #e65100; }
.card-icon.purple { background: #5e35b1; }

/* ===== Cards Grid (index page) ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.link-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--border-light);
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
  display: block;
}

.link-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--highlight);
  transform: translateY(-2px);
  color: var(--text);
}

.link-card .card-number {
  display: inline-block;
  width: 36px;
  height: 36px;
  background: var(--highlight);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 36px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.link-card h3 {
  margin-bottom: 8px;
  color: var(--highlight);
}

.link-card:nth-child(1) .card-number { background: #2e7d32; }
.link-card:nth-child(1) h3 { color: #2e7d32; }
.link-card:nth-child(2) .card-number { background: #1565c0; }
.link-card:nth-child(2) h3 { color: #1565c0; }
.link-card:nth-child(3) .card-number { background: var(--highlight); }
.link-card:nth-child(3) h3 { color: var(--highlight); }
.link-card:nth-child(4) .card-number { background: #5e35b1; }
.link-card:nth-child(4) h3 { color: #5e35b1; }
.link-card:nth-child(5) .card-number { background: #e65100; }
.link-card:nth-child(5) h3 { color: #e65100; }

.link-card p {
  color: var(--text-medium);
  font-size: 0.92rem;
  margin: 0;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 4px;
  color: var(--text-medium);
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 180px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px rgba(35, 153, 153, 0.18);
}

/* Yellow input cells (user editable - like spreadsheet) */
.input-cell {
  background: var(--input-bg) !important;
  border-color: #e6d060;
  font-weight: 600;
}

.input-cell:focus {
  border-color: #c9a800;
  box-shadow: 0 0 0 3px rgba(201, 168, 0, 0.2);
}

/* Blue output cells (calculated) */
.output-cell {
  background: var(--output-bg) !important;
  border-color: #90caf9;
  color: var(--output-text);
  font-weight: 700;
  cursor: default;
}

.output-value {
  display: inline-block;
  background: var(--output-bg);
  color: var(--output-text);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.05rem;
  border: 1px solid #90caf9;
}

.output-value.large {
  font-size: 1.3rem;
  padding: 10px 20px;
}

.output-value.danger-value {
  background: #ffebee;
  color: #c62828;
  border-color: #ef9a9a;
}

/* ===== Legend ===== */
.cell-legend {
  display: flex;
  gap: 20px;
  font-size: 0.82rem;
  color: var(--text-medium);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.cell-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid #ccc;
}

.legend-box.yellow { background: var(--input-bg); border-color: #e6d060; }
.legend-box.blue { background: var(--output-bg); border-color: #90caf9; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--highlight);
  color: #fff;
}
.btn-primary:hover { background: #1a7a7a; color: #fff; }

.btn-secondary {
  background: var(--bg-lighter);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #388e3c; color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #c62828; color: #fff; }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 1rem;
  line-height: 1;
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table th {
  background: #37474f;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table th.amount,
table th.text-right { text-align: right; }

.table-green th  { background: #2e7d32; }
.table-teal th   { background: #1a7a7a; }
.table-blue th   { background: #1565c0; }
.table-orange th { background: #e65100; }

table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

table tbody tr:hover {
  background: rgba(35, 153, 153, 0.06);
}

table tbody tr:nth-child(even) {
  background: var(--bg-light);
}

table tbody tr:nth-child(even):hover {
  background: rgba(35, 153, 153, 0.08);
}

table td.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table td.highlight-row {
  background: #fce4ec !important;
  font-weight: 700;
}

table td input {
  width: 100%;
  min-width: 90px;
  padding: 5px 8px;
  font-size: 0.88rem;
}

table td .output-cell {
  min-width: 90px;
}

/* ===== Steps List (index page) ===== */
.steps-list {
  list-style: none;
  padding: 0;
  counter-reset: steps;
}

.steps-list li {
  counter-increment: steps;
  padding: 12px 16px 12px 52px;
  position: relative;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--highlight);
}

.steps-list li::before {
  content: counter(steps);
  position: absolute;
  left: 12px;
  top: 12px;
  width: 28px;
  height: 28px;
  background: var(--highlight);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 28px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
}

.steps-list li strong {
  color: var(--highlight);
}

/* ===== Charts ===== */
.chart-container {
  margin: 20px 0;
  min-height: 300px;
}

/* ===== Consent Banner ===== */
#consent-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--text);
  color: #fff;
  padding: 16px 20px;
  z-index: 1000;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
}

#consent-banner.show { display: block; }

.consent-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.consent-inner p {
  flex: 1;
  margin: 0;
  font-size: 0.88rem;
  min-width: 250px;
}

.consent-inner .consent-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.consent-buttons {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ===== Section Headers ===== */
.section-header {
  margin-bottom: 24px;
}

.section-header h1 {
  color: #37474f;
  margin-bottom: 4px;
}

.section-header p {
  color: var(--text-medium);
  font-size: 0.95rem;
}

/* ===== Info/Note Boxes ===== */
.info-box {
  background: #e8f5e9;
  border-left: 4px solid var(--success);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.note-box {
  background: #fff3e0;
  border-left: 4px solid var(--warning);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.warning-box {
  background: #fce4ec;
  border-left: 4px solid var(--danger);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* ===== Inline Result Display ===== */
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.result-row:last-child { border-bottom: none; }

.result-row .label {
  color: var(--text-medium);
  font-size: 0.92rem;
}

/* ===== Dynamic Row Controls ===== */
.dynamic-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.dynamic-row input {
  flex: 1;
  min-width: 100px;
}

.dynamic-row .row-name {
  flex: 2;
  min-width: 140px;
}

.dynamic-row .row-amount {
  flex: 1;
  min-width: 100px;
}

.add-row-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: none;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-medium);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
  margin-top: 4px;
}

.add-row-btn:hover {
  border-color: var(--highlight);
  color: var(--highlight);
  background: rgba(35, 153, 153, 0.05);
}

/* ===== Checkbox (for expense DONE) ===== */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  cursor: pointer;
}

/* ===== Two-column layout ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

/* ===== Tax Slab Visual ===== */
.slab-bar {
  display: flex;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 12px 0;
}

.slab-bar .slab-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
  font-weight: 600;
  min-width: 2px;
  transition: all var(--transition);
}

/* ===== Footer ===== */
#site-footer {
  background: var(--bg);
  border-top: 3px solid var(--highlight);
  padding: 20px 0;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-medium);
}

.footer-inner p { margin-bottom: 4px; }

.disclaimer {
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
}

/* ===== Savings Rate Highlight ===== */
.savings-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--success), var(--highlight));
  color: #fff;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1.1rem;
}

/* ===== Tab Navigation (within a page) ===== */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0;
  position: sticky;
  top: var(--header-height);
  background: #eef6f6;
  z-index: 50;
  padding-top: 8px;
  margin-left: -20px;
  margin-right: -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.sub-tabs button {
  padding: 8px 18px;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: var(--text-medium);
  transition: all var(--transition);
  margin-bottom: -2px;
}

.sub-tabs button:hover {
  color: var(--highlight);
}

.sub-tabs button.active {
  color: var(--highlight);
  border-bottom-color: var(--highlight);
}

/* ===== Corpus Depleted Row ===== */
.depleted { background: #ffebee !important; }
.depleted td { color: var(--danger); font-weight: 700; }

/* ===== Output-value overflow for long text ===== */
.output-value.large.text-overflow {
  font-size: 0.95rem;
  padding: 8px 14px;
  white-space: nowrap;
}

/* ===== Result row border fix (was red highlight) ===== */
.result-row.primary-border {
  border-bottom: 2px solid var(--highlight);
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .two-col, .three-col {
    grid-template-columns: 1fr;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}

@media (max-width: 768px) {
  :root {
    --header-height: 60px;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: flex;
  }

  #main-nav {
    display: none;
    width: 100%;
    order: 3;
    padding: 10px 0;
  }

  #main-nav.open {
    display: block;
  }

  #main-nav ul {
    flex-direction: column;
    gap: 0;
  }

  #main-nav ul li a {
    padding: 10px 14px;
    border-radius: 0;
    border-bottom: 1px solid var(--border-light);
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .form-row .form-group {
    min-width: auto;
  }

  .card {
    padding: 16px;
    margin-bottom: 16px;
  }

  #content {
    padding: 16px 0;
  }

  table {
    font-size: 0.82rem;
  }

  table th, table td {
    padding: 6px 8px;
  }

  .consent-inner {
    flex-direction: column;
    text-align: center;
  }

  .dynamic-row {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }

  .site-title { font-size: 1.2rem; }

  .btn { padding: 8px 16px; font-size: 0.88rem; }

  .sub-tabs button {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .link-card {
    padding: 20px;
  }

  .cell-legend {
    flex-direction: column;
    gap: 6px;
  }
}

/* ===== Print Styles ===== */
@media print {
  #site-header, #site-footer, #consent-banner, .nav-toggle, .btn, .add-row-btn {
    display: none !important;
  }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; }
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-medium); }
.text-small { font-size: 0.85rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
