/* =========================================================
   বাংলা ক্যালকুলেটর হাব — Bangla Calculator Hub
   Clean light theme · emerald primary · red accent
   ========================================================= */

:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --text: #1f2a28;
  --muted: #5f6f6b;
  --border: #e2e9e7;
  --primary: #059669;
  --primary-dark: #047857;
  --primary-ink: #065f46;
  --primary-soft: #d1fae5;
  --primary-softer: #ecfdf5;
  --ring: rgba(5, 150, 105, 0.16);
  --red: #dc2626;
  --red-dark: #991b1b;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(16, 40, 33, 0.06);
  --shadow-md: 0 1px 2px rgba(16, 40, 33, 0.05), 0 10px 28px rgba(16, 40, 33, 0.08);
  --font: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg { vertical-align: middle; }

:focus-visible {
  outline: 3px solid rgba(5, 150, 105, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

.container {
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 20px;
}

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--primary), #10b981);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.brand-text { line-height: 1.15; min-width: 0; }

.brand-text strong {
  display: block;
  font-size: 1.06rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.home-link {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary-dark);
  background: var(--primary-softer);
  border: 1px solid #b9ead6;
  padding: 8px 18px;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.home-link:hover { background: var(--primary-soft); }

/* ---------------- Hero (home) ---------------- */
.hero {
  text-align: center;
  padding: 46px 0 14px;
}

.hero-title {
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 10px;
  line-height: 1.25;
}

.hero-accent { color: var(--primary-dark); }

.hero-sub {
  max-width: 560px;
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 1.02rem;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 34px 0 16px;
}

/* ---------------- Card grid ---------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}

.calc-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.calc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #a7f3d0;
}

.calc-card-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  font-size: 1.65rem;
  background: var(--primary-softer);
  border: 1px solid #d3f1e3;
  border-radius: 13px;
  margin-bottom: 12px;
}

.calc-card-body { display: flex; flex-direction: column; gap: 2px; }

.calc-card-name { font-weight: 700; font-size: 1.08rem; }

.calc-card-en {
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 600;
}

.calc-card-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 6px;
  line-height: 1.55;
}

.calc-card-go {
  margin-top: auto;
  padding-top: 12px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.86rem;
}

/* ---------------- Calc view layout ---------------- */
.calc-view { padding: 26px 0 30px; }

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.back-link:hover { color: var(--primary-dark); }

.calc-view .container { max-width: 860px; }

.calc-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.calc-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  background: linear-gradient(135deg, var(--primary-softer), var(--primary-soft));
  border: 1px solid #cdeedd;
  border-radius: 15px;
}

.calc-title h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  font-weight: 700;
  line-height: 1.3;
}

.en-sub {
  margin: 0;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 4px 0 12px;
}

.notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  margin: 0 0 16px;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 12px 0 0;
  line-height: 1.6;
}

.hint.center { text-align: center; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 14px; min-width: 0; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label, .field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="date"],
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  font-size: 1.02rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

input.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

input::placeholder { color: #a3b1ad; }

.form-error {
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 10px 0 0;
}

/* Segmented control */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #edf3f1;
  padding: 4px;
  border-radius: 13px;
  margin-bottom: 6px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  min-height: 40px;
}

.seg-btn:hover { color: var(--primary-dark); }

.seg-btn.is-active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(16, 40, 33, 0.14);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 18px;
  min-height: 46px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.btn:active { transform: scale(0.98); }

.btn-ghost {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--primary-dark);
}

.btn-ghost:hover { border-color: var(--primary); background: var(--primary-softer); }

.btn-primary {
  background: var(--primary);
  border: 1.5px solid var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* ---------------- Result panels ---------------- */
.result-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(135deg, #ecfdf5, #d9f3e7);
  border: 1px solid #a7f3d0;
  padding: 16px 18px;
  border-radius: 14px;
  margin-top: 16px;
}

.result-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.result-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--primary-ink);
  direction: ltr;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.result-sub {
  font-size: 0.86rem;
  color: #3f7263;
}

