/* ==================================================================
   STYLE: Techniczne, kompaktowe, zero "klocków Duplo"
   ================================================================== */
:root {
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-table-header: #f9fafb;
    --bg-table-even: #f9fafb;
    --input-bg: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 14px;
    --sidebar-width: 240px;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --bg-body: #111827;
    --bg-card: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --bg-table-header: #111827;
    --bg-table-even: #1f2937;
    --input-bg: #111827;
}

body { font-family: 'Segoe UI', Tahoma, sans-serif; background-color: var(--bg-body); color: var(--text-main); margin: 0; padding: 0; font-size: 13px; transition: background-color 0.2s, color 0.2s; }

/* UKŁAD MODULARNY */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--bg-card); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; flex-shrink: 0; transition: background-color 0.2s, border-color 0.2s; }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; flex: 1; }
.sidebar-menu li { border-bottom: 1px solid var(--border-color); }
.sidebar-menu a { display: block; padding: 15px 20px; color: var(--text-main); text-decoration: none; font-weight: 600; font-size: 13px; transition: all 0.2s; }
.sidebar-menu a:hover { background: var(--bg-table-even); color: var(--primary-color); }
.sidebar-menu a.active { background: var(--bg-table-even); color: var(--primary-color); border-left: 4px solid var(--primary-color); padding-left: 16px; }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); font-size: 11px; color: var(--text-muted); text-align: center; }
.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; height: 100vh; }
.content-wrapper { padding: 20px; max-width: 1400px; margin: 0 auto; margin-left: 0; width: 100%; box-sizing: border-box; }

/* TOPBAR */
.topbar { display: flex; justify-content: flex-end; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--border-color); background: var(--bg-card); }
.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-main); }
.logo span { color: var(--primary-color); }
.actions { display: flex; gap: 15px; align-items: center; }

/* ALERTY I FORMULARZE KOMPAKTOWE */
.alert { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 15px; font-weight: 500; font-size: 12px; }
.alert-error { background-color: rgba(220, 38, 38, 0.1); color: var(--danger); border: 1px solid rgba(220, 38, 38, 0.2); }
.alert-success { background-color: rgba(22, 163, 74, 0.1); color: var(--success); border: 1px solid rgba(22, 163, 74, 0.2); }

.form-group { margin-bottom: 10px; }
.form-group label { display: block; margin-bottom: 3px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.form-group input, .form-group select { width: 100%; padding: 6px 8px; border: 1px solid var(--border-color); border-radius: var(--radius); background-color: var(--input-bg); color: var(--text-main); font-size: 13px; box-sizing: border-box; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary-color); }

.login-wrapper { max-width: 350px; margin: 10vh auto; background: var(--bg-card); padding: 20px; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid var(--border-color); }

