  @font-face {
    font-family: 'Vazirmatn';
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/vazirmatn-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
  }
  @font-face {
    font-family: 'Vazirmatn';
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/vazirmatn-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg: #111315;
    --surface: #181b1e;
    --card: rgba(255,255,255,0.06);
    --card-solid: #20252a;
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --primary-light: rgba(45,212,191,0.14);
    --accent: #f59e0b;
    --danger: #fb7185;
    --text: #f6f3ee;
    --muted: #a9b1ad;
    --border: rgba(255,255,255,0.36);
    --warn: #fbbf24;
    --good: #6ee7b7;
    --radius: 8px;
  }

  body {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    background:
      linear-gradient(180deg, rgba(45,212,191,0.05), transparent 280px),
      linear-gradient(135deg, #111315 0%, #171a1d 46%, #101418 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 24px 16px 48px;
    position: relative;
    overflow-x: hidden;
  }
  html { scroll-behavior: smooth; background-color: #111315; color-scheme: dark; }

  /* Background: quiet grid for a utilitarian calculator surface */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
    background-size: 36px 36px;
    z-index: -1;
  }

  .container { max-width: 760px; margin: 0 auto; }

  header { margin-bottom: 24px; }
  .brand-line {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    margin-bottom: 18px; color: var(--muted); font-size: 0.86rem;
  }
  .brand {
    color: var(--text); font-weight: 800; font-size: 1.05rem;
  }
  .trust-pill {
    display: inline-flex; align-items: center;
    border: 1px solid rgba(45,212,191,0.52); color: #99f6e4;
    background: rgba(45,212,191,0.08); border-radius: var(--radius);
    padding: 6px 10px; white-space: nowrap; text-decoration: none;
    transition: background .2s, border-color .2s;
  }
  .trust-pill:hover,
  .trust-pill:focus-visible {
    background: rgba(45,212,191,0.14);
    border-color: rgba(45,212,191,0.75);
    outline: none;
  }
  header h1 {
    font-size: clamp(1.8rem, 3.4vw, 2.65rem); line-height: 1.42; font-weight: 900; margin-bottom: 12px;
    color: var(--text);
  }
  .hero-question {
    color: #99f6e4;
  }
  .hero-answer {
    display: block;
    font-size: 0.82em;
    color: var(--text);
    margin-top: 2px;
  }
  header p { color: var(--muted); font-size: 0.94rem; line-height: 1.9; max-width: 680px; }
  /* Tabs */
  .tabs {
    position: sticky; top: 8px; z-index: 20;
    display: flex; gap: 8px; margin-bottom: 24px;
    background: rgba(17,19,21,0.96); backdrop-filter: blur(12px);
    border-radius: var(--radius); padding: 6px; border: 1px solid var(--border);
  }
  #article-effective-rate { scroll-margin-top: 84px; }
  .tab-btn {
    flex: 1; padding: 10px 4px; border: none; background: transparent;
    border-radius: 8px; font-family: inherit; font-size: 0.85rem; font-weight: 500;
    cursor: pointer; color: var(--muted); transition: all .2s;
  }
  .tab-btn.active {
    background: var(--primary);
    color: #071411;
    box-shadow: 0 2px 12px rgba(45,212,191,0.25);
  }

  .tab-btn:focus-visible, .article-card a:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 3px;
  }
  .articles-intro { color: var(--muted); margin-bottom: 20px; line-height: 1.9; }
  .article-card { line-height: 2; }
  .article-card h3 { font-size: 1.15rem; margin-bottom: 8px; }
  .article-card p, .article-card ul { margin-bottom: 16px; }
  .article-card ul { padding-inline-start: 24px; }
  .article-card .article-meta { color: var(--muted); font-size: 0.82rem; }
  .article-details summary { cursor: pointer; color: #99f6e4; font-weight: 700; padding: 10px 0; }
  .article-details summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
  .article-details .article-read-less { display: none; }
  .article-details[open] .article-read-more { display: none; }
  .article-details[open] .article-read-less { display: inline; }
  .article-full { border-top: 1px solid var(--border); padding-top: 16px; }
  .article-full h4 { font-size: 1rem; margin: 20px 0 8px; }
  .article-formula { background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 8px; padding: 22px 12px; margin-bottom: 16px; text-align: center; overflow-x: auto; }
  .article-formula math { font-size: clamp(1rem, 3.5vw, 1.3rem); margin: 0 auto; }
  .ear-article-link { color: #99f6e4; text-decoration: underline; text-underline-offset: 4px; }
  .ear-article-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
  .inline-math { font-size: 1.12em; margin-inline: 0.2em; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
  .inline-code { font-family: monospace; font-size: 0.95em; overflow-wrap: anywhere; }
  .article-symbols { margin: 16px 0 24px; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,0.15); }
  .article-symbols dt { font-weight: 700; color: #99f6e4; margin-top: 14px; }
  .article-symbols dt:first-child { margin-top: 0; }
  .article-symbols dd { margin: 4px 0 0; }
  .article-card a { color: #99f6e4; text-underline-offset: 4px; }

  /* Card */
  .card {
    background: rgba(255,255,255,0.065); backdrop-filter: blur(16px);
    border-radius: var(--radius); padding: 24px;
    border: 1px solid var(--border); margin-bottom: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  }

  .panel { display: none; }
  .panel.active { display: block; }

  /* Form */
  .field { margin-bottom: 18px; }
  label { display: block; font-size: 0.9rem; font-weight: 700; margin-bottom: 6px; color: #e7ece8; }
  label span.hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }

  input[type="text"], input[type="number"], select {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
    border-radius: 8px; font-family: inherit; font-size: 1rem;
    background: rgba(255,255,255,0.06); color: var(--text);
    transition: border-color .2s, background .2s; direction: ltr; text-align: right;
  }
  input[type="text"]::placeholder, input[type="number"]::placeholder { color: var(--muted); }
  select option { background: #1e1a45; color: var(--text); }
  input[type="text"]:focus, input[type="number"]:focus, select:focus {
    outline: none; border-color: var(--primary);
    background: rgba(45,212,191,0.08);
    box-shadow: 0 0 0 3px rgba(45,212,191,0.16);
  }

  /* Align paired controls even when their labels wrap onto different line counts. */
  .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }

  .input-choice { margin-bottom: 18px; }
  .choice-group {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
    padding: 5px; border: 1px solid var(--border); border-radius: 8px;
    background: rgba(0,0,0,0.16);
  }
  .choice-btn {
    min-width: 0; border: 0; border-radius: 6px; padding: 10px 8px;
    background: transparent; color: var(--muted); font-family: inherit;
    font-size: 0.86rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; text-align: center;
    white-space: normal; line-height: 1.45;
    transition: background .2s, color .2s, box-shadow .2s;
  }
  .choice-btn.active {
    background: rgba(45,212,191,0.18); color: #b7fff2;
    box-shadow: inset 0 0 0 1px rgba(45,212,191,0.48);
  }
  .choice-stack { grid-template-columns: 1fr; }
  .choice-stack .choice-btn {
    justify-content: flex-start;
    line-height: 1.65; text-align: right; padding: 10px 12px;
  }
  .choice-stack .choice-example { flex-direction: column; align-items: flex-start; gap: 2px; }
  .choice-example strong { font-weight: 700; }
  .choice-example span { font-size: 0.78rem; font-weight: 400; color: var(--muted); }
  .choice-help {
    color: var(--muted); font-size: 0.8rem; line-height: 1.7;
    margin-top: 7px;
  }
  .derived-note {
    display: none; margin: -2px 0 18px; padding: 11px 13px;
    border: 1px solid rgba(45,212,191,0.28); border-radius: 8px;
    background: rgba(45,212,191,0.07); color: var(--muted);
    font-size: 0.82rem; line-height: 1.75;
  }
  .derived-note.show { display: block; }
  .derived-note strong { color: #99f6e4; }

  .btn {
    width: 100%; padding: 14px;
    background: var(--primary);
    color: #061513; border: none; border-radius: 8px; font-family: inherit;
    font-size: 1.05rem; font-weight: 700; cursor: pointer;
    transition: transform .15s, box-shadow .15s; margin-top: 4px;
    box-shadow: 0 4px 16px rgba(45,212,191,0.28);
  }
  .btn:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(45,212,191,0.36); }
  .btn:active { transform: translateY(0); }
  .reset-btn {
    display: block; margin: 11px auto 0; padding: 5px 8px;
    border: 0; background: transparent; color: var(--muted);
    font-family: inherit; font-size: 0.82rem; cursor: pointer;
    text-decoration: underline; text-decoration-color: rgba(169,177,173,0.45);
    text-underline-offset: 4px; transition: color .2s;
  }
  .reset-btn:hover,
  .reset-btn:focus-visible { color: #99f6e4; outline: none; }

  /* Results */
  .result-card {
    display: none;
    background: linear-gradient(135deg, rgba(45,212,191,0.13), rgba(245,158,11,0.08));
    border: 1.5px solid rgba(45,212,191,0.52);
    border-radius: var(--radius); padding: 22px; margin-top: 20px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0,0,0,0.26);
  }
  .result-card.show { display: block; }
  .result-card.result-nudge {
    animation: resultNudge 1.25s ease;
  }

  .result-card h3 {
    font-size: 1rem; font-weight: 700; margin-bottom: 16px; text-align: center;
    color: #99f6e4;
  }
  @keyframes resultNudge {
    0% {
      box-shadow: 0 4px 24px rgba(0,0,0,0.26), 0 0 0 0 rgba(45,212,191,0.0);
      border-color: rgba(45,212,191,0.52);
    }
    35% {
      box-shadow: 0 10px 34px rgba(0,0,0,0.34), 0 0 0 8px rgba(45,212,191,0.10);
      border-color: rgba(110,231,183,0.9);
    }
    100% {
      box-shadow: 0 4px 24px rgba(0,0,0,0.26), 0 0 0 0 rgba(45,212,191,0.0);
      border-color: rgba(45,212,191,0.52);
    }
  }

  .result-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .result-row:last-child { border-bottom: none; }
  .result-row .label { color: var(--muted); font-size: 0.9rem; }
  .result-row .value { font-weight: 700; font-size: 0.95rem; color: var(--text); }
  .result-row .value.big { font-size: 1.15rem; color: #fbbf24; }
  .result-row .value.apr { color: #99f6e4; }

  .result-summary {
    background: rgba(8,13,12,0.48);
    border: 1px solid rgba(255,255,255,0.36);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
  }
  .verdict-kicker {
    color: var(--muted); font-size: 0.82rem; margin-bottom: 7px;
  }
  .verdict-title {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 1.35rem; line-height: 1.45; font-weight: 900;
    margin-bottom: 8px;
  }
  .verdict-title.good { color: #6ee7b7; }
  .verdict-title.ok { color: #fde68a; }
  .verdict-title.warn { color: #fb923c; }
  .verdict-title.high { color: #fb7185; }
  .verdict-title.bad { color: #e879f9; }
  .verdict-lead {
    color: #e7ece8; font-size: 0.95rem; line-height: 1.85;
  }
  .result-placeholder {
    background: rgba(255,255,255,0.045);
    border: 1px dashed rgba(255,255,255,0.42);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    color: var(--muted);
    line-height: 1.8;
    font-size: 0.9rem;
  }
  .result-placeholder strong { color: #f6f3ee; }

  /* Verdict bar */
  .verdict {
    margin-top: 16px; background: rgba(255,255,255,0.06);
    border-radius: 8px; padding: 14px 16px; font-size: 0.88rem; line-height: 1.7;
    border: 1px solid rgba(255,255,255,0.36);
  }
  .verdict strong { color: #99f6e4; }

  /* Explainer box */
  .explainer {
    background: rgba(45,212,191,0.07);
    border-right: 4px solid var(--primary);
    border-radius: 0 8px 8px 0; padding: 14px 16px; margin-top: 20px;
    font-size: 0.87rem; line-height: 1.75; color: var(--muted);
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  }
  .explainer strong { color: #99f6e4; }

  .presets {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    margin-bottom: 18px;
  }
  .preset-btn {
    background: rgba(255,255,255,0.052);
    border: 1px solid rgba(255,255,255,0.36);
    color: #f6f3ee; border-radius: 8px; padding: 11px 10px;
    font-family: inherit; cursor: pointer; text-align: right;
    min-height: 64px; transition: border-color .2s, background .2s;
  }
  .preset-btn:hover { border-color: rgba(45,212,191,0.45); background: rgba(45,212,191,0.08); }
  .preset-btn strong { display: block; font-size: 0.9rem; margin-bottom: 3px; }
  .preset-btn span { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
  .preset-label {
    color: #99f6e4;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 12px;
  }
  .preset-separator {
    height: 0;
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.12);
    background: linear-gradient(90deg, rgba(45,212,191,0), rgba(45,212,191,0.3), rgba(45,212,191,0));
    margin: 2px 0 18px;
  }

  /* Variable installments textarea */
  textarea {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
    border-radius: 8px; font-family: 'Vazirmatn', Tahoma, monospace; font-size: 0.95rem;
    background: rgba(255,255,255,0.06); color: var(--text);
    resize: vertical; direction: ltr; text-align: right;
    transition: border-color .2s, background .2s; line-height: 1.8;
  }
  textarea::placeholder { color: var(--muted); }
  textarea:focus {
    outline: none; border-color: var(--primary);
    background: rgba(45,212,191,0.08);
    box-shadow: 0 0 0 3px rgba(45,212,191,0.16);
  }
  .var-counter {
    font-size: 0.8rem; color: var(--muted); margin-top: 5px; text-align: left;
  }
  .var-counter.has-entries { color: #99f6e4; }

  /* Grace period toggle */
  .grace-toggle {
    display: inline-block; margin-bottom: 16px; font-size: 0.85rem;
    color: #99f6e4; cursor: pointer; user-select: none;
    padding: 6px 12px; border: 1px dashed rgba(45,212,191,0.58);
    border-radius: 8px; transition: background .2s;
  }
  .grace-toggle:hover { background: rgba(45,212,191,0.1); }
  .optional-toggle { background: transparent; font-family: inherit; }
  .panel-switch {
    margin-bottom: 18px; padding: 10px 13px;
    border: 1px solid var(--border); border-radius: 8px;
    background: rgba(0,0,0,0.16); color: var(--muted);
    font-size: 0.84rem; line-height: 1.8;
  }
  .link-btn {
    padding: 0; border: 0; background: transparent; color: #99f6e4;
    font-family: inherit; font-size: inherit; font-weight: 700; cursor: pointer;
    text-decoration: underline; text-underline-offset: 4px;
  }
  .link-btn:hover, .link-btn:focus-visible { color: #ccfbf1; }
  .grace-panel { display: none; margin-bottom: 4px; }
  .grace-panel.open { display: block; }

  /* Validation errors */
  .field-error { font-size: 0.82rem; color: #f87171; margin-top: 5px; display: none; }
  .field-error.show { display: block; }
  input.invalid { border-color: #f87171 !important; box-shadow: 0 0 0 3px rgba(248,113,113,0.2) !important; }
  .form-error {
    background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.4);
    border-radius: 8px; padding: 11px 14px; font-size: 0.88rem; color: #fca5a5;
    margin-bottom: 14px; display: none;
  }
  .form-error.show { display: block; }

  /* Tooltip helper */
  .tooltip-wrap { position: relative; display: inline-block; margin-right: 4px; }
  .tooltip-icon { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; background: #99f6e4; color: #061513; border-radius: 50%; font-size: 11px; cursor: default; }

  /* Reference box */
  .ref-box {
    background: rgba(255,255,255,0.05); backdrop-filter: blur(12px);
    border: 1px solid rgba(45,212,191,0.52); border-radius: var(--radius);
    margin-bottom: 20px; overflow: hidden;
  }
  .ref-box summary {
    padding: 13px 18px; font-size: 0.88rem; font-weight: 700; color: #99f6e4;
    cursor: pointer; list-style: none; user-select: none;
  }
  .ref-box summary::-webkit-details-marker { display: none; }
  .ref-box[open] summary { border-bottom: 1px solid rgba(255,255,255,0.08); }
  .ref-body { padding: 16px 18px; }
  .ref-baseline {
    font-size: 0.88rem; color: var(--muted); margin-bottom: 14px;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
  }
  .ref-baseline strong { color: #99f6e4; }
  .ref-bands { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
  .band { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: #e7ece8; }
  .bdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .b-good .bdot { background: #6ee7b7; }
  .b-ok   .bdot { background: #fde68a; }
  .b-warn .bdot { background: #fb923c; }
  .b-high .bdot { background: #f87171; }
  .b-bad  .bdot { background: #e879f9; }
  .ref-note { font-size: 0.78rem; color: var(--muted); border-top: 1px solid rgba(255,255,255,0.07); padding-top: 12px; line-height: 1.7; }
  .ref-note a { color: #99f6e4; }

  .seo-content {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .seo-content h2 {
    font-size: 1.15rem;
    color: #f0eeff;
    margin-bottom: 10px;
  }
  .seo-content h3 {
    font-size: 0.98rem;
    color: #99f6e4;
    margin-bottom: 8px;
  }
  .seo-content p {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.85;
    margin-bottom: 14px;
  }
  .seo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 18px 0 20px;
  }
  .seo-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.36);
    border-radius: 8px;
    padding: 16px;
  }
  .faq-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
  }
  .faq-list details {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.36);
    border-radius: 8px;
    padding: 12px 14px;
  }
  .faq-list summary {
    color: #e7ece8;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
  }
  .faq-list p {
    margin: 10px 0 0;
  }
  .page-links {
    margin: 0;
    padding-right: 20px;
    line-height: 2;
  }
  .page-links a { color: #99f6e4; }
  .site-footer {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.12);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.8;
    text-align: center;
  }
  .footer-free {
    color: #99f6e4;
    font-weight: 700;
  }
  .footer-social {
    display: inline-block;
    margin-top: 8px;
    color: var(--primary);
    text-underline-offset: 4px;
  }

  @media(max-width: 420px) {
    .row-2 { grid-template-columns: 1fr; }
    .seo-grid { grid-template-columns: 1fr; }
    .presets { grid-template-columns: 1fr; }
    .brand-line { align-items: flex-start; flex-direction: column; }
    .tab-btn { font-size: 0.78rem; }
  }
