.tool-main {
    padding-top: 100px;
    min-height: 100vh;
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.tool-header {
    text-align: center;
    margin-bottom: 3rem;
}

.tool-header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.tool-header p {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Icon buttons */
.btn-icon {
    background: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
    transition: all 0.3s ease;
    color: var(--text-light);
}

.btn-icon:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

/* Dark mode styles */
body.dark-mode {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --text-dark: #eaeaea;
    --text-light: #b0b0b0;
    --border: #2d2d44;
}

body.dark-mode .tool-main,
body.dark-mode .upload-zone,
body.dark-mode .stat-card,
body.dark-mode .chart-card,
body.dark-mode .breakdown-card,
body.dark-mode .neu-card,
body.dark-mode .cost-modal,
body.dark-mode .history-card,
body.dark-mode .orders-table-section {
    background: var(--bg-secondary, #16213e);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

body.dark-mode .navbar {
    background: rgba(26, 26, 46, 0.95);
}

.upload-section {
    max-width: 700px;
    margin: 0 auto 4rem;
}

.upload-zone {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
    border: 2px dashed var(--neu-dark);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    transform: scale(1.02);
    box-shadow: 0 10px 40px rgba(108, 99, 255, 0.15);
}

.upload-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    box-shadow: 0 8px 25px rgba(108, 99, 255, 0.4);
}

.upload-zone h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-zone p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.upload-buttons {
    margin-bottom: 1.5rem;
}

.upload-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.upload-hint i {
    color: var(--accent);
}

.supported-formats {
    text-align: center;
    margin-top: 2rem;
}

.supported-formats h4 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    font-weight: 600;
}

.format-tags {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.format-tag {
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    font-size: 0.875rem;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.format-tag i {
    color: var(--success);
}

.dashboard-section {
    margin-bottom: 4rem;
}

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

.report-info h2 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.report-info p {
    color: var(--text-light);
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.gradient-bg {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    padding: 1.5rem;
}

.chart-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-family: var(--font-body);
    font-weight: 700;
}

.chart-container {
    height: 250px;
    position: relative;
}

.breakdown-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.breakdown-card {
    padding: 1.5rem;
}

.breakdown-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-family: var(--font-body);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.breakdown-item span:first-child {
    color: var(--text-light);
}

.breakdown-item span:last-child {
    font-weight: 600;
    color: var(--text-dark);
}

.orders-table-section {
    padding: 1.5rem;
    overflow: hidden;
}

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

.table-header h3 {
    font-family: var(--font-body);
    font-weight: 700;
}

.table-search input {
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
    font-family: var(--font-body);
    width: 250px;
}

.table-search input:focus {
    outline: 2px solid var(--accent);
}

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

#ordersTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#ordersTable th {
    background: var(--bg-primary);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    box-shadow: var(--neu-shadow-dark);
}

#ordersTable td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
}

#ordersTable tr:hover {
    background: var(--bg-secondary);
}

.anomaly-section {
    padding: 1.5rem;
    margin-top: 2rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
}

.anomaly-section h3 {
    color: #92400e;
    font-family: var(--font-body);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.anomaly-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.anomaly-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.anomaly-item i {
    color: var(--warning);
}

.history-section {
    margin-bottom: 4rem;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.history-card {
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-card:hover {
    transform: translateY(-5px);
}

.history-card h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-body);
    font-weight: 700;
}

.history-card p {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.history-card .history-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    padding: 2.5rem;
    max-width: 400px;
    width: 90%;
    position: relative;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-content h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.modal-content > p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
    font-family: var(--font-body);
    font-size: 1rem;
}

.form-group input:focus {
    outline: 2px solid var(--accent);
}

.modal-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.loading-spinner {
    display: none;
    text-align: center;
    padding: 3rem;
}

.loading-spinner.active {
    display: block;
}

.file-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(224, 229, 236, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.file-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.file-loading-content {
    text-align: center;
    background: var(--white, #ffffff);
    padding: 3rem;
    border-radius: var(--radius-lg, 24px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.file-loading-content .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-secondary);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.file-loading-content .loading-text {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-dark);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 2rem;
    }
    
    .upload-zone {
        padding: 2rem 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .breakdown-section {
        grid-template-columns: 1fr;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dashboard-actions {
        width: 100%;
    }
    
    .dashboard-actions .btn {
        flex: 1;
    }
    
    .table-search input {
        width: 100%;
    }
    
    .cost-input-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .cost-input-grid.single-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* Workflow Steps */
.workflow-steps {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.workflow-step .step-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
}

.workflow-step span {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-light);
}

/* Cost Modal Section */
.cost-modal-section {
    max-width: 900px;
    margin: 0 auto 4rem;
}

.cost-modal {
    padding: 2.5rem;
}

.cost-modal-header {
    text-align: center;
    margin-bottom: 2rem;
}

.cost-modal-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.cost-modal-header p {
    color: var(--text-light);
}

.cost-input-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.cost-input-grid.single-row {
    grid-template-columns: repeat(4, 1fr);
}

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

.cost-input-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cost-input-group label i {
    color: var(--accent);
}

.cost-input-group small {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.input-with-prefix, .input-with-suffix {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
    overflow: hidden;
}

.input-with-prefix input, .input-with-suffix input {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    width: 100%;
}

.input-with-prefix input:focus, .input-with-suffix input:focus {
    outline: none;
}

.input-with-prefix .prefix, .input-with-suffix .suffix {
    padding: 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
}

.cost-modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.cost-formula-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    font-size: 0.875rem;
    color: var(--text-light);
}

.cost-formula-hint i {
    color: var(--accent);
}

.cost-formula-hint strong {
    color: var(--text-dark);
}

/* Profit Margin Bar */
.profit-margin-bar {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--neu-shadow-dark), var(--neu-shadow-light);
}

.margin-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.margin-label span:first-child {
    font-weight: 600;
    color: var(--text-dark);
}

.margin-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
}

.margin-progress {
    height: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.margin-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%);
    border-radius: 6px;
    transition: width 0.5s ease;
    width: 0%;
}

.margin-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================
   RESPONSIVE DESIGN - ALL SCREENS
   ================================ */

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .tool-main .container {
        max-width: 1320px;
    }
    
    .tool-header h1 {
        font-size: 3.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop & Laptop (1024px - 1399px) */
@media (max-width: 1399px) and (min-width: 1024px) {
    .tool-main .container {
        max-width: 960px;
    }
    
    .tool-header h1 {
        font-size: 3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cost-input-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .cost-input-grid.single-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet Landscape (768px - 1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
    .tool-main {
        padding-top: 90px;
    }
    
    .tool-main .container {
        padding: 0 1.5rem;
    }
    
    .tool-header {
        margin-bottom: 2rem;
    }
    
    .tool-header h1 {
        font-size: 2.5rem;
        margin-bottom: 0.5rem;
    }
    
    .tool-header p {
        font-size: 1rem;
    }
    
    .upload-section {
        max-width: 600px;
        margin-bottom: 3rem;
    }
    
    .upload-zone {
        padding: 2.5rem 2rem;
    }
    
    .upload-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    .upload-zone h3 {
        font-size: 1.25rem;
    }
    
    .workflow-steps {
        gap: 1.5rem;
    }
    
    .workflow-step .step-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .cost-modal-section {
        max-width: 700px;
    }
    
    .cost-modal {
        padding: 2rem;
    }
    
    .cost-input-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .cost-modal-header h2 {
        font-size: 1.5rem;
    }
    
    .dashboard-section {
        margin-bottom: 3rem;
    }
    
    .dashboard-header {
        margin-bottom: 1.5rem;
    }
    
    .report-info h2 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .chart-card {
        padding: 1.25rem;
    }
    
    .chart-container {
        height: 220px;
    }
    
    .breakdown-section {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .breakdown-card {
        padding: 1.25rem;
    }
    
    .profit-margin-bar {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .orders-table-section {
        padding: 1.25rem;
    }
    
    #ordersTable {
        font-size: 0.85rem;
    }
    
    #ordersTable th,
    #ordersTable td {
        padding: 0.75rem 0.625rem;
    }
}

/* Tablet Portrait & Large Phone (481px - 767px) */
@media (max-width: 767px) and (min-width: 481px) {
    .tool-main {
        padding-top: 85px;
    }
    
    .tool-main .container {
        padding: 0 1.25rem;
    }
    
    .tool-header {
        margin-bottom: 1.5rem;
    }
    
    .tool-header h1 {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .tool-header p {
        font-size: 0.95rem;
    }
    
    .upload-section {
        max-width: 100%;
        margin-bottom: 2.5rem;
    }
    
    .upload-zone {
        padding: 2rem 1.5rem;
    }
    
    .upload-icon {
        width: 70px;
        height: 70px;
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }
    
    .upload-zone h3 {
        font-size: 1.15rem;
    }
    
    .upload-zone p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }
    
    .upload-buttons {
        margin-bottom: 1rem;
    }
    
    .upload-hint {
        font-size: 0.8rem;
    }
    
    .format-tags {
        gap: 0.75rem;
    }
    
    .format-tag {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .workflow-steps {
        gap: 1rem;
        margin-top: 1.5rem;
    }
    
    .workflow-step .step-icon {
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }
    
    .workflow-step span {
        font-size: 0.75rem;
    }
    
    .cost-modal-section {
        max-width: 100%;
        margin-bottom: 2.5rem;
    }
    
    .cost-modal {
        padding: 1.5rem;
    }
    
    .cost-modal-header {
        margin-bottom: 1.5rem;
    }
    
    .cost-modal-header h2 {
        font-size: 1.35rem;
    }
    
    .cost-modal-header p {
        font-size: 0.9rem;
    }
    
    .cost-input-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1rem;
    }
    
    .cost-input-group {
        margin-bottom: 0;
    }
    
    .cost-input-group label {
        font-size: 0.8rem;
    }
    
    .cost-input-group label i {
        font-size: 0.75rem;
    }
    
    .cost-input-group small {
        font-size: 0.65rem;
    }
    
    .input-with-prefix input,
    .input-with-suffix input {
        padding: 0.625rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .input-with-prefix .prefix,
    .input-with-suffix .suffix {
        padding: 0.625rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .cost-modal-actions {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .cost-modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .cost-formula-hint {
        font-size: 0.75rem;
        padding: 0.75rem;
        margin-top: 1rem;
    }
    
    .dashboard-section {
        margin-bottom: 2.5rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .report-info h2 {
        font-size: 1.35rem;
    }
    
    .report-info p {
        font-size: 0.85rem;
    }
    
    .dashboard-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .dashboard-actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
        justify-content: center;
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-card {
        padding: 1.25rem;
        flex-direction: row;
        align-items: center;
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.125rem;
    }
    
    .stat-content {
        flex: 1;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.35rem;
    }
    
    .profit-margin-bar {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .margin-label {
        margin-bottom: 0.75rem;
    }
    
    .margin-label span:first-child {
        font-size: 0.9rem;
    }
    
    .margin-value {
        font-size: 1.25rem;
    }
    
    .margin-progress {
        height: 10px;
    }
    
    .margin-scale {
        font-size: 0.65rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .chart-card {
        padding: 1.25rem;
    }
    
    .chart-card h3 {
        font-size: 1rem;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .breakdown-section {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .breakdown-card {
        padding: 1.25rem;
    }
    
    .breakdown-card h3 {
        font-size: 1rem;
    }
    
    .breakdown-item {
        padding: 0.625rem;
        font-size: 0.85rem;
    }
    
    .orders-table-section {
        padding: 1rem;
        overflow-x: scroll;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .table-header h3 {
        font-size: 1rem;
    }
    
    .table-search input {
        width: 100%;
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }
    
    #ordersTable {
        font-size: 0.75rem;
        min-width: 800px;
    }
    
    #ordersTable th,
    #ordersTable td {
        padding: 0.625rem 0.5rem;
        white-space: nowrap;
    }
    
    .anomaly-section {
        padding: 1.25rem;
        margin-top: 1.5rem;
    }
    
    .anomaly-section h3 {
        font-size: 1rem;
    }
    
    .anomaly-item {
        padding: 0.625rem;
        font-size: 0.8rem;
    }
    
    .history-section {
        margin-bottom: 2.5rem;
    }
    
    .history-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .history-card {
        padding: 1.25rem;
    }
}

/* Mobile Portrait (320px - 480px) */
@media (max-width: 480px) {
    .tool-main {
        padding-top: 80px;
    }
    
    .tool-main .container {
        padding: 0 0.875rem;
    }
    
    .tool-header {
        margin-bottom: 1.25rem;
    }
    
    .tool-header h1 {
        font-size: 1.75rem;
        margin-bottom: 0.375rem;
    }
    
    .tool-header p {
        font-size: 0.875rem;
    }
    
    .navbar .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    .navbar .logo {
        font-size: 1.1rem;
    }
    
    .navbar .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .upload-section {
        max-width: 100%;
        margin-bottom: 2rem;
    }
    
    .upload-zone {
        padding: 1.5rem 1rem;
    }
    
    .upload-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin-bottom: 0.875rem;
    }
    
    .upload-zone h3 {
        font-size: 1rem;
    }
    
    .upload-zone p {
        font-size: 0.8rem;
        margin-bottom: 0.875rem;
    }
    
    .upload-buttons {
        margin-bottom: 0.875rem;
    }
    
    .upload-hint {
        font-size: 0.7rem;
        flex-direction: column;
        text-align: center;
    }
    
    .format-tags {
        gap: 0.5rem;
    }
    
    .format-tag {
        padding: 0.25rem 0.625rem;
        font-size: 0.7rem;
    }
    
    .workflow-steps {
        gap: 0.75rem;
        margin-top: 1.25rem;
    }
    
    .workflow-step .step-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .workflow-step span {
        font-size: 0.65rem;
    }
    
    .cost-modal-section {
        max-width: 100%;
        margin-bottom: 2rem;
    }
    
    .cost-modal {
        padding: 1.25rem;
    }
    
    .cost-modal-header {
        margin-bottom: 1.25rem;
    }
    
    .cost-modal-header h2 {
        font-size: 1.15rem;
    }
    
    .cost-modal-header p {
        font-size: 0.8rem;
    }
    
    .cost-input-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin-bottom: 0.875rem;
    }
    
    .cost-input-grid.single-row {
        grid-template-columns: 1fr;
    }
    
    .cost-input-group {
        margin-bottom: 0;
    }
    
    .cost-input-group label {
        font-size: 0.75rem;
    }
    
    .cost-input-group label i {
        font-size: 0.7rem;
    }
    
    .cost-input-group small {
        font-size: 0.6rem;
    }
    
    .input-with-prefix input,
    .input-with-suffix input {
        padding: 0.5rem 0.375rem;
        font-size: 0.875rem;
    }
    
    .input-with-prefix .prefix,
    .input-with-suffix .suffix {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }
    
    .cost-modal-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1.25rem;
    }
    
    .cost-modal-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    .cost-formula-hint {
        font-size: 0.7rem;
        padding: 0.625rem;
        margin-top: 0.875rem;
        flex-direction: column;
        text-align: center;
    }
    
    .dashboard-section {
        margin-bottom: 2rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.875rem;
        margin-bottom: 1.25rem;
    }
    
    .report-info h2 {
        font-size: 1.15rem;
    }
    
    .report-info p {
        font-size: 0.75rem;
    }
    
    .dashboard-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .dashboard-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 0.625rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin-bottom: 1.25rem;
    }
    
    .stat-card {
        padding: 1rem;
        flex-direction: row;
        align-items: center;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .stat-content {
        flex: 1;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 1.15rem;
    }
    
    .profit-margin-bar {
        padding: 1rem;
        margin-bottom: 1.25rem;
    }
    
    .margin-label {
        margin-bottom: 0.625rem;
    }
    
    .margin-label span:first-child {
        font-size: 0.8rem;
    }
    
    .margin-value {
        font-size: 1.1rem;
    }
    
    .margin-progress {
        height: 8px;
    }
    
    .margin-scale {
        font-size: 0.6rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin-bottom: 1.25rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
    
    .chart-card h3 {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    .chart-container {
        height: 180px;
    }
    
    .breakdown-section {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        margin-bottom: 1.25rem;
    }
    
    .breakdown-card {
        padding: 1rem;
    }
    
    .breakdown-card h3 {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    .breakdown-item {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .orders-table-section {
        padding: 0.875rem;
        overflow-x: auto;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.625rem;
    }
    
    .table-header h3 {
        font-size: 0.9rem;
    }
    
    .table-search {
        width: 100%;
    }
    
    .table-search input {
        width: 100%;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    #ordersTable {
        font-size: 0.7rem;
        min-width: 700px;
    }
    
    #ordersTable th,
    #ordersTable td {
        padding: 0.5rem 0.375rem;
    }
    
    .anomaly-section {
        padding: 1rem;
        margin-top: 1.25rem;
    }
    
    .anomaly-section h3 {
        font-size: 0.9rem;
    }
    
    .anomaly-list {
        gap: 0.5rem;
    }
    
    .anomaly-item {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .history-section {
        margin-bottom: 2rem;
    }
    
    .history-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }
    
    .history-card {
        padding: 1rem;
    }
    
    .history-card h4 {
        font-size: 1rem;
    }
    
    .history-card p {
        font-size: 0.75rem;
    }
    
    .empty-state {
        padding: 2rem;
    }
    
    .empty-state i {
        font-size: 3rem;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .modal-content h2 {
        font-size: 1.35rem;
    }
    
    .form-group {
        margin-bottom: 0.875rem;
    }
    
    .form-group label {
        font-size: 0.85rem;
    }
    
    .form-group input {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

/* Loss row highlight in tables */
.loss-row {
    background-color: rgba(239, 68, 68, 0.05) !important;
}

/* Anomaly item types */
.anomaly-item.loss {
    border-left: 3px solid var(--danger);
}

.anomaly-item.low_margin {
    border-left: 3px solid var(--warning);
}

/* Touch-friendly improvements for mobile */
@media (max-width: 767px) {
    .btn,
    .btn-primary,
    .btn-secondary {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .cost-input-group input {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
}