/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.7;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Header Section */
.section:first-child {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 80px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.section:first-child::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.section:first-child .container {
    position: relative;
    z-index: 2;
}

.header-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 20px;
    color: #ffffff;
    text-shadow:
        0 3px 6px rgba(0, 0, 0, 0.8),
        0 6px 12px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(0, 0, 0, 0.3),
        0 1px 0px rgba(255, 255, 255, 0.1);
    animation: fadeInUp 1s ease-out;
    background: rgba(0, 0, 0, 0.35);
    padding: 20px 35px;
    border-radius: 18px;
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.header-subtitle {
    font-size: 1.2rem;
    opacity: 1;
    font-weight: 500;
    color: #f8fafc;
    animation: fadeInUp 1s ease-out 0.2s both;
    text-shadow:
        0 3px 6px rgba(0, 0, 0, 0.8),
        0 6px 12px rgba(0, 0, 0, 0.5),
        0 1px 0px rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.25);
    padding: 12px 24px;
    border-radius: 25px;
    backdrop-filter: blur(5px);
    margin-top: 15px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Header links styling */
.section:first-child a {
    color: #fef3c7;
    text-decoration: underline;
    text-decoration-color: rgba(254, 243, 199, 0.6);
    text-underline-offset: 2px;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.section:first-child a:hover {
    color: #fbbf24;
    text-decoration-color: #fbbf24;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 0 8px rgba(251, 191, 36, 0.4);
    transform: translateY(-1px);
}

.section:first-child a:visited {
    color: #fed7aa;
    text-decoration-color: rgba(254, 215, 170, 0.7);
}

.section:first-child a:visited:hover {
    color: #fb923c;
    text-decoration-color: #fb923c;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 0 8px rgba(251, 146, 60, 0.4);
}

/* Header paragraph text styling */
.section:first-child p {
    color: #f8fafc;
    font-weight: 500;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 4px 8px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(3px);
    margin: 10px auto;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Content Section */
.section:not(:first-child) {
    background: #f8fafc;
    padding: 60px 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Blog Cards */
.blog-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: none;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.blog-card-body {
    padding: 40px;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: 600;
}

h4 {
    font-size: 1.8rem;
    color: #667eea;
    border-left: 4px solid #667eea;
    padding-left: 20px;
    margin-bottom: 30px;
    margin-top: 40px;
}

h4:first-child {
    margin-top: 0;
}

h2 {
    font-size: 2.2rem;
    color: #667eea;
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 2px;
}

p {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #4a5568;
    text-align: justify;
}

/* Lists */
ul {
    margin: 20px 0;
    padding-left: 0;
}

li {
    list-style: none;
    position: relative;
    margin-bottom: 15px;
    padding-left: 30px;
    font-size: 1.1rem;
    color: #4a5568;
}

li::before {
    content: '•';
    color: #667eea;
    font-size: 1.5rem;
    position: absolute;
    left: 0;
    top: -2px;
}

/* Calculator Section - Compact Version */
.blog-card h2 {
    margin-bottom: 25px;
}

/* Calculator Grid Layout */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.calculator-item {
    display: flex;
    flex-direction: column;
}

.calculator-item.full-width {
    grid-column: 1 / -1;
}

/* Calculator Inputs - Compact */
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f7fafc;
    color: #2c3e50;
    margin-bottom: 5px;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

input[type="number"]:hover,
input[type="text"]:hover {
    border-color: #cbd5e0;
    background: white;
}

/* Currency Input Fields */
.currency-input {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    font-weight: 600;
    color: #2d3748;
    text-align: right;
    padding-right: 45px !important;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%) !important;
    border: 2px solid #e2e8f0 !important;
}

.currency-input:focus {
    background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%) !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.currency-input::after {
    content: '₽';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #667eea;
    font-weight: 700;
    font-size: 1.1rem;
    pointer-events: none;
}

/* Container for currency inputs to position the ruble symbol */
.calculator-item {
    position: relative;
}

.calculator-item:has(.currency-input)::after {
    content: '₽';
    position: absolute;
    right: 15px;
    bottom: 18px;
    color: #667eea;
    font-weight: 700;
    font-size: 1.1rem;
    pointer-events: none;
    z-index: 2;
}

/* Auto-format containers - Compact */
.autoformat {
    margin-bottom: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.autoformat:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.autoformat>div:first-child {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.autoformat .formatted {
    font-size: 1.1rem;
    font-weight: 700;
    color: #667eea;
    margin-top: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* Sticky outputs - Compact */
.sticky,
.sticky1 {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.25);
    border: none;
    animation: pulse 2s infinite;
    margin: 0;
    flex-grow: 1;
    min-width: 200px;
}

/* For sticky positioning when needed */
.sticky.is-sticky {
    position: sticky;
    top: 15px;
}

.sticky1.is-sticky {
    position: sticky;
    top: 60px;
}

/* Calculator input labels - Compact */
.calculator-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    line-height: 1.3;
}

/* Стили для кнопки получения ставки ЦБ */
.fetch-rate-btn {
    margin-top: 8px;
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
}

.fetch-rate-btn.loading {
    background: #2196F3;
    color: white;
    cursor: wait;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.fetch-rate-btn.success {
    background: #4CAF50;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.fetch-rate-btn.success:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.fetch-rate-btn.success:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.fetch-rate-btn.error {
    background: #9E9E9E;
    color: #666;
    cursor: not-allowed;
    box-shadow: 0 2px 8px rgba(158, 158, 158, 0.2);
}

.fetch-rate-btn:disabled {
    opacity: 0.6;
}

/* Results section */
.results-section {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid #e2e8f0;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    min-width: 280px;
    flex-shrink: 0;
}

.results-section p {
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

/* Input labels */
.blog-card-body>p:has(input) {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 1rem;
}

/* Label styling for compact calculator */
label.calculator-label {
    display: block;
    margin-bottom: 5px;
}

input[type="number"]::placeholder {
    color: #a0aec0;
    font-style: italic;
    opacity: 0.8;
}

/* Mathematical formulas styling */
.formula {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    margin: 0 2px;
    display: inline-block;
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.formula:hover {
    background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* Block formulas for important expressions */
.formula-block {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 10px 0;
    display: inline-block;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Variable definitions */
.variable {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    background: #f1f5f9;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 2px 6px;
    margin: 0 1px;
    font-weight: 700;
    color: #667eea;
    font-size: 0.95em;
}

/* Simplified mathematical formulas for mobile compatibility */
.math-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.formula-steps {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.formula-step {
    margin: 15px 0;
    text-align: center;
    line-height: 1.8;
}

.formula-step .label {
    font-weight: 600;
    color: #2d3748;
    display: block;
    margin-bottom: 8px;
}

.formula-expression {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Source Code Pro', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    color: #667eea;
    background: #f7fafc;
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-block;
    border: 1px solid #e2e8f0;
    margin: 5px 0;
}

.formula-description {
    font-size: 0.9rem;
    color: #64748b;
    font-style: italic;
    margin-top: 8px;
    text-align: center;
}

/* Simple fraction display using slash notation */
.fraction-simple {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', 'Monaco', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
}

.math-variable {
    font-style: italic;
    font-weight: 600;
    color: #2d3748;
}

/* Large formula display */
.main-formula {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin: 15px 0;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', monospace;
}

/* Responsive design */
@media (max-width: 768px) {
    .header-title {
        font-size: 2rem;
        padding: 16px 28px;
        border-radius: 15px;
    }

    .header-subtitle {
        font-size: 1rem;
        padding: 10px 20px;
        border-radius: 20px;
    }

    .section:first-child {
        padding: 60px 20px;
    }

    .blog-card-body {
        padding: 25px;
    }

    .container {
        width: 95%;
    }

    h4 {
        font-size: 1.4rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    .autoformat {
        padding: 15px;
    }

    .currency-input {
        padding-right: 42px !important;
    }

    .calculator-item:has(.currency-input)::after {
        right: 14px;
        bottom: 16px;
        font-size: 1rem;
    }

    /* Calculator grid on mobile */
    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .calculator-item.full-width {
        grid-column: 1;
    }

    .sticky,
    .sticky1 {
        font-size: 1.1rem;
        padding: 12px 18px;
        margin: 12px 0;
    }

    .results-section {
        padding: 15px;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .result-label {
        min-width: auto;
        margin-bottom: 5px;
    }

    .sticky,
    .sticky1 {
        width: 100%;
        min-width: auto;
    }

    .formula-block {
        font-size: 1rem;
        padding: 10px 14px;
        margin: 8px 0;
    }

    .formula {
        font-size: 0.9rem;
        padding: 3px 6px;
    }

    .variable {
        font-size: 0.85em;
        padding: 1px 4px;
    }

    .math-block {
        padding: 15px;
        margin: 15px 0;
    }

    .formula-steps {
        padding: 15px;
        margin: 15px 0;
    }

    .formula-expression {
        font-size: 1rem;
        padding: 6px 10px;
    }

    .main-formula {
        font-size: 1.1rem;
        padding: 12px 16px;
    }

    .formula-description {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 1.6rem;
        padding: 14px 24px;
        border-radius: 12px;
    }

    .header-subtitle {
        font-size: 0.9rem;
        padding: 8px 18px;
        border-radius: 18px;
    }

    .blog-card-body {
        padding: 20px;
    }

    input[type="number"],
    input[type="text"] {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .currency-input {
        padding-right: 40px !important;
        text-align: right;
    }

    .calculator-item:has(.currency-input)::after {
        right: 12px;
        bottom: 15px;
        font-size: 1rem;
    }

    .fetch-rate-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        margin-top: 6px;
    }

    .navigation-section {
        padding: 30px 15px;
    }

    .navigation-card {
        padding: 15px;
    }

    .home-link {
        padding: 12px 24px;
        font-size: 1rem;
        gap: 10px;
    }

    .sticky,
    .sticky1 {
        font-size: 1rem;
        padding: 10px 15px;
    }

    .calculator-label {
        font-size: 0.85rem;
    }

    .autoformat {
        padding: 12px;
    }

    .autoformat>div:first-child {
        font-size: 0.9rem;
    }

    .autoformat .formatted {
        font-size: 1rem;
        padding: 6px 10px;
    }

    .results-section {
        padding: 12px;
    }

    .result-item {
        gap: 8px;
        margin-bottom: 12px;
    }

    .result-label {
        font-size: 0.85rem;
    }

    .formula-block {
        font-size: 0.95rem;
        padding: 8px 12px;
        margin: 6px 0;
    }

    .formula {
        font-size: 0.85rem;
        padding: 2px 5px;
        margin: 0 1px;
    }

    .variable {
        font-size: 0.8em;
        padding: 1px 3px;
    }

    .math-block {
        padding: 12px;
        margin: 12px 0;
    }

    .formula-steps {
        padding: 12px;
        margin: 12px 0;
    }

    .formula-expression {
        font-size: 0.9rem;
        padding: 5px 8px;
        margin: 8px auto;
        max-width: 280px;
        word-break: break-all;
    }

    .main-formula {
        font-size: 1rem;
        padding: 10px 12px;
        margin: 8px auto;
        max-width: 280px;
    }

    .formula-description {
        font-size: 0.8rem;
        margin-top: 5px;
    }

    .formula-step .label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .fetch-rate-btn {
        padding: 7px 10px;
        font-size: 0.8rem;
        margin-top: 5px;
    }

    .navigation-section {
        padding: 25px 12px;
    }

    .navigation-card {
        padding: 12px;
    }

    .home-link {
        padding: 10px 20px;
        font-size: 0.95rem;
        gap: 8px;
    }

    .home-icon {
        font-size: 1.2rem;
    }
}

/* Additional visual enhancements */
.blog-card:last-child {
    margin-bottom: 0;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Selection colors */
::selection {
    background: rgba(102, 126, 234, 0.2);
    color: #2c3e50;
}

/* Navigation section */
.navigation-section {
    background: #f8fafc;
    padding: 40px 20px;
    border-top: 1px solid #e2e8f0;
}

.navigation-card {
    text-align: center;
    padding: 20px;
}

.home-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.home-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a6fd8 0%, #6b4190 100%);
    text-decoration: none;
    color: white;
}

.home-link:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.home-icon {
    font-size: 1.3rem;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.home-link:hover .home-icon {
    transform: translateX(-3px);
}

.home-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}