/* ==========================================================================
   Finance Tools — Shared design tokens and base styles
   Every module inherits these CSS variables and base classes.
   ========================================================================== */

.ft-wrapper {
    --ft-bg: #ffffff;
    --ft-surface: #ffffff;
    --ft-text: #0f172a;
    --ft-muted: #64748b;
    --ft-border: #e2e8f0;
    --ft-border-strong: #cbd5e1;
    --ft-primary: #006a4e;          /* Bangladesh green */
    --ft-primary-dark: #00503b;
    --ft-accent: #f42a41;           /* Bangladesh red */
    --ft-accent-2: #6366f1;         /* indigo */
    --ft-accent-3: #f59e0b;         /* amber */
    --ft-good: #10b981;
    --ft-bad: #ef4444;
    --ft-shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.25);
    --ft-shadow-sm: 0 6px 18px -8px rgba(15, 23, 42, 0.18);
    --ft-radius: 18px;
    --ft-radius-sm: 12px;
    --ft-grad: linear-gradient(135deg, #00b894 0%, #006a4e 35%, #6366f1 70%, #f42a41 100%);
    --ft-grad-soft: linear-gradient(135deg, rgba(0, 184, 148, 0.12) 0%, rgba(99, 102, 241, 0.10) 50%, rgba(244, 42, 65, 0.10) 100%);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Plus Jakarta Sans", "Hind Siliguri", "Noto Sans Bengali", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ft-text);
    max-width: 980px;
    margin: 24px auto;
    padding: 0 16px;
    line-height: 1.5;
    box-sizing: border-box;
}

.ft-wrapper *,
.ft-wrapper *::before,
.ft-wrapper *::after {
    box-sizing: border-box;
}

/* Card shell — used by every module */
.ft-card {
    position: relative;
    background: var(--ft-surface);
    border-radius: var(--ft-radius);
    overflow: hidden;
    box-shadow: var(--ft-shadow);
    border: 1px solid var(--ft-border);
}

.ft-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 6px;
    background: var(--ft-grad);
    z-index: 1;
}

/* Header */
.ft-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 32px 28px 18px;
    background: var(--ft-grad-soft);
    position: relative;
}

.ft-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
    background: linear-gradient(135deg, var(--ft-primary), var(--ft-accent-2) 70%, var(--ft-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ft-subtitle {
    margin: 0;
    color: var(--ft-muted);
    font-size: 14px;
}

.ft-badge {
    flex-shrink: 0;
    width: 56px;
    height: 36px;
    border-radius: 6px;
    background: var(--ft-primary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px -4px rgba(0, 106, 78, 0.6);
}

.ft-badge-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ft-accent);
    margin-right: 4px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

/* Tabs */
.ft-tabs {
    display: flex;
    gap: 4px;
    padding: 0 28px;
    margin: 18px 0 0;
    border-bottom: 1px solid var(--ft-border);
}

.ft-tab {
    background: transparent;
    border: 0;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ft-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: color 0.18s ease, border-color 0.18s ease;
    font-family: inherit;
}

.ft-tab:hover { color: var(--ft-text); }

.ft-tab.is-active {
    color: var(--ft-primary);
    border-bottom-color: var(--ft-primary);
}

/* Forms */
.ft-form { padding: 24px 28px 8px; }

.ft-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
}

.ft-field { display: flex; flex-direction: column; }
.ft-field--full { grid-column: 1 / -1; }

.ft-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ft-text);
    margin-bottom: 8px;
}

.ft-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1.5px solid var(--ft-border);
    border-radius: var(--ft-radius-sm);
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.ft-input-wrap:focus-within {
    border-color: var(--ft-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 106, 78, 0.10);
}

.ft-prefix,
.ft-suffix {
    padding: 0 14px;
    color: var(--ft-muted);
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.ft-prefix { border-right: 1px solid var(--ft-border); }
.ft-suffix { border-left: 1px solid var(--ft-border); }

.ft-input-wrap input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 12px 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ft-text);
    outline: none;
    width: 100%;
    font-family: inherit;
}

.ft-input-wrap input::-webkit-outer-spin-button,
.ft-input-wrap input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ft-input-wrap input[type=number] { -moz-appearance: textfield; }

/* Range */
.ft-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--ft-primary) 0%, var(--ft-accent-2) 50%, var(--ft-accent) 100%);
    outline: none;
    margin-top: 12px;
}

.ft-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--ft-primary);
    cursor: pointer;
    box-shadow: 0 4px 10px -2px rgba(0, 106, 78, 0.4);
    transition: transform 0.15s ease;
}

.ft-range::-webkit-slider-thumb:hover { transform: scale(1.1); }

.ft-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--ft-primary);
    cursor: pointer;
    box-shadow: 0 4px 10px -2px rgba(0, 106, 78, 0.4);
}

/* Chip selector */
.ft-chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.ft-chip {
    background: #f8fafc;
    border: 1.5px solid var(--ft-border);
    border-radius: var(--ft-radius-sm);
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--ft-text);
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-family: inherit;
}

.ft-chip small {
    font-size: 11px;
    font-weight: 500;
    color: var(--ft-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ft-chip:hover { border-color: var(--ft-primary); color: var(--ft-primary); }

.ft-chip.is-active {
    background: var(--ft-grad);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 14px -4px rgba(99, 102, 241, 0.5);
}

.ft-chip.is-active small { color: rgba(255, 255, 255, 0.85); }

/* Select */
.ft-field select {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ft-text);
    background: #f8fafc;
    border: 1.5px solid var(--ft-border);
    border-radius: var(--ft-radius-sm);
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    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='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    font-family: inherit;
}

.ft-field select:focus {
    border-color: var(--ft-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 106, 78, 0.10);
}

/* Checkbox */
.ft-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ft-text);
    cursor: pointer;
    user-select: none;
}

