:root {
    /* Layout Tokens */
    --container-max: 1100px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

input, textarea, button, select {
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Mode Switch */
.mode-switch-container {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.mode-switch {
    background: var(--bg);
    padding: 6px;
    border-radius: 100px;
    display: flex;
    position: relative;
    width: 280px;
    border: 1px solid var(--border);
}

.mode-btn {
    flex: 1;
    padding: 12px 0;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s;
    color: var(--muted);
}

.mode-btn.active {
    color: white;
}

.mode-glider {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(50% - 6px);
    height: calc(100% - 12px);
    background: var(--sky);
    border-radius: 100px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Transition */
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
}

.container {
    width: 100%;
    max-width: var(--container-max);
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    align-items: start;
}

.app-header {
    width: 100%;
    max-width: var(--container-max);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin: 0 auto 12px;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-main h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0;
    text-transform: uppercase;
}

.header-main h1 span {
    color: var(--sky);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Profile Dropdown */
.profile-dropdown-container {
    position: relative;
    z-index: 100;
}

.profile-active {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

@media (hover: hover) {
    .profile-active:hover {
        border-color: var(--sky);
    }
}

.profile-name {
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 800;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-transform: uppercase;
    width: 110px;
    outline: none;
    cursor: pointer;
}

.profile-active.editing .profile-name {
    cursor: text;
    color: var(--sky);
}

.profile-active.editing #profile-edit-icon {
    color: var(--sky);
    opacity: 1 !important;
}

#profile-chevron {
    font-size: 0.8rem;
    color: var(--muted);
    transition: transform 0.2s;
}

.profile-dropdown-container.open #profile-chevron {
    transform: rotate(180deg);
}

.profile-list {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    min-width: 180px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.profile-item {
    padding: 12px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

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

@media (hover: hover) {
    .profile-item:hover {
        background: var(--sky-dim);
        color: var(--sky);
    }
}

.profile-item.active {
    background: var(--sky);
    color: white;
}

/* Scenario Tabs */
.scenario-tabs {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 800;
    font-size: 0.7rem;
    color: var(--muted);
    min-width: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow);
}

.tab.active {
    border-color: var(--sky);
    background: var(--sky-dim);
    color: var(--sky);
    box-shadow: var(--sky-glow);
}

.tab.editing .edit-icon {
    color: var(--sky);
    opacity: 1 !important;
}

::placeholder {
    color: var(--muted);
    opacity: 0.6;
    font-family: inherit;
}

[data-theme="dark"] ::placeholder {
    color: var(--muted);
    opacity: 0.4;
    font-family: inherit;
}

.tab-name::placeholder,
.profile-name::placeholder {
    opacity: 1 !important;
    color: inherit !important;
}

.tab-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
    border: none;
    background: none;
    color: inherit;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: inherit;
    width: 100%;
    cursor: pointer;
}

.tab.editing .tab-name {
    cursor: text;
}

@media (hover: hover) {
    .tab:hover:not(.active) {
        background: rgba(0,0,0,0.02);
        border-color: var(--border-strong);
    }

    [data-theme="dark"] .tab:hover:not(.active) {
        background: rgba(255,255,255,0.02);
    }
}

/* Right Column */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: fit-content;
    position: sticky;
    top: 40px;
}

/* Summary Panel */
.summary-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.calc-summary-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
    margin-bottom: 24px;
}

.big-stat {
    margin-bottom: 32px;
}

.big-stat label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.big-stat .value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--sky);
    letter-spacing: -1.5px;
}

.summary-breakdown {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    color: var(--text-dim);
}

.breakdown-item span:last-child {
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
    opacity: 0.5;
}

.breakdown-item.final {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    padding-top: 8px;
}

.breakdown-item.final span:last-child {
    color: var(--sky);
    font-weight: 800;
}

/* Main Content */
.main-calc {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

/* Sales Price Header */
.price-input-group {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 40px;
    transition: border-color 0.3s;
}

.price-input-group:focus-within {
    border-color: var(--sky);
}

.price-input-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--sky);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.price-input-wrapper {
    display: flex;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
}

.currency-symbol {
    opacity: 0.3;
    margin-right: 8px;
}

input.main-price {
    background: none;
    border: none;
    color: var(--text);
    width: 100%;
    outline: none;
    font-size: inherit;
    font-weight: inherit;
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-width: 0;
}

.btn-clear {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

@media (hover: hover) {
    .btn-clear:hover {
        border-color: var(--danger);
        color: var(--danger);
    }
}

.btn-clear.btn-danger {
    background: var(--danger);
    color: white !important;
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.items-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 100px 140px 40px;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.input-field {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    outline: none;
    width: 100%;
}

.input-field:focus {
    border-color: var(--sky);
}

/* Toggle Switch */
.type-toggle {
    display: flex;
    background: var(--surface);
    padding: 4px;
    border-radius: 100px;
    gap: 4px;
    width: 100px;
    justify-self: center;
    border: 1px solid var(--border);
}

.toggle-btn {
    flex: 1;
    padding: 4px 8px;
    border-radius: 100px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--muted);
}

.toggle-btn.active[data-type="percent"] {
    background: var(--sky);
    color: white;
    box-shadow: var(--sky-glow);
}

.toggle-btn.active[data-type="flat"] {
    background: var(--sky);
    color: white;
    box-shadow: var(--sky-glow);
}

.remove-btn {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

@media (hover: hover) {
    .remove-btn:hover {
        opacity: 1;
    }
}

.add-btn {
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-dim);
    padding: 16px;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (hover: hover) {
    .add-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
        background: rgba(99, 102, 241, 0.05);
    }
}

/* Print View Default Hidden */
.print-only {
    display: none;
}

@media print {
    /* Hide everything except the print view */
    body > :not(.print-only) {
        display: none !important;
    }
    
    /* Reset body */
    body {
        background: white !important;
        padding: 20px !important;
        margin: 0 !important;
        color: #000 !important;
        display: block !important;
    }
    
    .print-only {
        display: block !important;
    }

    .print-header {
        border-bottom: 2px solid #000;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        padding-bottom: 10px;
        margin-bottom: 30px;
    }

    .print-brand {
        font-size: 24pt;
        font-weight: bold;
        text-transform: uppercase;
    }

    .print-brand span {
        color: #000;
    }

    .print-meta {
        text-align: right;
        font-size: 10pt;
    }

    #print-workspace-name {
        font-weight: bold;
        font-size: 12pt;
        margin-bottom: 4px;
    }

    /* Standard Table Formatting */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 40px;
    }

    .print-table th, .print-table td {
        border: 1px solid #000;
        padding: 10px 12px;
        font-size: 10pt;
    }

    .print-table th {
        background: #f8f8f8 !important; /* Extremely light gray */
        -webkit-print-color-adjust: exact; /* Ensure background prints if enabled */
        font-weight: bold;
        text-transform: uppercase;
        text-align: left;
        border-bottom: 2px solid #000;
    }

    /* Summary Formatting (Bottom Right) */
    .print-summary {
        width: 350px;
        float: right;
        page-break-inside: avoid;
    }

    .print-summary-row {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        font-size: 10pt;
    }

    .print-summary-row.final {
        border-top: 2px solid #000;
        border-bottom: 2px solid #000;
        margin-top: 10px;
        padding: 10px 0;
        font-size: 12pt;
        font-weight: bold;
    }
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
    .summary-panel {
        position: static;
    }
}

