:root {
    --bg-color: #f1f5f9;
    --panel-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, sans-serif; user-select: none; }
body { background: var(--bg-color); color: var(--text-main); height: 100vh; overflow: hidden; }

/* LAYOUT I UKRYWANIE ELEMENTÓW - POPRAWIONE */
.hidden { display: none !important; }
.app-view { display: flex; height: 100vh; width: 100vw; }
#view-pos { flex-direction: row; }
#view-orders { flex-direction: column; } /* POPRAWKA KDS - Nagłówek u góry, treść na dole */

/* KOSZYK (LEWO) */
.cart-panel { width: 350px; min-width: 350px; background: var(--panel-bg); display: flex; flex-direction: column; border-right: 1px solid var(--border-color); z-index: 10; box-shadow: var(--shadow); }
.cart-header { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid var(--border-color); }
.cart-items-container { flex: 1; overflow-y: auto; padding: 10px; background: #f8fafc; }
.cart-footer { padding: 15px; background: var(--panel-bg); border-top: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 15px; }

/* MENU (PRAWO) */
.menu-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-color); }
.menu-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 25px; background: var(--panel-bg); border-bottom: 1px solid var(--border-color); z-index: 10; }
.menu-scroll-area { flex: 1; overflow-y: auto; padding: 25px; }