/* STRUKTURA PANELI */
.admin-header { background: #1e293b; color: #fff; padding: 12px 15px; border-radius: var(--radius) var(--radius) 0 0; display: flex; justify-content: space-between; align-items: center; }
.admin-header h2 { margin: 0; font-size: 15px; font-weight: 600; }

.toolbar { background: var(--bg-card); padding: 12px 15px; border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 10px; margin-bottom: 20px; align-items: center; border: 1px solid var(--border-color); border-top: none; flex-wrap: wrap; }
.card { background: var(--bg-card); padding: 20px; border-radius: var(--radius); margin-bottom: 15px; border: 1px solid var(--border-color); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* PRZYCISKI - MAŁE I TECHNICZNE */
.btn { padding: 6px 12px; border: none; border-radius: var(--radius); cursor: pointer; color: white; font-size: 12px; font-weight: 600; transition: opacity 0.2s; white-space: nowrap; text-decoration: none; display: inline-block;}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary-color); }
.btn-dark { background: #4b5563; } 
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-restore { background-color: #8b5cf6; } 
.btn-sm { padding: 4px 8px; font-size: 11px; }

/* TABELE - GĘSTE I ZWARTE */
.table-responsive { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; margin-bottom: 0; }
th, td { border: 1px solid var(--border-color); padding: 8px 10px; text-align: left; color: var(--text-main); }
th { background: var(--bg-table-header); cursor: pointer; font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
tr:nth-child(even) { background: var(--bg-table-even); }

.summary-box { background-color: var(--bg-table-even); border: 1px solid var(--border-color); padding: 15px; border-radius: var(--radius); font-size: 13px; color: var(--text-main); margin-top: 15px; display: flex; gap: 20px; flex-wrap: wrap; align-items: stretch; }
.grand-total { font-size: 16px; color: var(--success); font-weight: 800; border-left: 2px solid var(--border-color); padding-left: 20px; }
.pagination-controls { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 15px; }
#page-info { font-weight: 600; font-size: 12px; color: var(--text-main); }

/* PRZEŁĄCZNIK THEME (Ikony Słońce/Księżyc) */
.theme-toggle-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); transition: all 0.2s; }
.theme-toggle-btn:hover { background-color: var(--bg-table-even); color: var(--primary-color); }
.theme-toggle-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* MODALE (EDYCJA I DIAGNOSTYKA LOGÓW) */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 100; justify-content: center; align-items: center; backdrop-filter: blur(2px); }
.modal-content { background: var(--bg-card); padding: 20px; border-radius: var(--radius); width: 300px; border: 1px solid var(--border-color); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.modal-log-content { background: var(--bg-card); padding: 25px; border-radius: var(--radius); width: 850px; max-width: 95%; max-height: 90vh; border: 1px solid var(--border-color); box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; flex-direction: column; }
.log-details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; padding: 15px; background: var(--bg-table-even); border-radius: var(--radius); border: 1px solid var(--border-color); }
.log-details-grid div strong { color: var(--text-muted); font-size: 11px; text-transform: uppercase; display: block; margin-bottom: 4px; }
.log-format { font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; background: var(--bg-body); padding: 15px; border-radius: var(--radius); color: var(--text-main); border: 1px solid var(--border-color); overflow-y: auto; flex: 1; white-space: pre-wrap; word-break: break-all; margin: 0; }

/* Statusy stanowisk w górnej belce (Pigułki) */
.status-badge {
    background: var(--bg-table-even);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 11px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-online { background-color: var(--success); box-shadow: 0 0 5px var(--success); }
.status-offline { background-color: var(--text-muted); }

.status-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    padding: 2px 4px;
    margin-left: 2px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.status-remove:hover { background: rgba(220, 38, 38, 0.1); color: var(--danger); }

/* Przycisk pobierania z pulsującym "NEW" */
.btn-ext-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--bg-table-even);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    margin-right: 15px;
}
.btn-ext-download:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.badge-new {
    background-color: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
    70% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ==================================================================
   NOWOŚĆ: Animacja nowo dodanego wiersza
   ================================================================== */
@keyframes flash-green {
    0% { background-color: rgba(22, 163, 74, 0.35); }
    100% { background-color: transparent; }
}
.row-new-highlight td {
    animation: flash-green 3.5s ease-out forwards;
}

/* RWD */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
    .main-content { height: auto; }
}

/* ==================================================================== */
/* POTĘŻNE WYMUSZENIE 100% SZEROKOŚCI DLA TABEL I GŁÓWNYCH KONTENERÓW  */
/* ==================================================================== */
html, body { overflow-x: hidden; }
.app-layout { width: 100% !important; max-width: 100% !important; }
.main-content { flex: 1 1 auto !important; width: 100% !important; max-width: 100% !important; overflow-x: hidden !important; }
.content-wrapper { width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; }
.card { width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; }
.table-responsive { width: 100% !important; max-width: 100% !important; overflow-x: auto !important; }
table { width: 100% !important; min-width: 100% !important; table-layout: auto !important; }

/* ==================================================================== */
/* STYLE DLA IKONEK ADMINISTRATORÓW ONLINE                              */
/* ==================================================================== */
.admin-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 12px;
    cursor: help;
    transition: 0.2s;
}
.admin-status-badge:hover {
    background: rgba(0,0,0,0.05);
}
html[data-theme="dark"] .admin-status-badge:hover {
    background: rgba(255,255,255,0.05);
}

/* ==================================================================== */
/* PODŚWIETLANIE WIERSZY TABELI PO NAJECHANIU MYSZKĄ (HOVER)            */
/* ==================================================================== */
#transaction-body tr {
    transition: background-color 0.15s ease-in-out;
}
html[data-theme="light"] #transaction-body tr:hover {
    background-color: rgba(59, 130, 246, 0.08) !important;
}
html[data-theme="dark"] #transaction-body tr:hover {
    background-color: rgba(59, 130, 246, 0.18) !important;
}

