/* styles.css - Premium Redesign */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* =========================================================
   Design System Tokens
   ========================================================= */
:root {
    /* Background Layers */
    --bg-base:      #060911;
    --bg-surface:   rgba(13, 18, 30, 0.75);
    --bg-surface-2: rgba(20, 27, 43, 0.6);
    --bg-elevated:  rgba(28, 37, 58, 0.85);

    /* Borders */
    --border:         rgba(255, 255, 255, 0.07);
    --border-strong:  rgba(255, 255, 255, 0.12);
    --border-focus:   rgba(99, 102, 241, 0.5);
    --border-success: rgba(16, 185, 129, 0.4);

    /* Text */
    --text-primary:   #f0f2f8;
    --text-secondary: #8892a4;
    --text-muted:     #4f5869;
    --text-accent:    #818cf8;

    /* Accents */
    --indigo:      #6366f1;
    --indigo-500:  #5457e0;
    --violet:      #8b5cf6;
    --purple:      #a855f7;
    --fuchsia:     #d946ef;
    --emerald:     #10b981;
    --amber:       #f59e0b;
    --rose:        #f43f5e;
    --cyan:        #06b6d4;
    --sky:         #38bdf8;

    /* Gradients */
    --grad-primary:   linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --grad-primary-h: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --grad-hero-ytm:  linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(139,92,246,0.18) 100%);
    --grad-hero-px:   linear-gradient(135deg, rgba(168,85,247,0.15) 0%, rgba(217,70,239,0.15) 100%);
    --grad-success:   linear-gradient(135deg, rgba(16,185,129,0.15) 0%, rgba(6,182,212,0.15) 100%);
    --grad-danger:    linear-gradient(135deg, rgba(244,63,94,0.15) 0%, rgba(245,158,11,0.12) 100%);

    /* Glow Effects */
    --glow-primary: 0 0 30px rgba(99, 102, 241, 0.35);
    --glow-violet:  0 0 30px rgba(139, 92, 246, 0.25);
    --glow-success: 0 0 20px rgba(16, 185, 129, 0.25);

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.6);

    /* Typography */
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-body:    'Inter', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

    /* Radii */
    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-full: 9999px;

    /* Transitions */
    --ease-snappy: cubic-bezier(0.175, 0.885, 0.32, 1.1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --t-fast: 0.15s;
    --t-base: 0.25s;
    --t-slow: 0.4s;
}

/* =========================================================
   Reset & Base
   ========================================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(ellipse 80% 60% at 5% 0%,   rgba(99, 102, 241, 0.13) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 95% 0%,  rgba(139, 92, 246, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse 50% 60% at 50% 100%, rgba(16, 185, 129, 0.06) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* =========================================================
   Header
   ========================================================= */
header {
    background: rgba(6, 9, 17, 0.82);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    display: flex;
    align-items: center;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(99,102,241,0.4) 50%, transparent 100%);
}

.header-container {
    max-width: 1520px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--grad-primary);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glow-primary), 0 0 0 1px rgba(99,102,241,0.4);
    transition: box-shadow var(--t-base) var(--ease-smooth), transform var(--t-fast) var(--ease-snappy);
}

.logo-icon:hover {
    box-shadow: var(--glow-primary), 0 0 0 1px rgba(99,102,241,0.6), 0 0 50px rgba(99,102,241,0.2);
    transform: scale(1.05) rotate(-3deg);
}

.logo-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: white;
    stroke-width: 2;
}

.logo-text h1 {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(120deg, #ffffff 30%, #c4b5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.logo-text p {
    font-size: 0.6875rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
    margin-top: 1px;
}

.badge {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.28);
    color: #a5b4fc;
    padding: 0.3rem 0.75rem;
    border-radius: var(--r-full);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--t-base) var(--ease-smooth);
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #818cf8;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(129,140,248,0.8);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(129,140,248,0.8); }
    50% { opacity: 0.5; box-shadow: 0 0 2px rgba(129,140,248,0.4); }
}

