/* ===== KWIKSUM SHARED STYLES ===== */
:root {
  --bg: #0c0c0e;
  --surface: #161619;
  --surface-2: #1e1e22;
  --surface-3: #26262b;
  --border: #2a2a30;
  --text: #e8e6e3;
  --text-muted: #b0b0b6;
  --text-dim: #7e7e86;
  --accent: #f0c040;
  --accent-dim: rgba(240, 192, 64, 0.12);
  --accent-glow: rgba(240, 192, 64, 0.06);
  --success: #4ade80;
  --error: #f87171;
  --radius: 12px;
  --radius-lg: 20px;
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'Outfit', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
button { background-color: transparent; }

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; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12, 12, 14, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.logo {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700;
  color: var(--text); text-decoration: none; letter-spacing: -0.04em; flex-shrink: 0;
}
.logo span { color: var(--accent); }
.search-bar { flex: 1; max-width: 420px; position: relative; }
.search-bar input {
  width: 100%; padding: 10px 16px 10px 40px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: var(--font-body); font-size: 0.9rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.search-bar input::placeholder { color: var(--text-dim); }
.search-bar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }
.header-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.currency-switcher, .decimal-switcher {
  display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.currency-btn, .decimal-btn {
  padding: 8px 12px; background: transparent; border: none; color: var(--text-dim);
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s; position: relative;
}
.decimal-btn { padding: 8px 10px; font-size: 0.8rem; }
.currency-btn:not(:last-child)::after,
.decimal-btn:not(:last-child)::after {
  content: ''; position: absolute; right: 0; top: 25%; height: 50%; width: 1px; background: var(--border);
}
.currency-btn:hover, .decimal-btn:hover { color: var(--text); }
.currency-btn.active, .decimal-btn.active {
  background: var(--accent-dim); color: var(--accent); font-weight: 600;
}
.theme-toggle {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; color: var(--text-muted); cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.filter-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; align-self: center; }

/* ===== LAYOUT ===== */
.app-layout {
  max-width: 1200px; margin: 0 auto; padding: 24px;
  display: grid; grid-template-columns: 220px 1fr; gap: 32px; min-height: calc(100vh - 65px);
}
.sidebar { position: sticky; top: 89px; height: fit-content; }
.nav-section { margin-bottom: 28px; }
.nav-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); padding: 0 12px; margin-bottom: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-muted); font-size: 0.88rem; font-weight: 450; cursor: pointer;
  transition: all 0.15s; text-decoration: none; user-select: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }
.main-content { min-width: 0; }

/* ===== HOME GRID ===== */
.home-view .section-title {
  font-family: var(--font-display); font-size: 1.8rem; font-weight: 700;
  margin-bottom: 6px; letter-spacing: -0.03em;
}
.home-view .section-sub { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 24px; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 40px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; cursor: pointer; transition: all 0.2s; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 12px;
}
.tool-card:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), 0 0 0 1px var(--accent-dim);
}
.tool-card-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.tool-card h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.tool-card p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.tool-card .tag { font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-top: auto; }

/* ===== CALCULATOR VIEWS ===== */
.calc-header { margin-bottom: 28px; }
.calc-back {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.85rem;
  cursor: pointer; margin-bottom: 16px; transition: color 0.15s; background: none; border: none;
  font-family: var(--font-body); text-decoration: none;
}
.calc-back:hover { color: var(--accent); }
.calc-header h1 { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 6px; }
.calc-header p { color: var(--text-muted); font-size: 0.95rem; }
.calc-body { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.calc-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
.calc-panel h2 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); margin-bottom: 20px; }

