* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: #1f2937;
    color: #fff;
}

.menu-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

/* Sidebar pinned to the left edge */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    max-width: 80%;
    background: #111827;
    color: #e5e7eb;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

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

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid #374151;
}

.menu-close {
    background: none;
    border: none;
    color: #e5e7eb;
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-nav a {
    color: #e5e7eb;
    text-decoration: none;
    padding: 14px 16px;
    border-bottom: 1px solid #1f2937;
}

.sidebar-nav a:hover {
    background: #1f2937;
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
    z-index: 40;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Content */
.content {
    padding: 16px;
    max-width: 760px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

h1 {
    font-size: 22px;
    margin: 0 0 16px;
}

.page-header h1 {
    margin: 0;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 14px;
}

.card-narrow {
    max-width: 420px;
    margin: 24px auto;
}

/* Product list */
.product-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.product-name {
    font-size: 17px;
    font-weight: 600;
}

.product-qty {
    font-weight: 600;
    color: #047857;
    white-space: nowrap;
}

.qty-zero {
    color: #b91c1c;
}

.product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: #6b7280;
    font-size: 14px;
    margin: 8px 0;
}

.product-notes {
    font-style: italic;
}

.product-actions {
    margin: 8px 0;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
}

.form label {
    margin: 10px 0 4px;
    font-weight: 500;
    font-size: 14px;
}

.form input,
.form textarea,
.form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.product-card {
    position: relative;
}

.sell-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.btn-custom-sell {
    margin-left: auto;
}

.btn-delete {
    background: #fee2e2;
    color: #991b1b;
    font-size: 18px;
    padding: 6px 10px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 35px;
}

.btn-delete:hover {
    background: #fecaca;
}

.sell-form input {
    width: 80px;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
}

.sell-form select {
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn-sell {
    background: #047857;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Modal (globalny) */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-small {
    max-width: 350px;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

.modal-body {
    padding: 16px;
}

.btn:disabled,
.sell-form input:disabled,
.sell-form select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Flash messages */
.flashes {
    margin-bottom: 16px;
}

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.empty {
    color: #6b7280;
    text-align: center;
    margin-top: 40px;
}

/* Filters */
.filters {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
}

.range-inputs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.range-inputs span {
    display: none;
}

@media (min-width: 400px) {
    .range-inputs {
        flex-wrap: nowrap;
    }
    .range-inputs span {
        display: inline;
    }
}

.range-inputs input {
    width: 100%;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.btn-link {
    font-size: 14px;
    color: #6b7280;
    text-decoration: none;
}

/* Larger screens */
@media (min-width: 768px) {
    .filter-form {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }
    
    .filter-group {
        flex: 1;
        min-width: 150px;
    }
    
    .price-range {
        flex: 1.5;
        min-width: 200px;
    }
    
    .filter-actions {
        margin-top: 0;
        margin-bottom: 2px;
    }

    .content {
        padding: 24px;
    }
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: background 0.2s, opacity 0.2s;
}

.back-to-top:hover {
    background: #1d4ed8;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast-container-top {
    bottom: auto;
    top: 20px;
}

.toast {
    background: #1f2937;
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
    position: relative;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-container-top .toast {
    transform: translateY(-20px);
}

.toast-container-top .toast.show {
    transform: translateY(0);
}

.toast-success {
    border-left: 4px solid #10b981;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-info {
    border-left: 4px solid #2563eb;
    background: #fff;
    color: #1f2937;
}

.toast-content {
    margin-right: 24px;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: currentColor;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.6;
}

.toast-close:hover {
    opacity: 1;
}

.toast-title {
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
}

/* Toast Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    width: 100%;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background: currentColor;
    width: 100%;
    transform-origin: left;
}

.toast-info .toast-progress-bar {
    background: #2563eb;
}

@keyframes toast-progress-anim {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}