/* =========================================================
   Main Layout
   ========================================================= */
main {
    max-width: 1520px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   Card — Glassmorphism
   ========================================================= */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.05);
    padding: 1.875rem;
    position: relative;
    overflow: hidden;
    transition: border-color var(--t-base) var(--ease-smooth),
                box-shadow var(--t-base) var(--ease-smooth);
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
    pointer-events: none;
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255,255,255,0.07);
}

/* =========================================================
   Tabs
   ========================================================= */
.tabs-container {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--r-md);
    padding: 4px;
    margin-bottom: 1.75rem;
    border: 1px solid var(--border);
    gap: 4px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 0.75rem;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--t-base) var(--ease-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: 0.01em;
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.tab-btn.active {
    background: var(--grad-primary);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(99,102,241,0.45), 0 0 0 1px rgba(99,102,241,0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* =========================================================
   Form Elements
   ========================================================= */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 0.72rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--t-base) var(--ease-smooth);
    -webkit-appearance: none;
    -moz-appearance: none;
}

.input-wrapper input:hover,
.input-wrapper select:hover {
    border-color: rgba(255,255,255,0.16);
    background: rgba(0, 0, 0, 0.35);
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.18), 0 0 16px rgba(99,102,241,0.1);
    background: rgba(8, 10, 20, 0.6);
}

.input-wrapper input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.5);
    cursor: pointer;
    opacity: 0.6;
}

.input-wrapper .input-prefix {
    position: absolute;
    left: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 1;
}

.input-wrapper .input-suffix {
    position: absolute;
    right: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 1;
}

.input-wrapper.has-prefix input { padding-left: 2.1rem; }
.input-wrapper.has-suffix input { padding-right: 2.1rem; }

/* Number input: hide arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

/* Custom select arrow */
.input-wrapper select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.input-wrapper select option {
    background: #0f172a;
    color: var(--text-primary);
}

/* Slider */
.slider-group { margin-top: 0.625rem; }

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--r-full);
    outline: none;
    cursor: pointer;
    transition: background var(--t-base);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--grad-primary);
    box-shadow: 0 0 10px rgba(99,102,241,0.6), 0 0 0 2px rgba(99,102,241,0.3);
    cursor: grab;
    transition: transform var(--t-fast) var(--ease-snappy),
                box-shadow var(--t-fast) var(--ease-smooth);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 0 16px rgba(99,102,241,0.8), 0 0 0 3px rgba(99,102,241,0.35);
}

input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }

/* Divider */
.section-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
    margin: 1.5rem 0;
}

/* =========================================================
   Primary Button
   ========================================================= */
.btn-primary {
    width: 100%;
    background: var(--grad-primary);
    border: none;
    color: white;
    padding: 0.9375rem;
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 700;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all var(--t-base) var(--ease-smooth);
    box-shadow: var(--glow-primary), inset 0 1px 0 rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.btn-primary:hover {
    background: var(--grad-primary-h);
    box-shadow: 0 0 40px rgba(99,102,241,0.55), inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 0 20px rgba(99,102,241,0.4);
}

/* =========================================================
   Formula Doc
   ========================================================= */
.formula-doc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--r-sm);
    padding: 0.875rem 1rem;
    margin-top: 1.25rem;
    border: 1px solid var(--border);
    line-height: 1.7;
}

.formula-doc code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: #bae6fd;
    background: rgba(14, 165, 233, 0.12);
    padding: 2px 5px;
    border-radius: 4px;
}

.formula-doc p + p { margin-top: 0.375rem; }

/* =========================================================
   Outputs Panel
   ========================================================= */
.outputs-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Hero Stats */
.main-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .main-metrics { grid-template-columns: 1fr; }
}

.hero-stat {
    border-radius: var(--r-lg);
    padding: 1.625rem 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid rgba(99, 102, 241, 0.2);
    position: relative;
    overflow: hidden;
    transition: border-color var(--t-base), transform var(--t-base) var(--ease-smooth);
}