/* Form elements */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); margin-bottom: 7px; }
.field input, .field select {
  width: 100%; padding: 11px 14px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: var(--font-body); font-size: 0.95rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.field input::placeholder { color: var(--text-dim); }
.input-group { display: flex; gap: 10px; }
.input-group .field { flex: 1; margin-bottom: 0; }
.field .input-with-unit { position: relative; }
.field .input-with-unit input { padding-right: 45px; }
.field .input-unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 0.85rem; pointer-events: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border-radius: 10px; font-family: var(--font-body); font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.15s; border: none; }
.btn-primary { background: var(--accent); color: #0c0c0e; width: 100%; margin-top: 8px; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }

/* Results */
.result-big { text-align: center; padding: 20px 0; }
.result-big .result-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 8px; }
.result-big .result-value { font-family: var(--font-display); font-size: 2.8rem; font-weight: 700; color: var(--accent); letter-spacing: -0.03em; line-height: 1.1; }
.result-big .result-sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 8px; }
.result-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: none; }
.result-row .rr-label { color: var(--text-muted); font-size: 0.9rem; }
.result-row .rr-value { font-weight: 600; font-size: 0.95rem; }
.result-divider { border: none; border-top: 1px dashed var(--border); margin: 4px 0; }

/* Bar chart */
.bar-chart { margin-top: 16px; }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .bar-label { width: 80px; font-size: 0.82rem; color: var(--text-muted); flex-shrink: 0; text-align: right; }
.bar-row .bar-track { flex: 1; height: 28px; background: var(--surface-2); border-radius: 6px; overflow: hidden; position: relative; }
.bar-row .bar-fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; display: flex; align-items: center; padding-left: 10px; font-size: 0.78rem; font-weight: 600; color: #0c0c0e; min-width: fit-content; }

/* Copy / share buttons */
.copy-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px;
  color: var(--text-muted); font-size: 0.78rem; font-family: var(--font-body); cursor: pointer;
  transition: all 0.15s; display: inline-flex; align-items: center; gap: 5px; margin-top: 16px;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== SHARE BAR ===== */
.share-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 16px 0; margin-top: 28px;
  border-top: 1px solid var(--border);
}
.share-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); margin-right: 4px; }
.share-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-family: var(--font-body); font-size: 0.82rem;
  font-weight: 500; cursor: pointer; text-decoration: none; transition: all 0.15s;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn.copied { border-color: var(--success); color: var(--success); }
.share-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Calc tabs */
.calc-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.calc-tab { flex: 1; padding: 8px 16px; border-radius: 8px; border: none; background: transparent; color: var(--text-muted); font-family: var(--font-body); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.calc-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* Bill split */
.person-entry { display: flex; gap: 10px; align-items: end; margin-bottom: 12px; }
.person-entry .field { margin-bottom: 0; }
.person-entry .field:first-child { flex: 1.2; }
.person-entry .field:nth-child(2) { flex: 1; }
.person-remove { padding: 11px; background-color: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text-muted); cursor: pointer; transition: all 0.15s; flex-shrink: 0; font-family: var(--font-body); font-size: 0.9rem; line-height: 1; }
.person-remove:hover { border-color: var(--error); color: var(--error); }
.add-person-btn { display: flex; align-items: center; gap: 6px; padding: 9px 14px; background: none; border: 1px dashed var(--border); border-radius: 10px; color: var(--text-muted); font-family: var(--font-body); font-size: 0.85rem; cursor: pointer; transition: all 0.15s; width: 100%; justify-content: center; }
.add-person-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Swap btn */
.swap-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; margin: 0 auto; flex-shrink: 0; }
.swap-btn:hover { border-color: var(--accent); color: var(--accent); transform: rotate(180deg); }