/* ==================================================================== */
/* NOWOCZESNE, PŁYWAJĄCE OKIENKA POTWIERDZEŃ (ZAMIAST ALERT/CONFIRM)    */
/* ==================================================================== */
.custom-modal-box {
    max-width: 400px;
    text-align: center;
    padding: 30px 25px;
    border: none !important;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: #1e293b;
}
html[data-theme="light"] .custom-modal-box {
    background: #ffffff;
}

.custom-modal-icon {
    font-size: 45px;
    margin-bottom: 15px;
    line-height: 1;
}

.custom-modal-title {
    margin-top: 0;
    font-size: 19px;
    font-weight: 700;
    color: var(--text-color);
}

.custom-modal-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 25px;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ==================================================================== */
/* CUSTOMOWE KONTROLKI: KALENDARZ I ROZWIJANA LISTA STANOWISK           */
/* ==================================================================== */
.custom-select-wrapper, .custom-datepicker-wrapper {
    position: relative;
    display: inline-block;
    user-select: none;
    font-family: 'Segoe UI', sans-serif;
}

/* ZMIANA: Wygląd pastylki (pill), białe tło, delikatna ramka */
.custom-select-trigger {
    background: #ffffff;
    color: #334155;
    padding: 6px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 50px; /* Kształt pastylki */
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.custom-select-trigger:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: max-content;
    min-width: 100%;
    z-index: 100;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.custom-select-options.open {
    display: flex;
}
.custom-option {
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: 0.2s;
}
.custom-option:last-child { border-bottom: none; }
.custom-option:hover {
    background: #f8fafc;
    color: #3b82f6;
    padding-left: 22px; 
}

/* KALENDARZ */
.custom-calendar-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 18px;
    z-index: 101;
    display: none;
    width: 260px;
}
.custom-calendar-popup.open { display: block; }
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-weight: 800; color: #1e293b; font-size: 15px; }

/* ZMIANA: Przyciski w kalendarzu również jako małe pastylki */
.cal-btn { cursor: pointer; background: #f1f5f9; border: none; border-radius: 50px; padding: 6px 12px; font-weight: bold; color: #475569; transition: 0.2s;}
.cal-btn:hover { background: #e2e8f0; color: #0f172a;}

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-day-name { font-size: 11px; color: #94a3b8; font-weight: 800; margin-bottom: 8px; text-transform: uppercase; }

/* ZMIANA: Wybieranie dni w kalendarzu jako małe kółka/pastylki */
.cal-day { padding: 8px 0; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 50px; color: #334155; position: relative; transition: 0.2s; }
.cal-day:hover { background: #f1f5f9; color: #3b82f6; }
.cal-day.disabled { color: #cbd5e1; cursor: default; font-weight: 400; }
.cal-day.disabled:hover { background: none; color: #cbd5e1; }
.cal-day.selected { background: #3b82f6; color: white; box-shadow: 0 4px 8px rgba(59, 130, 246, 0.4); }

.cal-day.has-data::after { content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; background: #10b981; border-radius: 50%; box-shadow: 0 0 4px rgba(16,185,129,0.8); }
.cal-day.selected.has-data::after { background: white; box-shadow: 0 0 4px rgba(255,255,255,0.8); }

/* Motyw Ciemny */
html[data-theme="dark"] .custom-select-trigger { background: #1e293b; color: #f8fafc; border-color: #334155; }
html[data-theme="dark"] .custom-select-trigger:hover { background: #0f172a; }
html[data-theme="dark"] .custom-select-options, html[data-theme="dark"] .custom-calendar-popup { background: #1e293b; border-color: #334155; }
html[data-theme="dark"] .custom-option { color: #cbd5e1; border-color: #334155; }
html[data-theme="dark"] .custom-option:hover { background: #0f172a; color: #38bdf8; }
html[data-theme="dark"] .cal-header { color: #f8fafc; }
html[data-theme="dark"] .cal-btn { background: #334155; color: #cbd5e1; }
html[data-theme="dark"] .cal-btn:hover { background: #475569; color: #fff; }
html[data-theme="dark"] .cal-day { color: #e2e8f0; }
html[data-theme="dark"] .cal-day:hover { background: #334155; color: #38bdf8; }
html[data-theme="dark"] .cal-day.disabled { color: #475569; }

/* WYŚRODKOWANIE DANYCH TRANSAKCJI */
#transactions-table th, #transactions-table td {
    text-align: center !important;
}