@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ===================== TOKENS ===================== */
:root {
    --primary: #6366f1;
    --primary-2: #8b5cf6;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --accent: #22d3ee;
    --accent-2: #10b981;
    --glow-color: rgba(99, 102, 241, 0.35);
    --bg: #080c18;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.6);
    --text: #f1f5f9;
    --text-muted: #64748b;
    --text-sub: #94a3b8;
    --highlight-bg: rgba(99, 102, 241, 0.12);
    --highlight-border: rgba(99, 102, 241, 0.3);
    --radius-card: 24px;
    --radius-input: 12px;
    --radius-btn: 10px;
    --shadow-card: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
}

/* ===================== RESET ===================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===================== BASE ===================== */
body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 16px 80px;
    overflow-x: hidden;
    position: relative;
}

body::-webkit-scrollbar {
    width: 6px;
}

body::-webkit-scrollbar-track {
    background: var(--bg);
}

body::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 8px;
}

body::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* ===================== BG BLOBS ===================== */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.18;
    animation: drift 18s ease-in-out infinite alternate;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #6366f1, #8b5cf6);
    top: -15%;
    left: -10%;
    animation-delay: 0s;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #22d3ee, #0ea5e9);
    bottom: -10%;
    right: -5%;
    animation-delay: -6s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #10b981, #22d3ee);
    top: 50%;
    left: 40%;
    animation-delay: -12s;
    opacity: 0.10;
}

@keyframes drift {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(30px, 40px) scale(1.06);
    }
}

/* ===================== CARD ===================== */
.calculator-card {
    width: 100%;
    max-width: 840px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    padding: 36px 40px 48px;
    animation: scaleIn 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===================== HEADER ===================== */
header {
    text-align: center;
    margin-bottom: 28px;
}

.header-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.currency-switcher {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    padding: 6px 10px;
}

.currency-switcher select {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.title-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.title-icon {
    font-size: 2.5rem;
    line-height: 1;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.7));
    animation: floatIcon 4s ease-in-out infinite;
}

@keyframes floatIcon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===================== MODE TABS ===================== */
.mode-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 14px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s;
    font-family: 'Outfit', sans-serif;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 20px var(--glow-color);
}

.tab-btn:not(.active):hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ===================== INPUT SECTION ===================== */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.input-group {
    margin-bottom: 22px;
}

label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 9px;
    flex-wrap: wrap;
}

.input-row.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

input[type="number"],
select.unit-select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-input);
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
    font-family: 'Outfit', sans-serif;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

input[type="number"]:focus,
select.unit-select:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select.unit-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

select.unit-select option {
    background: #1e293b;
    color: var(--text);
}

.full-select {
    padding: 12px 36px 12px 16px;
}

/* Input with prefix currency */
.input-with-currency {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 14px;
    color: var(--accent);
    font-weight: 800;
    font-size: 1.1rem;
    pointer-events: none;
    z-index: 1;
}

.input-with-currency input {
    padding-left: 34px;
}

/* Input with right suffix (%) */
.input-with-suffix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-suffix {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
}

.input-with-suffix input {
    padding-right: 36px;
}

/* Split duration inputs */
.split-inputs {
    display: flex;
    gap: 8px;
}

.split-field {
    position: relative;
    flex: 1;
}

.split-field input {
    text-align: center;
    padding: 12px 8px 12px 28px;
}

.split-label {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    pointer-events: none;
}

/* Rate freq toggle inside label */
.rate-freq-toggle {
    display: inline-flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 8px;
    margin-left: 6px;
}

.freq-btn {
    padding: 2px 9px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Outfit', sans-serif;
}

.freq-btn.active {
    background: var(--primary);
    color: white;
}

/* ===================== CONTRIBUTION SECTION ===================== */
.contribution-section {
    margin-bottom: 30px;
}

.toggle-section {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    cursor: pointer;
    color: var(--text-sub);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.25s;
    font-family: 'Outfit', sans-serif;
}