/* PRZYCISKI I INPUTY */
button { cursor: pointer; border: none; outline: none; font-weight: 600; border-radius: var(--radius-sm); transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 5px; }
.icon-btn { width: 40px; height: 40px; font-size: 20px; background: var(--bg-color); color: var(--text-main); border: 1px solid var(--border-color); }
.icon-btn:hover { background: #e2e8f0; }
.btn-primary { background: var(--primary); color: #fff; padding: 12px 20px; font-size: 15px; }
.btn-primary:active { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text-main); padding: 10px 15px; border: 1px solid var(--border-color); }
.btn-secondary:active { background: var(--bg-color); }
.btn-danger { background: var(--danger); color: #fff; border:none;}

/* ELEMENTY UI KOSZYKA */
.switch-container { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: bold; font-size: 14px; background: var(--bg-color); padding: 8px 12px; border-radius: 20px; border: 1px solid var(--border-color); }
.switch-toggle { width: 34px; height: 18px; background: #ccc; border-radius: 20px; position: relative; transition: 0.3s; }
.switch-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transition: 0.3s; }
.switch-toggle.active { background: var(--success); }
.switch-toggle.active::after { left: 18px; }

.cart-item { background: #fff; padding: 12px; border-radius: var(--radius-sm); margin-bottom: 8px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; cursor: pointer; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.cart-item:active { transform: scale(0.98); }
.cart-item-name { font-weight: 600; font-size: 14px; }
.cart-item-note { font-size: 12px; color: var(--warning); margin-top: 4px; font-style: italic; }
.cart-item-price { font-weight: 700; color: var(--primary); }
.cart-main-note { background: #fff3cd; color: #856404; padding: 10px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 10px; font-weight: bold; cursor:pointer;}

.order-type-tabs { display: flex; background: var(--bg-color); border-radius: var(--radius-sm); padding: 4px; gap: 2px; }
.type-tab { flex: 1; text-align: center; padding: 8px 0; font-size: 12px; font-weight: 600; border-radius: 4px; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.type-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.input-group { display: flex; align-items: center; background: var(--bg-color); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 0 10px; flex: 1; overflow:hidden;}
.input-group i { color: var(--text-muted); font-size: 18px; }
.input-group input, .modern-input { flex: 1; border: none; background: transparent; padding: 10px; font-size: 14px; color: var(--text-main); font-weight: 600; outline: none; }
.order-inputs { display: flex; flex-wrap: wrap; gap: 10px; }
.full-width { flex: 0 0 100%; }

.cart-summary { display: flex; justify-content: space-between; align-items: center; padding-top: 15px; border-top: 2px dashed var(--border-color); }
.sum-text { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.sum-text span { display: block; font-size: 24px; color: var(--text-main); font-weight: 800; }
#btn-add-order { padding: 15px 25px; font-size: 16px; border-radius: var(--radius-md); }

/* MENU */
.qty-selector { display: flex; align-items: center; background: var(--bg-color); border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.qty-selector button { background: transparent; padding: 10px 15px; font-size: 18px; color: var(--text-main); }
.qty-selector span { font-weight: 800; font-size: 18px; width: 40px; text-align: center; }
.qty-selector.big button { padding: 15px 20px; font-size: 24px; }
.qty-selector.big span { font-size: 24px; width: 60px; }

.header-actions { display: flex; gap: 10px; }
.category-title { font-size: 18px; font-weight: 800; margin: 20px 0 10px 0; color: var(--text-main); }
.category-title:first-child { margin-top: 0; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.menu-dish { background: var(--panel-bg); border: 1px solid var(--border-color); padding: 20px 10px; border-radius: var(--radius-md); text-align: center; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.menu-dish:active { transform: scale(0.95); border-color: var(--primary); }

/* KDS WIDOK (ZAMÓWIENIA) - POPRAWKI LAYOUTU */
.kds-header { display: flex; justify-content: space-between; padding: 15px 25px; background: var(--panel-bg); border-bottom: 1px solid var(--border-color); z-index: 10; position: relative; } /* Dodany z-index */
.kds-header-left { display: flex; gap: 10px; }
.kds-filters { display: flex; gap: 15px; }
.kds-container { padding: 25px; overflow-y: auto; flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 20px; background: var(--bg-color); }

/* KDS KARTY */
.kds-card { background: var(--panel-bg); width: 300px; border-radius: var(--radius-md); padding: 15px; box-shadow: var(--shadow); border-top: 5px solid var(--primary); display: flex; flex-direction: column; gap: 12px; position: relative; }
.kds-card.type-dostawa { border-top-color: var(--danger); }
.kds-card.type-wynos { border-top-color: var(--warning); }
.kds-card.type-odbior { border-top-color: var(--success); }
.kds-card.done { opacity: 0.6; border-top-color: var(--text-muted); box-shadow: none; }

.kds-top { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.kds-time { font-size: 26px; font-weight: 900; line-height: 1; }
.kds-id { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.kds-badge { padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: bold; text-transform: uppercase; color: #fff; background: var(--text-muted); }
.kds-badge.w-trakcie { background: var(--warning); color: #000; }
.kds-badge.w-drodze { background: var(--primary); }
.kds-badge.zrealizowane { background: var(--success); }

.kds-meta { background: var(--bg-color); padding: 8px; border-radius: var(--radius-sm); font-size: 13px; color: var(--primary); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.kds-items { font-size: 15px; display:flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.kds-item b { color: var(--primary); font-size: 16px; margin-right: 5px; }
.kds-bottom { margin-top: auto; border-top: 1px solid var(--border-color); padding-top: 15px; display: flex; justify-content: space-between; align-items: center; }
.kds-price { font-weight: 800; font-size: 18px; }

.kds-divider { width: 100%; border-top: 2px dashed #cbd5e1; margin: 10px 0; position: relative; display: flex; justify-content: center; }
.kds-divider span { position: absolute; top: -10px; background: var(--bg-color); padding: 0 15px; color: #94a3b8; font-weight: 800; font-size: 14px; text-transform: uppercase; }

/* CUSTOM DROPDOWN (Zastępuje <select>) */
.custom-select { position: relative; width: 160px; }
.select-trigger { background: var(--panel-bg); border: 1px solid var(--border-color); padding: 10px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.select-trigger::after { content: '\25BC'; font-size: 10px; color: var(--text-muted); }
.select-options { position: absolute; top: calc(100% + 5px); left: 0; width: 100%; background: var(--panel-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 100; display: none; flex-direction: column; overflow: hidden; }
.custom-select.open .select-options { display: flex; }
.select-option { padding: 10px 15px; font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.select-option:hover { background: var(--bg-color); color: var(--primary); }

/* CUSTOM MODALS */
#sys-modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(2px); z-index: 10000; display: flex; justify-content: center; align-items: center; }
.sys-modal { background: var(--panel-bg); width: 400px; max-width: 90%; border-radius: var(--radius-lg); padding: 25px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; gap: 15px; animation: modalPop 0.2s ease-out; }
@keyframes modalPop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sys-modal h3 { font-size: 20px; color: var(--text-main); margin-bottom: 5px; }
.sys-modal p { color: var(--text-muted); font-size: 15px; line-height: 1.5; }
.sys-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.sys-modal-actions.col { flex-direction: column; }
.sys-modal-actions.col button { width: 100%; padding: 15px; }

.variant-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.variant-btn { background: var(--bg-color); border: 1px solid var(--border-color); padding: 15px; border-radius: var(--radius-sm); font-weight: 600; display:flex; flex-direction:column; gap:5px;}
.variant-btn small { color: var(--primary); font-size: 14px; font-weight: 800; }

.payment-methods { display: flex; gap: 10px; }
.pay-btn { flex: 1; padding: 15px; background: var(--bg-color); border: 1px solid var(--border-color); color: var(--text-main); }
.pay-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Loader */
#loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.8); z-index: 10000; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.spinner { width: 50px; height: 50px; border: 5px solid #e2e8f0; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Niezależne Backdrops dla okien modalnych */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(2px); z-index: 999999; display: flex; justify-content: center; align-items: center; }
.modal-backdrop.hidden { display: none !important; }
.modal-box { background: var(--panel-bg); width: 400px; max-width: 90%; border-radius: var(--radius-lg); padding: 25px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; gap: 15px; }

/* Pełnoekranowy edytor i kolumny */
.fullscreen-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: var(--panel-bg); z-index: 50000; display: flex; flex-direction: column; }
.fullscreen-modal.hidden { display: none !important; }
.fs-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px; border-bottom: 1px solid var(--border-color); background: #fff; }
.fs-content { display: flex; flex: 1; overflow: hidden; background: var(--bg-color); gap: 1px; }
.fs-column { flex: 1; background: var(--panel-bg); display: flex; flex-direction: column; overflow: hidden; transition: 0.2s; }
.fs-column.disabled { opacity: 0.35; pointer-events: none; filter: grayscale(30%); background: #f8fafc; }
.fs-col-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: #fff; }
.fs-list { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
/* Style elementów list w edytorze menu */
.editor-item { background: var(--panel-bg); border: 1px solid var(--border-color); padding: 12px 15px; border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.editor-item:hover { border-color: var(--primary); background: #f8fafc; }
.editor-item.active { background: #e0f2fe; border-color: var(--primary); }
.editor-item-actions { display: flex; gap: 8px; }