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

.hidden { display: none !important; }

body {
    font-family: Arial, sans-serif;
    font-size: 8pt;
    background-color: #ffffff;
    color: #333;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ============================================
   LOGIN OVERLAY
   ============================================ */
.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a0a08 0%, #3d1208 50%, #000000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.login-box {
    background: white;
    border-radius: 12px;
    width: 360px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-header {
    background: linear-gradient(135deg, #eb3c24 0%, #000000 100%);
    padding: 24px 24px 20px;
    text-align: center;
}

.login-logo-bar {
    width: 48px; height: 4px;
    background: rgba(255,255,255,0.6);
    border-radius: 2px;
    margin: 0 auto 12px;
}

.login-title { color: white; font-size: 16pt; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: rgba(255,255,255,0.75); font-size: 9pt; }

.login-user-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.login-user-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    width: 100%;
}

.login-user-btn:hover { border-color: #eb3c24; background: #fff5f4; }

.login-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #eb3c24, #000);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11pt;
    font-weight: bold;
    flex-shrink: 0;
}

.login-user-info { flex: 1; }
.login-user-name { font-size: 9pt; font-weight: bold; color: #222; }
.login-user-nik { font-size: 7.5pt; color: #888; }

.login-info { padding: 16px; color: #888; font-size: 8pt; text-align: center; line-height: 1.5; }

#login-step-pin, #login-step-set-pin { padding: 20px 24px 24px; }

.login-selected-user {
    text-align: center;
    font-size: 10pt;
    font-weight: bold;
    color: #222;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.login-pin-label { text-align: center; font-size: 8pt; color: #666; margin-bottom: 12px; }

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 20px;
}

.pin-dots span {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: white;
    transition: all 0.15s ease;
}

.pin-dots span.filled { background: #eb3c24; border-color: #eb3c24; }

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.pin-key {
    padding: 0; height: 44px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    font-size: 14pt;
    font-weight: bold;
    color: #222;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-key:hover { background: #f0f7ff; border-color: #eb3c24; }
.pin-key:active { background: #fdecea; transform: scale(0.95); }
.pin-key-back { font-size: 13pt; color: #666; }
.pin-key-ok { background: #eb3c24; color: white; border-color: #eb3c24; font-size: 10pt; }
.pin-key-ok:hover { background: #c92d18; }

.login-error { text-align: center; color: #dc3545; font-size: 8pt; margin-bottom: 8px; font-weight: bold; }

.btn-link {
    background: none; border: none;
    color: #888; font-size: 8pt; cursor: pointer;
    padding: 4px 0; display: block; margin: 0 auto;
    text-decoration: underline;
}

.btn-link:hover { color: #eb3c24; }

/* ============================================
   MAIN UI
   ============================================ */
#main-ui { display: flex; flex-direction: column; position: fixed; top: 0; left: 0; right: 0; bottom: 0; }

.app-header {
    background: linear-gradient(135deg, #eb3c24 0%, #000000 100%);
    color: white;
    padding: 0.6rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.app-title { font-size: 1.3rem; font-weight: 600; }

.header-user { display: flex; align-items: center; gap: 12px; font-size: 8.5pt; color: rgba(255,255,255,0.85); }

.btn-logout {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 7.5pt;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ============================================
   TABS
   ============================================ */
.tab-bar {
    display: flex;
    background-color: white;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 2rem;
    flex-shrink: 0;
}

.tab-btn {
    background: none; border: none;
    padding: 0.75rem 1.5rem;
    font-size: 10pt; font-family: Arial, sans-serif; font-weight: bold;
    cursor: pointer; color: #666;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.tab-btn:hover { color: #eb3c24; background-color: #f8f9fa; }
.tab-btn.active { color: #eb3c24; border-bottom-color: #eb3c24; font-weight: 600; }

/* ============================================
   TAB CONTENT
   ============================================ */
.tab-content { flex: 1; min-height: 0; padding: 0; overflow: hidden; display: none; flex-direction: column; gap: 1rem; }
.tab-content.active { display: flex; padding: 1.5rem 2rem; box-sizing: border-box; }

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.toolbar label { font-weight: bold; white-space: nowrap; }

/* ============================================
   BUTTONS
   ============================================ */
.btn, button {
    padding: 0.4rem 1rem; border: none; border-radius: 6px;
    font-size: 8pt; font-family: Arial, sans-serif; font-weight: bold;
    cursor: pointer; transition: all 0.2s ease;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary, #btn-save-offer { background-color: #eb3c24; color: white; }
.btn-primary:hover, #btn-save-offer:hover { background-color: #c92d18; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(235,60,36,0.3); }
.btn-secondary { background-color: #6c757d; color: white; }
.btn-secondary:hover { background-color: #5a6268; }
.btn-success { background-color: #28a745; color: white; }
.btn-success:hover { background-color: #218838; }
.btn-danger { background-color: #dc3545; color: white; }
.btn-danger:hover { background-color: #c82333; }
.btn-warning { background-color: #ffc107; color: #000; }
.btn-warning:hover { background-color: #e0a800; }
.btn-icon { padding: 0.3rem 0.7rem; font-size: 14px; font-weight: bold; background-color: #6c757d; color: white; border-radius: 6px; line-height: 1; flex-shrink: 0; }
.btn-icon:hover { background-color: #5a6268; }
.btn-small { padding: 3px 8px; font-size: 7pt; margin: 0 2px; }

/* ============================================
   INPUTS
   ============================================ */
input[type="text"], input[type="number"], input[type="date"], select, textarea {
    padding: 0.4rem 0.6rem; border: 1px solid #d1d5db; border-radius: 4px;
    font-size: 8pt; font-family: Arial, sans-serif;
    background: white; color: #333; width: 100%;
    transition: border-color 0.2s ease;
}

input[type="text"]:focus, input[type="number"]:focus,
input[type="date"]:focus, select:focus, textarea:focus {
    outline: none; border-color: #eb3c24;
    box-shadow: 0 0 0 2px rgba(235,60,36,0.12);
}

textarea { resize: vertical; }
.input-with-btn { display: flex; gap: 6px; align-items: center; }
.input-with-btn select, .input-with-btn input { flex: 1; min-width: 0; }

/* ============================================
   TABLES
   ============================================ */
.table-container { background-color: white; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); min-height: 0; }
.data-table { width: 100%; border-collapse: collapse; background: white; }
.data-table thead { background-color: #f8f9fa; }

.data-table thead th {
    position: sticky; top: 0; z-index: 10;
    background-color: #f8f9fa; padding: 0.5rem;
    text-align: left; font-weight: bold; font-family: Arial, sans-serif;
    font-size: 8pt; color: #4b5563; border-bottom: 2px solid #e5e7eb;
    white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.data-table tbody tr { border-bottom: 1px solid #e5e7eb; transition: background-color 0.15s ease; cursor: pointer; }
.data-table tbody tr:hover { background-color: #f0f7ff; }
.data-table tbody tr.selected { background-color: #dbeafe; border-left: 4px solid #3b82f6; }
.data-table tbody td { padding: 0.5rem; color: #374151; font-family: Arial, sans-serif; font-size: 8pt; vertical-align: middle; }

/* ============================================
   FORM SECTION
   ============================================ */
.form-section { background: white; border-radius: 6px; padding: 12px 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); margin-bottom: 10px; flex-shrink: 0; }
.form-section h4 { font-size: 9pt; font-weight: bold; color: #eb3c24; margin-bottom: 8px; padding-bottom: 5px; border-bottom: 1px solid #f0e0de; text-transform: uppercase; letter-spacing: 0.4px; }
.form-group { margin-bottom: 8px; }
.form-group label { display: block; margin-bottom: 3px; font-weight: bold; font-size: 7.5pt; color: #555; }

/* ============================================
   OFERTA LAYOUT
   ============================================ */
.oferta-layout { display: flex; gap: 14px; flex: 1; min-height: 0; overflow: hidden; }
.oferta-col { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; }
.oferta-col:first-child { flex: 0 0 25%; }
.oferta-col:last-child  { flex: 0 0 25%; }
.oferta-actions { display: flex; gap: 8px; margin-top: 8px; flex-shrink: 0; }

.auto-badge {
    display: inline-block;
    font-size: 6.5pt;
    font-weight: bold;
    background: #e8f5e9;
    color: #28a745;
    border: 1px solid #a5d6a7;
    border-radius: 4px;
    padding: 1px 5px;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: 0.3px;
}

/* Rabat */
.rabat-row { display: flex; align-items: center; gap: 10px; }
.rabat-row input { width: 80px !important; }
.rabat-preview { font-size: 8pt; color: #eb3c24; font-weight: bold; white-space: nowrap; }

/* Nagłówek prawej kolumny oferty */
.oferta-right-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #f0e0de;
}

.oferta-right-header h4 {
    border: none;
    margin: 0;
    padding: 0;
}

/* ============================================
   QUILL
   ============================================ */
.ql-toolbar.ql-snow { border-radius: 4px 4px 0 0; border-color: #d1d5db; font-family: Arial, sans-serif; font-size: 8pt; padding: 4px; flex-shrink: 0; }
.ql-container.ql-snow { border-radius: 0 0 4px 4px; border-color: #d1d5db; font-family: Arial, sans-serif; font-size: 8pt; flex: 1; overflow-y: auto; min-height: 0; }
.ql-editor { min-height: 200px; font-size: 8pt; line-height: 1.5; }
#quill-editor { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
.modal-overlay:not(.hidden) { display: flex; }
.modal { background-color: white; padding: 0; border-radius: 8px; width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.modal-wide { max-width: 860px; }
.modal h3 { margin: 0; font-size: 11pt; font-weight: bold; color: white; background: linear-gradient(135deg, #eb3c24 0%, #000000 100%); padding: 14px 20px; border-radius: 8px 8px 0 0; }
.modal-inner { padding: 16px 20px; }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 20px 16px; border-top: 1px solid #e5e7eb; }

/* ============================================
   PRODUCT LINE BADGE
   ============================================ */
.pl-badge-row { display: flex; align-items: center; gap: 10px; background: #f8f9fa; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 12px; margin-bottom: 14px; }
.pl-badge-label { font-size: 8pt; font-weight: bold; color: #555; white-space: nowrap; }
.pl-badge { font-size: 9pt; font-weight: bold; color: white; background: linear-gradient(135deg, #eb3c24 0%, #000000 100%); padding: 3px 12px; border-radius: 12px; flex: 1; }

/* ============================================
   ŚLEDZENIE FORM GRID
   ============================================ */
.sledzenie-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }

/* ============================================
   DETAILS GRID
   ============================================ */
.details-grid { display: grid; grid-template-columns: 190px 1fr; gap: 6px 12px; font-size: 8pt; }
.details-grid .dl { font-weight: bold; color: #555; white-space: nowrap; }
.details-grid .dv { color: #222; }

/* ============================================
   SEARCH
   ============================================ */
#sledzenie-search { max-width: 360px; padding: 0.5rem; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 8pt; transition: border-color 0.2s ease; width: auto; }
#sledzenie-search:focus { outline: none; border-color: #eb3c24; }

/* ============================================
   ACTION BUTTONS
   ============================================ */
.action-btns { display: flex; gap: 4px; }
.action-btns button { padding: 3px 8px; font-size: 7.5pt; }

/* ============================================
   ADMINISTRACJA
   ============================================ */
#uprawnienia-list { display: flex; flex-direction: column; gap: 10px; }

.uprawnienie-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f8f9fa;
    cursor: pointer;
    user-select: none;
}

.uprawnienie-row:hover { background: #f0f7ff; border-color: #eb3c24; }

.uprawnienie-label { flex: 1; font-size: 9pt; font-weight: bold; color: #333; }

.uprawnienie-row input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.uprawnienie-toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    background: #d1d5db;
    border-radius: 10px;
    transition: background 0.2s;
}

.uprawnienie-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.uprawnienie-row input[type="checkbox"]:checked ~ .uprawnienie-toggle-track {
    background: #28a745;
}

.uprawnienie-row input[type="checkbox"]:checked ~ .uprawnienie-toggle-track::after {
    transform: translateX(16px);
}

.admin-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 7pt; font-weight: bold; }
.admin-badge.yes { background: #fdecea; color: #eb3c24; border: 1px solid #f5b5ae; }
.admin-badge.no { background: #f1f1f1; color: #888; border: 1px solid #ddd; }

.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table thead th.sortable:hover { background-color: #e9ecef; }

.data-table thead th.sort-asc::after  { content: ' ▲'; font-size: 7pt; color: #eb3c24; }
.data-table thead th.sort-desc::after { content: ' ▼'; font-size: 7pt; color: #eb3c24; }

/* ============================================
   MENU KONTEKSTOWE
   ============================================ */
.context-menu {
    position: fixed;
    z-index: 5000;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 4px 0;
    min-width: 130px;
}

.context-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 16px;
    background: none;
    border: none;
    border-radius: 0;
    font-size: 8.5pt;
    font-weight: normal;
    color: #333;
    cursor: pointer;
}

.context-menu button:hover { background: #f0f7ff; }
.context-menu .ctx-danger { color: #dc3545; }
.context-menu .ctx-danger:hover { background: #fdecea; }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* ── Analityki ────────────────────────────────────────────── */
.analiza-item { border-left: 3px solid transparent; padding: 10px 14px; cursor: pointer; font-size: 9pt; transition: all .15s; }
.analiza-item:hover { background: #fef2f1; border-left-color: #eb3c24; }
.analiza-item.active { background: #fef2f1; border-left-color: #eb3c24; font-weight: 600; color: #eb3c24; }

/* ── Toast ────────────────────────────────────────────────── */
.toast { background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 9pt; pointer-events: all; box-shadow: 0 4px 12px rgba(0,0,0,.2); max-width: 320px; }
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