.toggle-section:hover {
    border-color: var(--border-active);
    color: var(--text);
    background: var(--surface-hover);
}

.toggle-arrow {
    margin-left: auto;
    transition: transform 0.3s;
    font-size: 1rem;
}

.toggle-section.open .toggle-arrow {
    transform: rotate(180deg);
}

.collapsible-body {
    padding: 20px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-input) var(--radius-input);
    background: rgba(0, 0, 0, 0.2);
    animation: fadeSlideDown 0.3s ease;
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pill Button Group */
.pill-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pill-btn {
    padding: 8px 16px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.22s;
    font-family: 'Outfit', sans-serif;
}

.pill-btn.active {
    background: var(--primary-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 14px var(--glow-color);
}

.pill-btn:not(.active):hover {
    border-color: var(--primary);
    color: var(--text);
}

/* ===================== DASHBOARD ===================== */
.dashboard {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    transition: transform 0.22s, box-shadow 0.22s;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.kpi-card.highlight {
    grid-column: span 2;
    background: var(--highlight-bg);
    border-color: var(--highlight-border);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.1);
}

.kpi-card.rule72 {
    border-color: rgba(34, 211, 238, 0.2);
    background: rgba(34, 211, 238, 0.05);
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}

.kpi-card.highlight .kpi-value {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.2rem;
}

.kpi-card.rule72 .kpi-value {
    color: var(--accent);
}

.kpi-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===================== VIEW CONTROLS ===================== */
.view-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.view-toggle,
.format-toggle {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.view-btn,
.fmt-btn {
    padding: 7px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
}

.view-btn.active,
.fmt-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 10px var(--glow-color);
}

.view-btn:not(.active):hover,
.fmt-btn:not(.active):hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ===================== CHART ===================== */
.chart-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    height: 320px;
}

.chart-wrapper canvas {
    max-height: 280px;
}

/* ===================== TEXT SUMMARY ===================== */
.text-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text-sub);
}

.text-summary strong {
    color: var(--text);
}

.text-summary .ts-highlight {
    color: var(--accent);
    font-weight: 700;
}

.text-summary .ts-rule {
    color: #f59e0b;
    font-weight: 700;
}

/* ===================== DATA TABLE ===================== */
.table-wrapper {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.table-wrapper::-webkit-scrollbar {
    height: 5px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
    min-width: 540px;
}

.data-table thead tr {
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 1px solid var(--border);
}

.data-table thead th {
    padding: 14px 16px;
    text-align: right;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.data-table thead th:first-child {
    text-align: left;
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--surface-hover);
}

.data-table tbody td {
    padding: 12px 16px;
    text-align: right;
    font-weight: 500;
    color: var(--text-sub);
}

.data-table tbody td:first-child {
    text-align: left;
    font-weight: 700;
    color: var(--text);
}

.data-table tbody td.positive {
    color: #10b981;
}

.data-table tbody td.negative {
    color: #f87171;
}

.data-table tbody tr.year-row td {
    font-weight: 700;
    color: var(--text);
    background: rgba(99, 102, 241, 0.05);
}

/* ===================== DOWNLOAD BAR ===================== */
.download-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.download-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

.dl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.22s;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.02em;
}

.dl-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.dl-btn:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.dl-csv {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.25);
}

.dl-excel {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    box-shadow: 0 3px 12px rgba(14, 165, 233, 0.25);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 680px) {
    .calculator-card {
        padding: 24px 18px 36px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .kpi-card.highlight {
        grid-column: span 1;
    }

    .kpi-value {
        font-size: 1.6rem;
    }

    .kpi-card.highlight .kpi-value {
        font-size: 1.8rem;
    }

    .input-row.two-col {
        grid-template-columns: 1fr;
    }

    .view-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .mode-tabs {
        gap: 4px;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 9px 0;
    }
}