.hero-stat:first-child {
    background: var(--grad-hero-ytm);
    border-color: rgba(99, 102, 241, 0.22);
}

.hero-stat:last-child {
    background: var(--grad-hero-px);
    border-color: rgba(168, 85, 247, 0.2);
}

.hero-stat::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 70%);
    pointer-events: none;
}

/* Glowing orb behind hero cards */
.hero-stat::after {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    right: -20px;
    bottom: -30px;
    filter: blur(40px);
    opacity: 0.25;
    pointer-events: none;
}

.hero-stat:first-child::after  { background: var(--indigo); }
.hero-stat:last-child::after   { background: var(--purple); }

.hero-stat:hover { transform: translateY(-2px); }

.hero-stat .stat-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(255,255,255,0.5);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.hero-stat .stat-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    background: linear-gradient(120deg, #ffffff 20%, #c4b5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-stat .stat-sub {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.35);
    margin-top: 0.5rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* =========================================================
   Stat Cards
   ========================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1.25rem 1.375rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: all var(--t-base) var(--ease-smooth);
}

.stat-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    border-radius: 0 2px 2px 0;
}

.stat-card.accent-success::before { background: linear-gradient(180deg, var(--emerald), var(--cyan)); }
.stat-card:not(.accent-success)::before { background: var(--grad-primary); }

.stat-card .stat-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.375rem;
}

.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.stat-card.accent-success .stat-value { color: #6ee7b7; }

.stat-card .stat-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* =========================================================
   Charts
   ========================================================= */
.charts-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1rem;
}

@media (max-width: 1280px) {
    .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
    height: 300px;
    display: flex;
    flex-direction: column;
    padding: 1.375rem;
}

.chart-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.chart-title {
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.chart-canvas-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

/* =========================================================
   Pricing Breakdown
   ========================================================= */
.pricing-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 2rem;
}

.pricing-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.8125rem;
    gap: 0.5rem;
}

.pricing-detail-item:last-child { border-bottom: none; }

.pricing-detail-item span:first-child {
    color: var(--text-muted);
    font-weight: 500;
}

.pricing-detail-item span:last-child {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

/* Section headings inside cards */
.card-section-heading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.card-section-heading svg { flex-shrink: 0; }

/* =========================================================
   Cash Flow Schedule Table
   ========================================================= */
.schedule-container {
    overflow-x: auto;
    margin-top: 0.75rem;
    max-height: 320px;
    overflow-y: auto;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.78rem;
}

.schedule-table thead { position: sticky; top: 0; z-index: 10; }

.schedule-table th {
    background: rgba(6, 9, 17, 0.9);
    backdrop-filter: blur(8px);
    padding: 0.7rem 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    white-space: nowrap;
}

.schedule-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.025);
    color: var(--text-primary);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    vertical-align: middle;
}

.schedule-table tbody tr {
    transition: background var(--t-fast) var(--ease-smooth);
}

.schedule-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.06);
}

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

/* Row status styles */
.schedule-table tbody tr[data-status="past"] td {
    opacity: 0.45;
}

.schedule-table tbody tr[data-status="next"] td {
    background: rgba(16, 185, 129, 0.04);
}

.schedule-table tbody tr[data-status="maturity"] td {
    background: rgba(99, 102, 241, 0.04);
}

.schedule-table tbody tr[data-status="ex-coupon"] td {
    background: rgba(245, 158, 11, 0.04);
}

