/* ═══════════════════════════════════════════
   Design System & Variables
   ═══════════════════════════════════════════ */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.88);
    --bg-card-hover: rgba(255, 255, 255, 0.98);
    --border-color: rgba(99, 102, 241, 0.12);
    --border-hover: rgba(99, 102, 241, 0.3);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --accent-primary: #4f46e5;
    --accent-secondary: #7c3aed;
    --accent-glow: rgba(99, 102, 241, 0.18);

    --success: #059669;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #d97706;
    --danger: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.08);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-card: 0 4px 24px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-glow: 0 0 35px var(--accent-glow);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ═══════════════════════════════════════════
   Background Effects
   ═══════════════════════════════════════════ */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08), transparent 70%);
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.06), transparent 70%);
    bottom: -50px;
    left: -50px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, -30px);
    }
}

/* ═══════════════════════════════════════════
   Container & Layout
   ═══════════════════════════════════════════ */
.container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════
   Header
   ═══════════════════════════════════════════ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rate-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.rate-badge.live {
    border-color: rgba(16, 185, 129, 0.3);
}

.rate-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s ease-in-out infinite;
}

.rate-badge.live .rate-dot {
    background: var(--success);
}

.rate-badge.error .rate-dot {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.85);
    }
}

/* ═══════════════════════════════════════════
   Card Grid
   ═══════════════════════════════════════════ */
.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
}

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

/* ═══════════════════════════════════════════
   Card
   ═══════════════════════════════════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.card-icon-success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════
   Input Group
   ═══════════════════════════════════════════ */
.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-prefix {
    padding: 0 0 0 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
    user-select: none;
}

.input-suffix {
    padding: 0 0.875rem 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    padding: 0.75rem 0.5rem;
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-wrapper input[readonly] {
    color: var(--success);
    cursor: default;
}

/* Remove number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* ═══════════════════════════════════════════
   Refresh Button
   ═══════════════════════════════════════════ */
.btn-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-refresh:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: rotate(90deg);
}

.btn-refresh.spinning svg {
    animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════════════════════════════
   Info Row
   ═══════════════════════════════════════════ */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
}

/* ═══════════════════════════════════════════
   Calculate Button
   ═══════════════════════════════════════════ */
.btn-calculate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    margin-top: auto;
}

.btn-calculate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.btn-calculate:hover::before {
    transform: translateX(100%);
}

.btn-calculate:active {
    transform: translateY(0);
}

/* ═══════════════════════════════════════════
   Results
   ═══════════════════════════════════════════ */
.result-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
}

.result-placeholder p {
    font-size: 0.85rem;
}

.results-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeInUp 0.5s ease;
}