.ft-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--ft-primary);
    cursor: pointer;
}

/* Submit button */
.ft-submit {
    margin-top: 22px;
    width: 100%;
    padding: 16px 24px;
    background: var(--ft-grad);
    color: #ffffff;
    border: 0;
    border-radius: var(--ft-radius-sm);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-size: 200% 200%;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-position 0.4s ease;
    box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.5);
    font-family: inherit;
}

.ft-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -8px rgba(99, 102, 241, 0.6);
    background-position: 100% 100%;
}

.ft-submit:active { transform: translateY(0); }

.ft-submit:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.ft-submit-icon { width: 18px; height: 18px; transition: transform 0.18s ease; }
.ft-submit:hover .ft-submit-icon { transform: translateX(4px); }

/* Results */
.ft-results { padding: 8px 28px 28px; }
.ft-results:empty { padding: 0; }

.ft-result-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--ft-border);
    border-radius: var(--ft-radius);
    padding: 24px;
    margin-top: 20px;
    animation: ft-fade-in 0.4s ease both;
}

@keyframes ft-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Headline result */
.ft-headline {
    text-align: center;
    padding: 18px 0 22px;
    border-bottom: 1px dashed var(--ft-border);
    margin-bottom: 20px;
}

.ft-headline-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ft-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.ft-headline-value {
    font-size: 42px;
    font-weight: 800;
    background: var(--ft-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.ft-headline-sub { margin-top: 6px; font-size: 13px; color: var(--ft-muted); }

/* Stat grid */
.ft-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.ft-stat {
    background: #ffffff;
    border: 1px solid var(--ft-border);
    border-radius: var(--ft-radius-sm);
    padding: 16px;
    text-align: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ft-stat:hover { transform: translateY(-2px); box-shadow: var(--ft-shadow-sm); }

.ft-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ft-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.ft-stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--ft-text);
    letter-spacing: -0.01em;
}

.ft-stat--good .ft-stat-value { color: var(--ft-primary); }
.ft-stat--accent .ft-stat-value { color: var(--ft-accent-2); }
.ft-stat--warn .ft-stat-value { color: var(--ft-accent-3); }

/* Chart wrap */
.ft-chart-wrap {
    margin-top: 24px;
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--ft-border);
    border-radius: var(--ft-radius-sm);
}

.ft-chart-wrap h4 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ft-text);
    letter-spacing: -0.01em;
}

.ft-chart-canvas { width: 100%; height: 280px; }

/* Compare table */
.ft-compare {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 16px;
    border-radius: var(--ft-radius-sm);
    border: 1px solid var(--ft-border);
}

.ft-compare table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    font-size: 14px;
}

.ft-compare th,
.ft-compare td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--ft-border);
    white-space: nowrap;
    vertical-align: middle;
}

.ft-compare td.ft-bank-name {
    white-space: normal;
}

.ft-compare th {
    background: #f8fafc;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ft-muted);
}

.ft-compare tr:last-child td { border-bottom: 0; }

.ft-compare tr.is-top {
    background: linear-gradient(90deg, rgba(0, 184, 148, 0.10), rgba(99, 102, 241, 0.05));
}

.ft-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--ft-border);
    color: var(--ft-muted);
    font-weight: 700;
    font-size: 12px;
}

.ft-compare tr.is-top .ft-rank {
    background: var(--ft-grad);
    color: #ffffff;
}

.ft-bank-name {
    font-weight: 600;
    color: var(--ft-text);
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 220px;
    max-width: 320px;
    line-height: 1.35;
    padding-right: 12px;
}

.ft-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

.ft-tag--good { background: rgba(16, 185, 129, 0.12); color: #047857; }
.ft-tag--bad { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }

.ft-maturity-cell {
    font-weight: 800;
    color: var(--ft-primary);
    font-size: 15px;
}

/* Loading + error */
.ft-loading {
    text-align: center;
    padding: 30px 0;
    color: var(--ft-muted);
    font-weight: 500;
}

.ft-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid var(--ft-border);
    border-top-color: var(--ft-primary);
    border-radius: 50%;
    animation: ft-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes ft-spin { to { transform: rotate(360deg); } }

.ft-error {
    background: rgba(239, 68, 68, 0.10);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--ft-radius-sm);
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 14px;
    font-weight: 500;
}

.ft-disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--ft-muted);
    margin: 14px 8px 0;
    font-style: italic;
}

/* Mobile */
@media (max-width: 640px) {
    .ft-wrapper { margin: 16px auto; padding: 0 12px; }
    .ft-header { padding: 24px 18px 14px; }
    .ft-title { font-size: 22px; }
    .ft-tabs { padding: 0 18px; }
    .ft-form { padding: 18px; }
    .ft-grid { grid-template-columns: 1fr; gap: 14px; }
    .ft-results { padding: 4px 18px 22px; }
    .ft-result-card { padding: 18px; }
    .ft-headline-value { font-size: 32px; }
    .ft-stats { grid-template-columns: 1fr; }
    .ft-compare th, .ft-compare td { padding: 10px 12px; font-size: 13px; }
    .ft-bank-name { min-width: 160px; max-width: 220px; font-size: 13px; line-height: 1.3; }
}