/* Cash Flow Type Badges */
.cash-flow-type {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: var(--r-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.type-outflow {
    color: #fb7185;
    background: rgba(244, 63, 94, 0.1);
    border-color: rgba(244, 63, 94, 0.2);
}

.type-coupon {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
}

.type-principal {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.type-ex-coupon {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
}

.amount-ex-coupon {
    color: var(--text-muted);
    text-decoration: line-through;
    font-size: 0.72rem;
    margin-right: 0.4rem;
}

.amount-buyer-ex-coupon {
    color: #fbbf24;
    font-weight: 700;
}

/* =========================================================
   Tooltip
   ========================================================= */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-secondary);
    font-size: 8px;
    font-weight: 800;
    cursor: help;
    transition: all var(--t-fast) var(--ease-smooth);
    vertical-align: middle;
    flex-shrink: 0;
}

.tooltip-icon:hover {
    background: rgba(99,102,241,0.2);
    border-color: rgba(99,102,241,0.4);
    color: #a5b4fc;
}

/* =========================================================
   Badges (header & inline)
   ========================================================= */
.badge-live {
    background: rgba(16, 185, 129, 0.13) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    color: #34d399 !important;
}

.badge-live::before {
    background: #10b981 !important;
    box-shadow: 0 0 6px rgba(16,185,129,0.8) !important;
}

.badge-simulated {
    background: rgba(245, 158, 11, 0.13) !important;
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
    color: #fbbf24 !important;
}

.badge-simulated::before {
    background: #f59e0b !important;
    box-shadow: 0 0 6px rgba(245,158,11,0.7) !important;
}

/* =========================================================
   NSDL Search
   ========================================================= */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.clear-btn {
    transition: color var(--t-fast) var(--ease-smooth);
    z-index: 1;
}

.clear-btn:hover { color: var(--rose) !important; }

.search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    max-height: 300px;
    background: rgba(10, 14, 26, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--r-md);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.04);
    z-index: 999;
    overflow-y: auto;
    animation: dropdown-enter var(--t-base) var(--ease-snappy);
}

@keyframes dropdown-enter {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.search-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: all var(--t-fast) var(--ease-smooth);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    position: relative;
}

.search-item:last-child { border-bottom: none; }

.search-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--grad-primary);
    border-radius: 0 2px 2px 0;
    opacity: 0;
    transition: opacity var(--t-fast) var(--ease-smooth);
}

.search-item:hover, .search-item.highlighted {
    background: rgba(99, 102, 241, 0.1);
    padding-left: calc(1rem + 3px);
}

.search-item:hover::before, .search-item.highlighted::before { opacity: 1; }

.search-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.search-item-issuer {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 68%;
}

.search-item-isin {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #a78bfa;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.search-item-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-details {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
    flex-wrap: wrap;
}

.search-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: var(--r-xs);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-coupon {
    background: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-freq {
    background: rgba(99, 102, 241, 0.1);
    color: #c7d2fe;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* =========================================================
   Scrollbars
   ========================================================= */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* =========================================================
   Utility — fade-in for output panels
   ========================================================= */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.outputs-panel > * {
    animation: fade-up 0.4s var(--ease-smooth) both;
}

.outputs-panel > *:nth-child(1) { animation-delay: 0.05s; }
.outputs-panel > *:nth-child(2) { animation-delay: 0.10s; }
.outputs-panel > *:nth-child(3) { animation-delay: 0.15s; }
.outputs-panel > *:nth-child(4) { animation-delay: 0.20s; }
.outputs-panel > *:nth-child(5) { animation-delay: 0.25s; }

/* =========================================================
   Separator (HR)
   ========================================================= */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
    margin: 1.5rem 0;
}

/* =========================================================
   Sticky Result Strip (shows after calculation)
   ========================================================= */
.result-strip {
    display: none; /* shown on mobile only via media query */
    position: sticky;
    top: 64px;
    z-index: 90;
    background: rgba(6, 9, 17, 0.92);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid var(--border);
    padding: 0.625rem 1rem;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s var(--ease-smooth), transform 0.3s var(--ease-smooth);
    pointer-events: none;
}

.result-strip::-webkit-scrollbar { display: none; }

.result-strip.has-data {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.result-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0.875rem;
    min-width: max-content;
    flex-shrink: 0;
}

.result-chip-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    margin: 0.125rem 0;
    flex-shrink: 0;
}