.results-content.hidden {
    display: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.result-item {
    flex: 1;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.result-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-divider {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   Result Boxes
   ═══════════════════════════════════════════ */
.result-box {
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.result-box-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.result-box-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 0.15rem;
}

.result-box-unit {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.result-box-amount {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.result-box-amount .result-box-value {
    color: var(--accent-primary);
}

.result-box-charges {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.result-box-charges .result-box-value {
    color: var(--danger);
}

.result-box-net {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 1.25rem;
}

.result-box-net .result-box-value {
    font-size: 1.6rem;
    color: var(--success);
}

.result-box-net .result-box-unit {
    color: var(--success);
    opacity: 0.7;
}

.negative::before {
    content: '− ';
}

/* ═══════════════════════════════════════════
   Divider Line
   ═══════════════════════════════════════════ */
.result-divider-line {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-hover), transparent);
    margin: 0.25rem 0;
}

/* ═══════════════════════════════════════════
   Shipping Box
   ═══════════════════════════════════════════ */
.result-box-shipping {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.result-box-shipping .result-box-value {
    color: var(--warning);
}

.result-box-shipping .result-box-unit {
    color: var(--warning);
    opacity: 0.6;
}

/* ═══════════════════════════════════════════
   Per KG & Per Percent Items
   ═══════════════════════════════════════════ */
.result-unit {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.result-item-highlight {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
    padding: 0.95rem;
}

.result-item-highlight .result-value {
    color: var(--accent-primary);
    font-size: 1.35rem;
    font-weight: 800;
}

.result-item-final {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
}

.result-item-final .result-value {
    color: var(--success);
    font-size: 1.1rem;
}

.result-item-final .result-unit {
    color: var(--success);
    opacity: 0.7;
}

/* ═══════════════════════════════════════════
   Formula
   ═══════════════════════════════════════════ */
.result-formula {
    text-align: center;
    margin-top: 0.25rem;
}

.result-formula code {
    font-size: 0.72rem;
    color: var(--text-secondary);
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    word-break: break-all;
}

/* ═══════════════════════════════════════════
   Percentage Breakdown Table
   ═══════════════════════════════════════════ */
.card-table {
    margin-top: 1.5rem;
    animation: fadeInUp 0.5s ease;
}

.card-table.hidden {
    display: none;
}

.card-icon-table {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.table-subtitle {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
}

.table-controls-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem 2rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.1rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.margin-input-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.margin-input-row label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.margin-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.margin-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.margin-input-wrapper input {
    width: 60px;
    background: none;
    border: none;
    outline: none;
    padding: 0.4rem 0.5rem;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.margin-suffix {
    padding-right: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.margin-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.purchase-cell {
    color: #db2777 !important;
}

.row-highlight .purchase-cell {
    color: var(--success) !important;
}

.profit-cell {
    color: #d97706 !important;
}

.row-highlight .profit-cell {
    color: var(--success) !important;
}

.zn-breakdown-block {
    margin-bottom: 1rem;
}

.zn-breakdown-title {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 700;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
}

.modal-backdrop.hidden {
    display: none;
}

.modal-panel {
    width: min(1320px, 100%);
    max-height: min(92vh, 920px);
    overflow: auto;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
    padding: 1.25rem;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-header h2 {
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
}

.modal-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem 1.25rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.expense-input-wrapper input {
    width: 110px;
}

.btn-profit {
    background: #ecfdf5;
    color: #047857;
    border-color: rgba(16, 185, 129, 0.25);
}

.btn-excel {
    background: #dcfce7;
    color: #166534;
    border-color: rgba(22, 101, 52, 0.22);
}

.zn-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.zn-summary-card {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
}

.zn-summary-card span {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.zn-summary-card strong {
    color: var(--success);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
}

.modal-table-wrapper {
    overflow-x: auto;
}

.zn-table {
    min-width: 1320px;
}

.zn-table th,
.zn-table td {
    width: auto !important;
}

.profit-loss-statement {
    margin-top: 1rem;
}

.profit-loss-statement h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.statement-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.statement-table th,
.statement-table td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.08);
    text-align: left;
}

.statement-table th {
    width: 45%;
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.statement-table td {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-weight: 800;
}

.statement-profit td,
.statement-profit th {
    background: #ecfdf5;
    color: #047857;
}

.statement-loss td,
.statement-loss th,
.negative-text,
.loss-cell {
    color: var(--danger) !important;
}

.row-loss {
    background: rgba(239, 68, 68, 0.08);
}

.print-zn-report {
    display: none;
}

.table-wrapper {
    overflow-x: visible;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.percent-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.68rem;
}

.percent-table thead {
    background: rgba(99, 102, 241, 0.08);
}

.percent-table th {
    padding: 0.55rem 0.35rem;
    text-align: left;
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
}

.percent-table th:last-child,
.percent-table td:last-child {
    text-align: right;
}

.percent-table td {
    padding: 0.58rem 0.4rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    transition: var(--transition);
    line-height: 1.35;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.percent-table th:nth-child(1),
.percent-table td:nth-child(1) {
    width: 4.5%;
}

.percent-table th:nth-child(2),
.percent-table td:nth-child(2),
.percent-table th:nth-child(3),
.percent-table td:nth-child(3) {
    width: 8%;
}

.percent-table th:nth-child(4),
.percent-table td:nth-child(4),
.percent-table th:nth-child(5),
.percent-table td:nth-child(5),
.percent-table th:nth-child(6),
.percent-table td:nth-child(6),
.percent-table th:nth-child(7),
.percent-table td:nth-child(7),
.percent-table th:nth-child(8),
.percent-table td:nth-child(8),
.percent-table th:nth-child(10),
.percent-table td:nth-child(10) {
    width: 10%;
}

.percent-table th:nth-child(9),
.percent-table td:nth-child(9) {
    width: 11.5%;
}

.percent-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

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

/* Highlighted 50% row */
.percent-table tbody tr.row-highlight {
    background: rgba(16, 185, 129, 0.08);
}

.percent-table tbody tr.row-highlight td {
    color: var(--success);
    font-weight: 600;
    border-bottom-color: rgba(16, 185, 129, 0.15);
}

.pct-badge {
    display: inline-block;
    min-width: 34px;
    text-align: center;
    padding: 0.18rem 0.35rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 600;
}

.row-highlight .pct-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.amount-cell {
    font-weight: 800;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    line-height: 1.35;
}

.profit-cell,
.purchase-cell {
    font-size: 0.82rem;
    line-height: 1.4;
}

/* ═══════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════ */
.footer {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
    margin-top: 1rem;
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .container {
        padding: 1.25rem 1rem;
        max-width: 100%;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .card {
        padding: 1.25rem;
    }

    .card-table {
        padding: 1rem;
    }

    .card-table .card-header,
    .table-header-actions,
    .table-controls-bar,
    .margin-input-row {
        align-items: flex-start;
    }

    .card-table .card-header,
    .table-header-actions {
        gap: 0.65rem;
    }

    .table-header-actions {
        width: 100%;
        margin-left: 0;
    }

    .table-subtitle {
        margin-left: 0;
        white-space: normal;
        line-height: 1.25;
    }

    .table-controls-bar {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .margin-input-row {
        width: 100%;
        gap: 0.5rem;
    }

    .margin-hint {
        width: 100%;
        line-height: 1.3;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .percent-table {
        min-width: 1180px;
        table-layout: fixed;
    }

    .zn-table {
        min-width: 1320px;
    }

    .modal-backdrop {
        align-items: flex-start;
        padding: 0.75rem;
    }

    .modal-panel {
        max-height: calc(100vh - 1.5rem);
        padding: 1rem;
    }

    .modal-header,
    .modal-controls {
        align-items: flex-start;
    }

    .zn-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .result-box-net .result-box-value {
        font-size: 1.3rem;
    }

    .percent-table th,
    .percent-table td {
        padding: 0.5rem 0.45rem;
        font-size: 0.8rem;
    }

    .amount-cell {
        font-size: 0.88rem;
    }
}

@media (max-width: 420px) {
    .container {
        padding: 1rem 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    .header-actions,
    .btn-action {
        width: 100%;
    }

    .btn-action {
        justify-content: center;
    }

    .result-row {
        flex-direction: column;
        align-items: stretch;
    }

    .result-divider {
        display: none;
    }

    .table-wrapper {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }

    .percent-table {
        min-width: 1100px;
    }

    .zn-table {
        min-width: 1280px;
    }

    .zn-summary-grid {
        grid-template-columns: 1fr;
    }

    .modal-controls .btn-action {
        width: 100%;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════
   Action Buttons (Header & Table)
   ═══════════════════════════════════════════ */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.table-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 100px;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    white-space: nowrap;
}

.btn-action:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
    color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.btn-back {
    color: var(--accent-primary);
}

.btn-print {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff !important;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-print:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-print-table {
    padding: 0.32rem 0.75rem;
    font-size: 0.75rem;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff !important;
    border-color: transparent;
}

.btn-print-table:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
    color: #ffffff !important;
}

/* ═══════════════════════════════════════════
   Organized Print & PDF Format
   ═══════════════════════════════════════════ */
.print-only-report {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 2mm;
    }

    html,
    body {
        background: #ffffff !important;
        color: #0f172a !important;
        font-size: 7pt !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.print-main-mode {
        zoom: 0.84;
    }

    body.print-zn-mode {
        zoom: 0.9;
    }

    * {
        box-sizing: border-box !important;
    }

    .bg-grid,
    .glow,
    .btn-action,
    .header,
    .card-grid,
    .footer,
    .table-controls-bar,
    .table-header-actions,
    .modal-backdrop,
    .result-placeholder {
        display: none !important;
    }

    .container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    .print-only-report {
        display: block !important;
        margin-bottom: 1mm;
    }

    .print-zn-report {
        display: none !important;
    }

    body.print-main-mode .print-zn-report {
        display: none !important;
    }

    body.print-zn-mode .print-only-report,
    body.print-zn-mode .card-table {
        display: none !important;
    }

    body.print-zn-mode .print-zn-report {
        display: block !important;
        margin-bottom: 0;
    }

    .print-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        padding-bottom: 0.8mm;
        border-bottom: 1.5px solid #0f172a;
        margin-bottom: 1mm;
    }

    .print-company {
        font-size: 10pt;
        font-weight: 800;
        color: #0f172a;
        margin: 0 0 0.1rem;
        line-height: 1.15;
    }

    .print-doc-title {
        font-size: 6.5pt;
        color: #475569;
        font-weight: 600;
        margin: 0;
        line-height: 1.1;
    }

    .print-meta-block {
        text-align: right;
        font-size: 6.2pt;
        color: #334155;
        line-height: 1.15;
    }

    .print-summary-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 1mm;
        table-layout: fixed;
    }

    .print-summary-table td {
        padding: 0.7mm 1.1mm;
        border: 1px solid #cbd5e1;
        line-height: 1.05;
        vertical-align: middle;
    }

    .print-lbl {
        background: #f8fafc !important;
        color: #475569;
        font-weight: 600;
        font-size: 5.4pt;
        text-transform: uppercase;
        letter-spacing: 0;
        width: 15%;
    }

    .print-val {
        color: #0f172a !important;
        font-weight: 800 !important;
        font-size: 7.2pt !important;
        width: 18.33%;
        font-family: 'JetBrains Mono', 'Fira Code', monospace;
    }

    .highlight-lbl {
        background: #ecfdf5 !important;
        color: #065f46 !important;
        font-weight: 700;
    }

    .highlight-val {
        background: #f0fdf4 !important;
        color: #047857 !important;
        font-weight: 900 !important;
        font-size: 7.7pt !important;
    }

    .print-params-box {
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        gap: 2mm;
        padding: 0.7mm 1.2mm;
        background: #f8fafc !important;
        border: 1px solid #cbd5e1;
        border-radius: 3px;
        margin-bottom: 1mm;
        line-height: 1.05;
    }

    .print-param-item {
        white-space: nowrap;
        font-size: 6.1pt;
    }

    .print-param-formula {
        margin-left: auto;
        white-space: nowrap;
    }

    .param-name {
        font-weight: 700;
        color: #334155;
        margin-right: 0.25rem;
    }

    .param-value {
        font-weight: 800;
        color: #4338ca !important;
        font-size: 6.8pt !important;
        margin-right: 0.35rem;
    }

    .param-note {
        font-size: 5.6pt;
        color: #64748b;
        font-style: italic;
    }

    .font-mono {
        font-family: monospace;
        font-size: 5.8pt;
        color: #0f172a;
        font-weight: 700;
    }

    .print-table-heading {
        font-size: 6.4pt;
        font-weight: 800;
        color: #0f172a;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        margin: 0 0 0.8mm;
        padding-bottom: 0.5mm;
        border-bottom: 1px solid #cbd5e1;
    }

    .card-table {
        margin-top: 0 !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        display: block !important;
        animation: none !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    .card-table .card-header {
        display: none !important;
    }

    .zn-breakdown-block {
        margin-bottom: 2mm !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .zn-breakdown-title {
        margin-bottom: 1mm !important;
        padding: 0 !important;
        background: transparent !important;
        color: #065f46 !important;
        font-size: 7pt !important;
        font-weight: 900 !important;
        border-radius: 0 !important;
    }

    .print-zn-report .print-params-box {
        justify-content: space-between;
    }

    .print-zn-report .profit-loss-statement {
        margin-top: 1mm !important;
    }

    .print-zn-report .profit-loss-statement h3 {
        font-size: 8pt !important;
        margin: 0 0 0.8mm !important;
    }

    .print-zn-report .statement-table {
        width: 100% !important;
        border-collapse: collapse !important;
        border: 1px solid #94a3b8 !important;
    }

    .print-zn-report .statement-table th,
    .print-zn-report .statement-table td {
        padding: 0.8mm 1.4mm !important;
        border: 1px solid #cbd5e1 !important;
        font-size: 7.2pt !important;
        line-height: 1.05 !important;
    }

    .print-zn-report .statement-table th {
        background: #f8fafc !important;
        color: #334155 !important;
        font-weight: 800 !important;
        width: 45% !important;
    }

    .print-zn-report .statement-table td {
        font-family: monospace !important;
        font-weight: 900 !important;
    }

    .print-zn-report .statement-profit th,
    .print-zn-report .statement-profit td {
        background: #dcfce7 !important;
        color: #065f46 !important;
    }

    .print-zn-report .statement-loss th,
    .print-zn-report .statement-loss td,
    .print-zn-report .loss-cell {
        background: #fee2e2 !important;
        color: #991b1b !important;
    }

    .table-wrapper {
        border: 1px solid #94a3b8 !important;
        border-radius: 2px !important;
        overflow: visible !important;
    }

    .percent-table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        font-size: 7pt !important;
    }

    .percent-table th {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        padding: 0.7mm 0.7mm !important;
        border-bottom: 1px solid #64748b !important;
        font-weight: 700 !important;
        font-size: 6pt !important;
        line-height: 1.02 !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }

    .percent-table td {
        padding: 0.62mm 0.65mm !important;
        border-bottom: 1px solid #e2e8f0 !important;
        color: #0f172a !important;
        font-size: 7.2pt !important;
        line-height: 1.05 !important;
        vertical-align: middle !important;
        overflow-wrap: anywhere !important;
    }

    .percent-table td.amount-cell {
        font-size: 7.9pt !important;
        font-weight: 900 !important;
    }

    .pct-badge {
        background: #e0e7ff !important;
        color: #3730a3 !important;
        font-weight: 800 !important;
        padding: 0.35mm 0.65mm !important;
        font-size: 6.5pt !important;
        border-radius: 2px !important;
        line-height: 1.05 !important;
        min-width: 7mm !important;
    }

    .purchase-cell {
        color: #be185d !important;
        font-weight: 800 !important;
        font-size: 7.9pt !important;
    }

    .profit-cell {
        color: #b45309 !important;
        font-weight: 800 !important;
        font-size: 7.9pt !important;
    }

    .percent-table tbody tr.row-highlight {
        background: #dcfce7 !important;
    }

    .percent-table tbody tr.row-highlight td {
        color: #065f46 !important;
        font-weight: 900 !important;
        font-size: 7.4pt !important;
    }

    .percent-table tbody tr.row-highlight .amount-cell,
    .percent-table tbody tr.row-highlight .purchase-cell,
    .percent-table tbody tr.row-highlight .profit-cell {
        font-size: 8pt !important;
        font-weight: 900 !important;
    }

    .percent-table th:nth-child(1),
    .percent-table td:nth-child(1) {
        width: 4% !important;
    }

    .percent-table th:nth-child(2),
    .percent-table td:nth-child(2),
    .percent-table th:nth-child(3),
    .percent-table td:nth-child(3) {
        width: 8% !important;
    }

    .percent-table th:nth-child(4),
    .percent-table td:nth-child(4),
    .percent-table th:nth-child(5),
    .percent-table td:nth-child(5),
    .percent-table th:nth-child(6),
    .percent-table td:nth-child(6),
    .percent-table th:nth-child(7),
    .percent-table td:nth-child(7),
    .percent-table th:nth-child(8),
    .percent-table td:nth-child(8),
    .percent-table th:nth-child(10),
    .percent-table td:nth-child(10) {
        width: 10% !important;
    }

    .percent-table th:nth-child(9),
    .percent-table td:nth-child(9) {
        width: 12% !important;
    }

    .percent-table tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .card-table,
    .table-wrapper,
    .percent-table,
    .print-only-report,
    .print-zn-report {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-before: avoid !important;
        break-before: avoid !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }
}
