/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 280px;
    --header-height: 70px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    color: var(--gray-800);
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.reg-number {
    font-size: 12px;
    color: var(--gray-400);
    font-family: 'JetBrains Mono', monospace;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin-bottom: 8px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-section h3 i {
    font-size: 14px;
    color: var(--gray-500);
}

.nav-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--gray-300);
    font-size: 14px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-download {
    width: 100%;
    padding: 12px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-download:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-download i {
    font-size: 16px;
}

.copyright {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.copyright p {
    color: var(--gray-400);
    font-size: 12px;
    margin-bottom: 4px;
    font-weight: 500;
}

.copyright a {
    color: var(--gray-500);
    font-size: 11px;
    text-decoration: none;
    transition: color 0.2s;
}

.copyright a:hover {
    color: var(--gray-300);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
    min-height: 100vh;
}

.content-header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

#doc-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.header-actions {
    display: flex;
    gap: 12px;
}

.btn-print, .btn-pdf {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.btn-print i, .btn-pdf i {
    font-size: 14px;
}

.btn-print:hover, .btn-pdf:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-pdf {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-pdf:hover {
    background: var(--primary-dark);
}

/* Content Body */
.content-body {
    flex: 1;
    padding: 32px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Threshold Table */
.threshold-section {
    margin-bottom: 48px;
}

.threshold-section h2, .calculator-section h2, .cost-section h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 10px;
}

.threshold-section h2 i, .calculator-section h2 i, .cost-section h2 i {
    font-size: 20px;
    color: var(--primary);
}

.threshold-table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.threshold-table {
    width: 100%;
    border-collapse: collapse;
}

.threshold-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.threshold-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
}

.threshold-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
}

.threshold-table tbody tr:hover {
    background: var(--gray-50);
}

.highlight-row {
    background: #fef3c7;
}

.amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    color: var(--gray-900);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge.tier-a {
    background: #d1fae5;
    color: #065f46;
}

.badge.tier-b {
    background: #fed7aa;
    color: #92400e;
}

/* Tier Explanation */
.tier-explanation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 32px;
}

.tier-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tier-a-card {
    border-left: 4px solid var(--secondary);
}

.tier-b-card {
    border-left: 4px solid var(--warning);
}

.tier-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tier-a-card h3 i {
    color: var(--secondary);
}

.tier-b-card h3 i {
    color: var(--warning);
}

.tier-card p {
    color: var(--gray-600);
    margin-bottom: 16px;
    font-size: 14px;
}

.tier-card ul {
    list-style: none;
}

.tier-card li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--gray-700);
    position: relative;
    padding-left: 20px;
}

.tier-card li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--secondary);
    font-weight: bold;
}

/* Calculator Section */
.calculator-section {
    margin-bottom: 48px;
}

.calculator-section h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--gray-900);
}

.formula-intro {
    color: var(--gray-600);
    margin-bottom: 24px;
}

.formula-display {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.formula-box {
    background: var(--gray-50);
    padding: 20px;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.8;
    margin: 16px 0;
    border: 2px solid var(--gray-200);
}

.formula-details {
    margin-top: 24px;
}

.formula-details h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--gray-800);
}

.formula-details ul {
    list-style: none;
}

.formula-details li {
    padding: 8px 0;
    font-size: 14px;
    color: var(--gray-700);
}

/* Calculator Form */
.calculator-form {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.calculator-form h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.calc-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-group input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.calc-result {
    background: var(--gray-50);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--primary);
}

.calc-result h4 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--gray-800);
}

.result-display {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.result-item {
    text-align: center;
}

.result-item span {
    display: block;
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.result-item strong {
    font-size: 20px;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
}

/* Cost Section */
.cost-section {
    margin-bottom: 48px;
}

.cost-section h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--gray-900);
}

.cost-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.cost-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.cost-icon {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--primary);
}

.cost-icon i {
    display: inline-block;
}

.cost-card h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--gray-800);
}

.cost-amount {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
}

.cost-annual {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: 4px;
}

/* Markdown Content Styling */
.markdown-content {
    padding: 32px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.markdown-content h1 {
    font-size: 28px;
    margin-bottom: 24px;
    color: var(--gray-900);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.markdown-content h2 {
    font-size: 22px;
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--gray-800);
}

.markdown-content h3 {
    font-size: 18px;
    margin-top: 24px;
    margin-bottom: 12px;
    color: var(--gray-800);
}

.markdown-content p {
    margin-bottom: 16px;
    line-height: 1.7;
}

.markdown-content ul, .markdown-content ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.markdown-content li {
    margin-bottom: 8px;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
}

.markdown-content th {
    background: var(--gray-50);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--gray-200);
}

.markdown-content td {
    padding: 12px;
    border: 1px solid var(--gray-200);
}

.markdown-content code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background: var(--gray-900);
    color: white;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 24px 0;
}

.markdown-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.markdown-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    margin: 24px 0;
    color: var(--gray-600);
    font-style: italic;
}

/* Print Styles */
@media print {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .header-actions {
        display: none;
    }

    .content-header {
        position: static;
    }

    .content-body {
        padding: 0;
        max-width: 100%;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 101;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    color: var(--gray-400);
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    color: white;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: block;
    }

    .sidebar-close {
        display: flex;
    }

    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-top: 70px;
    }

    .content-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        padding-left: 80px;
    }

    .content-body {
        padding: 20px;
        margin-top: 70px;
    }

    /* Mobile Table Scroll */
    .threshold-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
        box-shadow: 0 0 0 1px var(--gray-200);
    }

    .threshold-table-container:after {
        content: '← Scroll →';
        position: absolute;
        bottom: 10px;
        right: 10px;
        background: var(--primary);
        color: white;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 600;
        opacity: 0.9;
    }

    .threshold-table {
        min-width: 600px;
    }

    /* Mobile Grid Adjustments */
    .calc-inputs {
        grid-template-columns: 1fr;
    }

    .result-display {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tier-explanation {
        grid-template-columns: 1fr;
    }

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

    /* Mobile Typography */
    #doc-title {
        font-size: 20px;
    }

    .header-actions {
        gap: 8px;
    }

    .btn-print, .btn-pdf {
        padding: 8px 12px;
        font-size: 13px;
    }

    .btn-print span, .btn-pdf span {
        display: none;
    }
}

@media (max-width: 640px) {
    .mobile-menu-toggle {
        top: 15px;
        left: 15px;
        padding: 10px 14px;
        font-size: 16px;
    }

    .content-header {
        padding: 15px 15px 15px 70px;
    }

    .content-body {
        padding: 15px;
    }

    #doc-title {
        font-size: 18px;
    }

    .threshold-section h2, .calculator-section h2, .cost-section h2 {
        font-size: 20px;
    }

    /* Touch-friendly navigation */
    .nav-item {
        padding: 12px 16px;
        font-size: 15px;
    }

    /* Mobile Forms */
    .input-group input {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Mobile Cards */
    .tier-card, .cost-card {
        padding: 20px;
    }

    /* Improve button touch targets */
    .btn-download {
        padding: 14px;
        font-size: 15px;
    }

    /* Mobile Table Enhancement */
    .threshold-table {
        font-size: 14px;
    }

    .threshold-table th, .threshold-table td {
        padding: 10px 12px;
    }

    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* Overlay for mobile menu */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

@media (max-width: 1024px) {
    .sidebar-overlay.active {
        display: block;
    }
}