.rc-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.rc-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.rc-value.accent-green { color: #6ee7b7; }

/* =========================================================
   Collapsible Sections
   ========================================================= */
.collapsible-section {
    display: flex;
    flex-direction: column;
}

.collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0.875rem 1.125rem;
    cursor: pointer;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    transition: all var(--t-base) var(--ease-smooth);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.collapse-toggle:hover {
    background: var(--bg-surface-2);
    border-color: var(--border-strong);
}

.collapse-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collapse-chevron {
    flex-shrink: 0;
    transition: transform var(--t-base) var(--ease-smooth);
    color: var(--text-muted);
}

.collapsible-section.collapsed .collapse-chevron {
    transform: rotate(180deg);
}

.collapsible-body {
    overflow: hidden;
    transition: max-height 0.35s var(--ease-smooth);
    display: flex;
    flex-direction: column;
    gap: 0; /* handled by children */
}

/* =========================================================
   Floating Action Button (mobile only)
   ========================================================= */
.fab {
    display: none;
    position: fixed;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    right: 1.25rem;
    z-index: 200;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--grad-primary);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.6), 0 0 0 1px rgba(99,102,241,0.4);
    transition: all var(--t-base) var(--ease-snappy);
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fab:hover, .fab:active {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.8);
}

.fab:active { transform: scale(0.95); }

/* =========================================================
   MOBILE — Main breakpoints
   ========================================================= */

/* ── ≤ 1100px: Stack side-by-side to full column ── */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── ≤ 768px: Tablet portrait ── */
@media (max-width: 768px) {
    /* Layout */
    main {
        padding: 1rem;
        padding-bottom: 5.5rem; /* space for FAB */
    }

    .dashboard-grid { gap: 1rem; }

    /* Header */
    header { height: 56px; padding: 0 1rem; }
    .logo-text h1 { font-size: 1rem; }
    .logo-text p  { display: none; }
    .logo-icon    { width: 32px; height: 32px; border-radius: 9px; }
    .logo-icon svg { width: 15px; height: 15px; }
    .badge#conventionBadge { display: none; }

    /* Result strip becomes visible */
    .result-strip {
        display: flex;
        top: 56px;
    }

    /* Cards */
    .card { padding: 1.25rem; border-radius: var(--r-md); }
    .input-card { border-radius: var(--r-md); }

    /* Hero stats: 2 side by side, smaller */
    .main-metrics { gap: 0.75rem; }
    .hero-stat { padding: 1.125rem 1.25rem; border-radius: var(--r-md); }
    .hero-stat .stat-value {
        font-size: clamp(1.375rem, 5vw, 2rem);
    }
    .hero-stat .stat-sub { display: none; }

    /* Secondary stats */
    .stats-grid { gap: 0.75rem; }
    .stat-card  { padding: 1rem 1.125rem; border-radius: var(--r-md); }
    .stat-card .stat-value { font-size: 1.25rem; }

    /* Charts */
    .charts-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .chart-card  { height: 220px; padding: 1.125rem; }

    /* Collapsible sections */
    .collapsible-section { gap: 0.625rem; }
    .collapse-toggle { padding: 0.75rem 1rem; font-size: 0.8125rem; }

    /* Collapsible body spacing */
    .collapsible-body .card { margin-top: 0.5rem; }
    .collapsible-body .charts-grid { margin-top: 0.5rem; }

    /* Pricing breakdown → 2 col */
    .pricing-breakdown { grid-template-columns: 1fr 1fr; gap: 0 1rem; }

    /* Schedule table */
    .schedule-container { max-height: 260px; }
    .schedule-table th,
    .schedule-table td { padding: 0.5rem 0.75rem; font-size: 0.7rem; }

    /* Tabs: bigger touch targets */
    .tabs-container { margin-bottom: 1.25rem; }
    .tab-btn { padding: 0.75rem 0.5rem; font-size: 0.8rem; }

    /* Form */
    .form-group { margin-bottom: 1rem; }
    label { font-size: 0.65rem; }
    .input-wrapper input,
    .input-wrapper select {
        padding: 0.8rem 1rem;
        font-size: 0.9375rem; /* 15px — prevents iOS zoom */
        border-radius: var(--r-sm);
    }

    /* Slider — bigger thumb for touch */
    input[type="range"] { height: 4px; }
    input[type="range"]::-webkit-slider-thumb {
        width: 22px;
        height: 22px;
    }

    /* Button */
    .btn-primary { padding: 0.9375rem; font-size: 0.9375rem; margin-top: 1.125rem; }

    /* FAB */
    .fab { display: flex; }

    /* Formula: smaller */
    .formula-doc { font-size: 0.72rem; padding: 0.75rem; }

    /* Outputs panel animations: disable on mobile for perf */
    .outputs-panel > * { animation: none; }
}