.result-panel.is-profit { background: linear-gradient(135deg, #ecfdf5, #d1fae5); border-color: #6ee7b7; }
.result-panel.is-profit .result-value { color: #15803d; }
.result-panel.is-profit .result-label { color: #15803d; }

.result-panel.is-loss {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border-color: #fca5a5;
}
.result-panel.is-loss .result-value { color: var(--red-dark); }
.result-panel.is-loss .result-label { color: var(--red-dark); }
.result-panel.is-loss .result-sub { color: #a35454; }

.result-panel.is-neutral {
  background: #f8faf9;
  border-color: var(--border);
}
.result-panel.is-neutral .result-value { color: var(--text); }
.result-panel.is-neutral .result-label { color: var(--muted); }
.result-panel.is-neutral .result-sub { color: var(--muted); }

/* Stat tiles */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stat {
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

.stat-value {
  font-size: 1.18rem;
  font-weight: 700;
  direction: ltr;
  overflow-wrap: anywhere;
}

.stat-green { background: var(--primary-softer); border-color: #b9ead6; }
.stat-green .stat-value { color: var(--primary-dark); }

.stat-emerald {
  background: linear-gradient(135deg, var(--primary), #10b981);
  border-color: var(--primary-dark);
}
.stat-emerald .stat-label { color: #d1fae5; }
.stat-emerald .stat-value { color: #ffffff; }

/* Badge */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  margin-right: 6px;
}

.badge.cat-under { background: #fef3c7; color: #92400e; }
.badge.cat-normal { background: var(--primary-soft); color: var(--primary-ink); }
.badge.cat-over { background: #ffedd5; color: #9a3412; }
.badge.cat-obese { background: var(--red-soft); color: var(--red-dark); }
.badge.pct-up { background: var(--primary-soft); color: var(--primary-ink); }
.badge.pct-down { background: var(--red-soft); color: var(--red-dark); }
.badge.pct-flat { background: #e5e7eb; color: #4b5563; }

/* ---------------- General calculator ---------------- */
.calc-display {
  background: #0c261f;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 420px;
  margin: 0 auto;
}

.gen-expression {
  background: transparent;
  border: none;
  padding: 0;
  min-height: 0;
  color: #9fd8c3;
  text-align: right;
  font-size: 1.05rem;
  font-family: inherit;
  direction: ltr;
}

.gen-expression:focus { outline: none; box-shadow: none; }

.gen-expression::placeholder { color: #4e7a6b; }

.gen-result {
  color: #ffffff;
  text-align: right;
  font-size: 2.1rem;
  font-weight: 700;
  direction: ltr;
  min-height: 1.25em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 420px;
  margin: 16px auto 0;
}

.key {
  min-height: 56px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, background 0.12s ease;
}

.key:hover { background: #f3f8f6; }
.key:active { transform: scale(0.95); }

.key-fn { background: #edf3f1; color: var(--primary-dark); font-size: 1.05rem; }
.key-fn:hover { background: #e0ebe7; }

.key-op { background: #d9f3e7; color: var(--primary-dark); font-size: 1.3rem; }
.key-op:hover { background: #c8ecdb; }

.key-eq {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-size: 1.4rem;
}

.key-eq:hover { background: var(--primary-dark); }

.key[data-key="0"] { grid-column: span 2; }

/* ---------------- Tables ---------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
}

.data-table th {
  text-align: left;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid #edf2f0;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  white-space: nowrap;
}

.data-table tr.dim td { color: var(--muted); }

.data-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--border);
  font-weight: 700;
}

.data-table tfoot tr.total-row td {
  color: var(--primary-ink);
  font-size: 1.08rem;
  padding-top: 12px;
}

.data-table tr.is-source td { background: #f0faf5; }

.table-scroll { overflow-x: auto; }

/* Editable slab tables */
.slab-table .cell-input {
  width: 100%;
  min-width: 76px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1.3px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.97rem;
  text-align: right;
  direction: ltr;
  background: #fbfdfc;
}

.slab-table .cell-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.slab-table .cell-input:disabled { background: #eef2f0; color: var(--muted); }

.slab-table .cell-input.is-invalid { border-color: var(--red); }

.slab-table td { padding: 7px 8px; }

/* ---------------- Dynamic rows (GPA / CGPA) ---------------- */
.row-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.row-item .ri-name { flex: 1 1 160px; min-width: 140px; }
.row-item .ri-marks,
.row-item .ri-gpa { flex: 0 1 150px; width: 150px; min-width: 110px; }
.row-item .ri-credit { flex: 0 1 120px; width: 120px; min-width: 96px; }

.grade-chip {
  flex: 0 0 auto;
  min-width: 92px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 999px;
  background: #eef2f0;
  color: var(--muted);
  direction: ltr;
}

.grade-chip.g-high { background: var(--primary-soft); color: var(--primary-ink); }
.grade-chip.g-mid { background: #e0f2fe; color: #075985; }
.grade-chip.g-fail { background: var(--red-soft); color: var(--red-dark); }

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1.3px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.icon-btn:hover { color: var(--red); border-color: #fca5a5; background: #fef2f2; }

.ref-details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: #fbfdfc;
}

.ref-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary-dark);
}

.ref-details table { margin-top: 10px; }

/* ---------------- BMI gauge ---------------- */
.gauge-wrap { margin-top: 18px; }

.gauge {
  position: relative;
  display: flex;
  height: 16px;
  border-radius: 8px;
}

.gauge-seg { display: block; height: 100%; }

.g-under { width: 28.33%; background: #fbbf24; border-radius: 8px 0 0 8px; }
.g-normal { width: 21.67%; background: #34d399; }
.g-over { width: 16.67%; background: #fb923c; }
.g-obese { width: 33.33%; background: #f87171; border-radius: 0 8px 8px 0; }

.gauge-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 4px;
  background: #111827;
  border-radius: 2px;
  box-shadow: 0 0 0 2px #ffffff;
  transform: translateX(-50%);
  transition: left 0.25s ease;
}

.gauge-scale {
  position: relative;
  height: 20px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.gauge-scale span { position: absolute; transform: translateX(-50%); }
.gauge-scale .gs-first { transform: none; }
.gauge-scale .gs-last { transform: translateX(-100%); }

/* ---------------- Age ---------------- */
.next-birthday {
  margin-top: 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
}

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  bottom: 22px;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding-inline: 16px;
}

.toast {
  max-width: 480px;
  background: #065f46;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(6, 78, 59, 0.35);
  animation: toast-in 0.25s ease;
  text-align: center;
}

.toast.toast-error { background: var(--red-dark); box-shadow: 0 10px 30px rgba(127, 29, 29, 0.35); }
.toast.toast-info { background: #1f2937; box-shadow: 0 10px 30px rgba(17, 24, 39, 0.35); }

.toast.toast-out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Footer ---------------- */
.site-footer {
  background: #10231e;
  color: #cbd5d1;
  margin-top: 40px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: space-between;
  padding-top: 34px;
  padding-bottom: 26px;
}

.footer-brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.footer-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 12px;
}

.footer-brand strong { color: #ffffff; font-size: 1.02rem; }

.footer-brand p {
  margin: 4px 0 0;
  color: #9fb3ad;
  font-size: 0.88rem;
  max-width: 320px;
}

.footer-nav { min-width: 260px; }

.footer-nav-title {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8aa39c;
  margin-bottom: 10px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
}

.footer-links a {
  color: #d7e4e0;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 3px 0;
  border-bottom: 1px dashed transparent;
}

.footer-links a:hover { color: #ffffff; border-bottom-color: #34d399; }

.footer-links a.is-current {
  color: #34d399;
  font-weight: 700;
}

.footer-base {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  padding-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #8aa39c;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 30px; }
  .card { padding: 18px 16px; }
  .key { min-height: 54px; }
  .gen-result { font-size: 1.7rem; }
  .result-value { font-size: 1.55rem; }
  .calc-icon { width: 48px; height: 48px; font-size: 1.4rem; }
  .brand-text small { display: none; }
  .footer-inner { flex-direction: column; }
}

@media (max-width: 380px) {
  .container { padding-inline: 14px; }
  .seg-btn { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