/* Tables */
.amort-table { width: 100%; font-size: 0.8rem; margin-top: 16px; border-collapse: collapse; }
.amort-table th { text-align: left; padding: 8px 6px; color: var(--text-dim); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.amort-table td { padding: 7px 6px; color: var(--text-muted); border-bottom: 1px solid rgba(42,42,48,0.5); }
.amort-table tr:hover td { color: var(--text); }

/* FAQ / SEO content */
.seo-content { margin-top: 16px; }
.seo-content h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 16px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.faq-question { width: 100%; padding: 16px 20px; background: transparent; border: none; color: var(--text); font-family: var(--font-body); font-size: 0.92rem; font-weight: 500; text-align: left; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; transition: color 0.15s; }
.faq-question:hover { color: var(--accent); }
.faq-question .faq-icon { flex-shrink: 0; transition: transform 0.2s; color: var(--text-dim); font-size: 1.2rem; }
.faq-item.open .faq-icon { transform: rotate(45deg); color: var(--accent); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.faq-answer-inner { padding: 0 20px 16px; color: var(--text-muted); font-size: 0.88rem; line-height: 1.65; }
.seo-text { color: var(--text-muted); font-size: 0.88rem; line-height: 1.7; margin-top: 20px; max-width: 720px; }
.seo-text a { color: var(--accent); text-decoration: none; }
.seo-text a:hover { text-decoration: underline; }

/* Mobile nav */
.mobile-nav { display: none; overflow-x: auto; gap: 6px; padding: 12px 0; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.mobile-nav::-webkit-scrollbar { display: none; }
.mobile-nav-item { flex-shrink: 0; padding: 7px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: all 0.15s; white-space: nowrap; text-decoration: none; }
.mobile-nav-item:hover, .mobile-nav-item.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Decimal switcher */
.decimal-btn { padding: 8px 10px; font-size: 0.8rem; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.25s ease; }

/* Ad slots */
.ad-slot { border-radius: var(--radius); display: none; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.ad-slot.ad-active { display: flex; background: var(--surface); border: 1px solid var(--border); }
.ad-slot-sidebar { min-height: 250px; padding: 20px; margin-top: 20px; }
.ad-slot-leaderboard { min-height: 90px; padding: 16px; max-width: 1200px; margin: 0 auto 24px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 60px; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 32px; }
.footer-brand .logo { display: inline-block; margin-bottom: 12px; }
.footer-brand p { color: var(--text-muted); font-size: 0.85rem; line-height: 1.6; max-width: 300px; }
.footer-col h4 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 14px; }
.footer-col a { display: block; color: var(--text-muted); text-decoration: none; font-size: 0.88rem; padding: 4px 0; transition: color 0.15s; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.footer-bottom p { color: var(--text-dim); font-size: 0.8rem; }
.footer-bottom-links { display: flex; gap: 20px; }
.footer-bottom-links a { color: var(--text-dim); text-decoration: none; font-size: 0.8rem; transition: color 0.15s; }
.footer-bottom-links a:hover { color: var(--accent); }

/* Breadcrumb */
.breadcrumb { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 20px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-dim); text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text-muted); }

/* Light theme */
body.light {
  --bg: #f5f4f1; --surface: #ffffff; --surface-2: #f0efec; --surface-3: #e8e7e4;
  --border: #dddcd8; --text: #1a1a1c; --text-muted: #6b6b70; --text-dim: #9b9ba0;
  --accent: #c8960a; --accent-dim: rgba(200, 150, 10, 0.1); --accent-glow: rgba(200, 150, 10, 0.05);
}
body.light header { background: rgba(245, 244, 241, 0.85); }
body.light .tool-card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.08), 0 0 0 1px var(--accent-dim); }
body.light .btn-primary { color: #fff; }
body.light .bar-row .bar-fill { color: #fff; }

/* Responsive */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; padding: 16px; gap: 20px; }
  .sidebar { display: none; }
  .calc-body { grid-template-columns: 1fr; }
  .mobile-nav { display: flex !important; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .header-controls { gap: 6px; }
  .currency-switcher { display: none; }
  .decimal-switcher { display: none; }
  .filter-label { display: none; }
}
@media (max-width: 500px) {
  .footer-grid { grid-template-columns: 1fr; gap: 20px; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

/* Mobile nav category separator */
.mobile-nav-sep {
  flex-shrink: 0; color: var(--border); font-size: 0.9rem; padding: 0 4px;
  display: flex; align-items: center; user-select: none;
}

/* Educational content sections */
.edu-content h2 { margin-top: 32px; }
.edu-content h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--text); margin-top: 24px; margin-bottom: 8px; letter-spacing: -0.01em; }
.edu-content p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.75; margin-bottom: 12px; }
.edu-content a { color: var(--accent); text-decoration: none; }
.edu-content a:hover { text-decoration: underline; }