/* ── ≤ 480px: Small phones ── */
@media (max-width: 480px) {
    main { padding: 0.75rem; padding-bottom: 5.5rem; }
    .dashboard-grid { gap: 0.75rem; }

    /* Header */
    header { padding: 0 0.875rem; }

    /* Card */
    .card { padding: 1rem; }

    /* Hero stats: keep 2 col but more compact */
    .main-metrics { gap: 0.625rem; }
    .hero-stat { padding: 1rem; }
    .hero-stat .stat-value { font-size: clamp(1.25rem, 6vw, 1.75rem); }
    .hero-stat .stat-label { font-size: 0.6rem; }

    /* Stats */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.625rem; }
    .stat-card  { padding: 0.875rem 1rem; }
    .stat-card .stat-value { font-size: 1.125rem; }
    .stat-card .stat-sub   { font-size: 0.6rem; }

    /* Charts */
    .chart-card  { height: 190px; }

    /* row-2 stays 2 col down to 360px for dates/coupon */
    .form-group.row-2 { gap: 0.625rem; }

    /* Pricing: single column on tiny phones */
    .pricing-breakdown { grid-template-columns: 1fr; gap: 0; }

    /* Schedule: compressed */
    .schedule-table th,
    .schedule-table td { padding: 0.45rem 0.6rem; font-size: 0.67rem; }

    /* FAB size */
    .fab { width: 52px; height: 52px; right: 1rem; }

    /* Collapse toggle */
    .collapse-toggle { padding: 0.7rem 0.875rem; font-size: 0.775rem; }
    .collapse-title svg { display: none; } /* save space */

    /* Result strip */
    .rc-value { font-size: 0.75rem; }
    .rc-label { font-size: 0.57rem; }
    .result-chip { padding: 0 0.625rem; }
}

/* ── ≤ 360px: Very small phones ── */
@media (max-width: 360px) {
    .main-metrics { grid-template-columns: 1fr; }
    .stats-grid   { grid-template-columns: 1fr; }
    .form-group.row-2 { grid-template-columns: 1fr; }
}

/* =========================================================
   Touch / Hover: remove hover states on touch devices
   ========================================================= */
@media (hover: none) {
    .card:hover         { transform: none; border-color: var(--border); }
    .hero-stat:hover    { transform: none; }
    .stat-card:hover    { transform: none; border-color: var(--border); }
    .btn-primary:hover  { transform: none; }
    .search-item:hover  { background: rgba(99,102,241,0.12); }
}

/* =========================================================
   iOS Safe Area insets
   ========================================================= */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    main {
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
    }
    .fab {
        bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
}

/* =========================================================
   Print: hide chrome, show content
   ========================================================= */
@media print {
    header, .fab, .result-strip, .collapse-toggle,
    .btn-primary, .formula-doc, .tabs-container { display: none !important; }
    main { padding: 0; }
    .dashboard-grid { display: block; }
    .collapsible-body { max-height: none !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    body { background: white; color: black; }
}
