:root {
    --bg-color: #202020;
    --panel-color: #202020;
    --border-color: #333333;
    --text-primary: #e0e0e0;
    --text-highlight: #ffffff;
    --accent-blue: #b71c1c;
    --accent-blue-hover: #8e0000;
    --accent-red: #ff5c5c;
    --accent-green: #00b894;
    --input-bg: #2d2d2d;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-heavy: 0 10px 30px rgba(0, 0, 0, 0.5);
    --radius-main: 8px;
    --radius-sm: 4px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--panel-color);
    /* Match panel color #202020 */
    /* background-image: radial-gradient... REMOVED */
    color: var(--text-primary);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    padding: 0;
    /* Removing padding to fill screen seamlessly if embedding */
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 950px;
    background-color: var(--panel-color);
    border: 1px solid var(--border-color);
    /* Restored border */
    box-shadow: none;
    /* Removed shadow */
    display: flex;
    flex-direction: column;
    border-radius: 0;
    /* Flat look - no radius on container, or keep it? User said "tło całej strony... same jak aplikacji". If seamless, radius might look odd if padding is gone. Let's keep padding on body? */
    /* User said: "strona do około miały ten sam szary kolor" */
    /* Let's keep body padding 40px but remove container shadow/border so it looks like it floats less or blends more. */
    /* Actually, if colors are same, the container edge is invisible unless border is there. */
    /* User said "usuń cienie". If I remove shadow AND border and background is same, where does app end? */
    /* "żeby zarówno okno jak i strona do około miały ten sam szary kolor" implies seamless. */
    overflow: hidden;
}

/* Window Header */
.window-header {
    background-color: #252526;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
}

.window-title {
    font-weight: 600;
    color: var(--text-highlight);
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.window-controls .control {
    margin-left: 12px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.window-controls .control:hover {
    color: var(--text-highlight);
}

.window-controls .control.close:hover {
    color: var(--accent-red);
}

/* Content */
.window-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    max-height: 95vh;
}

/* Sections */
.panel-section {
    border: 1px solid var(--border-color);
    padding: 15px 15px 15px;
    background-color: #252526;
    position: relative;
    border-radius: var(--radius-main);
    box-shadow: var(--shadow-soft);
}

.panel-title {
    position: absolute;
    top: -10px;
    left: 15px;
    background-color: var(--accent-blue);
    padding: 2px 10px;
    font-size: 0.75rem;
    color: white;
    text-transform: uppercase;
    font-weight: 700;
    border-radius: var(--radius-sm);
    letter-spacing: 1px;
    box-shadow: var(--shadow-soft);
}

/* Inputs */
.input-group-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 70px;
    /* Reduced from 150px to fit more on line */
}

.input-wrapper label {
    font-size: 0.75rem;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
}

input,
select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-highlight);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-blue);
    background-color: #333;
    box-shadow: 0 0 0 2px rgba(183, 28, 28, 0.2);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #8e0000);
    color: white;
    width: 100%;
    box-shadow: 0 4px 10px rgba(183, 28, 28, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #d32f2f, #b71c1c);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    border: 1px dashed #555;
    color: #888;
    width: 100%;
    margin-top: 15px;
    padding: 12px;
}

.btn-secondary:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background-color: rgba(183, 28, 28, 0.05);
}

/* Button Alignment & Colors */
.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 20px;
}

.action-bar .btn {
    flex: 1;
    /* Equal sizing */
}

/* Reset Button - Anthracite with Gray Text */
.btn-reset {
    background-color: #2c2c2c;
    /* Anthracite/Dark Gray */
    color: #aaaaaa;
    /* Gray text */
    border: 1px solid #444;
}

.btn-reset:hover {
    background-color: #383838;
    color: #ffffff;
    border-color: #555;
}

/* Order Button - FORCE RED (Overrides btn-success) */
#order-btn {
    width: 100%;
    margin-top: 20px;
    background: linear-gradient(135deg, #b71c1c, #8e0000) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(183, 28, 28, 0.3) !important;
    border: none;
}

#order-btn:hover {
    background: linear-gradient(135deg, #d32f2f, #b71c1c) !important;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .action-bar {
        flex-direction: column;
        /* Stack buttons on mobile */
    }

    .chain-row {
        flex-direction: column;
        /* Stack inputs on mobile */
        align-items: stretch;
    }

    .chain-row .input-wrapper {
        min-width: 100%;
        /* Full width */
    }

    /* Customer Form Stacking */
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
}

/* Chain Row Base Styles */
.chain-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 10px;
    margin-bottom: 15px;
    background-color: #2a2a2a;
    border: 1px solid #3a3a3a;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-window {
    background-color: #252526;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-main);
    width: 90%;
    max-width: 400px;
    padding: 20px;
    box-shadow: var(--shadow-heavy);
    transform: scale(1);
    transition: transform 0.3s;
}

.modal-overlay.hidden .modal-window {
    transform: scale(0.95);
}

.modal-title {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-highlight);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-content {
    margin-bottom: 25px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Results */
.hidden {
    display: none !important;
}

.totals-summary {
    display: flex;
    justify-content: flex-end;
    gap: 30px;
    margin-top: 25px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-highlight);
    border-top: 1px solid #333;
    padding-top: 20px;
    flex-wrap: wrap;
    /* Wrap on small screens */
}

@media (max-width: 900px) {
    .totals-summary {
        font-size: 1rem;
        gap: 15px;
        flex-direction: column;
        align-items: flex-end;
    }
}

#total-gross {
    color: var(--accent-green);
    font-size: 1.4rem;
}

/* Result Blocks */
.result-block {
    background: #2a2a2a;
    border-radius: var(--radius-sm);
    box-shadow: none;
    /* Removed shadow */
    overflow-x: auto;
    /* Allow horizontal scroll for tables */
}

.result-block h3 {
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

table th {
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Form Layout */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row input {
    flex: 1;
}

.panel-subtitle {
    font-size: 0.75rem;
    color: var(--accent-blue);
    margin-top: 25px;
    margin-bottom: 12px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #218c74);
    color: white;
    font-size: 1.1rem;
    padding: 15px;
    margin-top: 20px;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
    border-radius: var(--radius-main);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 184, 148, 0.4);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #202020;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}