/* MODALS OVERLAY */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 9999 !important;
    display: none; /* JS toggles to flex */
    align-items: center !important;
    justify-content: center !important;
    padding: 24px;
    box-sizing: border-box;
}

.modal .card, .modal-inner {
    background: rgba(26, 29, 36, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 20px !important;
    backdrop-filter: blur(16px) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6) !important;
    animation: modalAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    margin: auto !important;
    width: 100%;
    max-width: 500px;
    position: relative;
    z-index: 10000;
    overflow: hidden;
    padding: 32px !important; /* Ensure consistent generous padding */
}

@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

:root {
    --bg-dark: #0f1115;
    --bg-surface: #1a1d24;
    --bg-surface-hover: #232730;
    --text-primary: #f0f2f5;
    --text-secondary: #9aa0a6;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --border-color: #2e333e;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --shadow-subtle: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.25);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none; /* reset browser default */
}

/* ---- CUSTOM FOCUS RING (tylko klawiatura, nie mysz) ---- */
*:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.75);
    outline-offset: 2px;
    border-radius: inherit;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(155deg, #0e1119 0%, #0f1115 45%, #100f17 100%);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}


/* HEADER */
.header {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    box-shadow: var(--shadow-subtle);
    position: relative;
    overflow: hidden;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 50%, #06b6d4 100%);
    opacity: 0.6;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.logo-name {
    background: linear-gradient(-90deg, #e2e8f0 0%, #94a3b8 25%, #bfdbfe 50%, #94a3b8 75%, #e2e8f0 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.5px;
    animation: textGradientShift 5s linear infinite;
}

@keyframes textGradientShift {
    0% { background-position: 200% center; }
    100% { background-position: 0% center; }
}

.logo-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 6px rgba(59,130,246,0.5));
    align-self: center;
}

.accent {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #0f1115;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    align-self: center;
    box-shadow: 0 1px 6px rgba(251,191,36,0.35);
    margin-left: 2px;
}

.time-display {
    font-variant-numeric: tabular-nums;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-dark);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* CARDS & PANELS */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-subtle);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.accent-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.accent-link:hover {
    color: var(--accent-blue-hover);
    text-decoration: underline;
}


/* CONTROLS (Operator & Device) */
.controls-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-select {
    width: 100%;
    padding: 14px 16px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    appearance: none;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.modern-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ===== OPERATOR CUSTOM DROPDOWN ===== */
.operator-wrapper {
    position: relative;
}

.operator-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.operator-display:hover {
    border-color: var(--accent-blue);
    background: var(--bg-surface-hover);
}

.operator-display.open {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.operator-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0;
    transition: var(--transition);
}

.operator-avatar.empty {
    background: var(--bg-surface-hover);
    color: var(--text-secondary);
    font-size: 1rem;
}


.operator-name {
    flex: 1;
    font-size: 0.975rem;
    font-weight: 500;
    color: var(--text-primary);
}

.operator-name.placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.operator-chevron {
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition: transform 0.25s ease;
}

.operator-display.open .operator-chevron {
    transform: rotate(180deg);
}

.operator-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    border: 1px solid var(--accent-blue);
    border-top: none;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    z-index: 50;
    overflow: hidden;
    display: none;
    animation: dropdownFadeIn 0.15s ease-out;
}

.operator-dropdown-list.open {
    display: block;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.operator-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.operator-option:hover {
    background: var(--bg-surface-hover);
}

.operator-option.selected {
    background: rgba(59, 130, 246, 0.1);
}

.operator-option-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.operator-option-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* TOGGLE BUTTONS */
.toggle-container {
    display: flex;
    gap: 8px;
    background: var(--bg-dark);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.toggle-container input[type="radio"] {
    display: none;
}

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.toggle-container input[type="radio"]:checked + .toggle-btn {
    background: color-mix(in srgb, var(--device-color, #10b981), transparent 85%);
    color: var(--device-color, #10b981);
    border-color: var(--device-color, #10b981);
}

/* WORKSPACE */
.workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (min-width: 900px) {
    .workspace {
        grid-template-columns: 1fr 1fr;
    }
}

/* PARKINGS GRID */
.parkings-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.parking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* ---- SEPARATORY GRUP w siatce parkingów ---- */
.parking-group-separator {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 -2px;
    pointer-events: none;
}

.parking-group-separator.hidden {
    display: none;
}

.parking-group-sep-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.85;
}

.parking-group-sep-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0.7;
}

.parking-group-sep-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
    opacity: 0.6;
}

.parking-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--border-color); /* Overridden inline */
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.parking-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    border-color: rgba(255,255,255,0.1);
}

.parking-card.selected {
    background: linear-gradient(135deg, var(--bg-surface-hover) 0%, #20242e 100%);
    border-color: color-mix(in srgb, var(--card-color, #3b82f6), transparent 55%);
    border-top-color: var(--card-color, #3b82f6) !important;
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--card-color, #3b82f6), transparent 70%),
        0 0 22px color-mix(in srgb, var(--card-color, #3b82f6), transparent 65%),
        0 8px 24px rgba(0, 0, 0, 0.3);
}

.parking-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.parking-name {
    font-size: 1rem;
    font-weight: 500;
}

/* REASONS PANEL */
.reasons-panel {
    background: rgba(26, 29, 36, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.reasons-panel.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.selected-parking-name {
    color: var(--accent-blue);
    font-weight: 700;
}

.reasons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.reason-btn {
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    border-left: 3px solid rgba(59, 130, 246, 0.4);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.reason-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59,130,246,0.07) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.25s;
}

.reason-btn:hover::before {
    opacity: 1;
}

.reason-btn:hover {
    border-color: var(--accent-blue);
    border-left-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.reason-btn:active {
    transform: translateY(0) scale(0.96);
    background: rgba(59, 130, 246, 0.25);
    transition: transform 0.1s;
}

.reason-label {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.3;
}

.reason-shortcut {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.reason-btn:hover .reason-shortcut {
    color: rgba(255,255,255,0.8);
}

/* ---- GEAR ICON on reason button ---- */
.reason-gear-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, color 0.2s;
    z-index: 2;
    padding: 0;
    line-height: 1;
    user-select: none;
}
.reason-btn:hover .reason-gear-btn {
    opacity: 1;
}
.reason-gear-btn:hover {
    background: rgba(59,130,246,0.2);
    color: var(--accent-blue);
    opacity: 1 !important;
}

/* ---- ADD NEW REASON GHOST TILE ---- */
.reason-btn.add-new {
    background: transparent !important;
    border: 1.5px dashed rgba(255, 255, 255, 0.15) !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    opacity: 0.45;
    box-shadow: none !important;
    transform: none !important;
    transition: opacity 0.2s, border-color 0.2s, background 0.2s;
}
.reason-btn.add-new:hover {
    border-color: rgba(255, 255, 255, 0.35) !important;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03) !important;
    opacity: 0.85;
}
.reason-btn.add-new .reason-label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: inherit;
}

/* ---- SHORTCUT BADGE — bottom-right watermark ---- */
.reason-shortcut-badge {
    position: absolute;
    bottom: 5px;
    right: 7px;
    font-size: 0.62rem;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    opacity: 0.38;
    letter-spacing: 0.04em;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.2s;
    line-height: 1;
}
.reason-btn:hover .reason-shortcut-badge {
    opacity: 0.65;
}

/* ---- DYNAMIC SHORTCUT BADGES (Alt Reveal) ---- */
.dynamic-shortcut {
    position: absolute;
    bottom: 4px; /* Slightly lower on the reasons */
    right: 4px;
    background: var(--accent-blue);
    color: white;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: 0.70rem;
    font-weight: 800;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transform: scale(0.6);
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 10;
    text-transform: uppercase;
}

body.show-alt-hints .dynamic-shortcut {
    opacity: 1;
    transform: scale(1);
}

.device-wrapper .dynamic-shortcut {
    top: 4px; 
    bottom: auto; /* Adjust positioning for device badges to be top-right */
}

/* ---- SHORTCUT CAPTURE BOX (focus state) ---- */
#shortcut-capture-box:focus {
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
#shortcut-capture-box.captured {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

/* ---- SHORTCUT LIST ROWS inside modal ---- */
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.shortcut-row-key {
    font-family: monospace;
    font-weight: 600;
    background: rgba(59,130,246,0.15);
    color: var(--accent-blue);
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
.shortcut-row-info {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.shortcut-row-del {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.shortcut-row-del:hover {
    background: rgba(239,68,68,0.15);
    color: var(--accent-red);
}


.shortcut-input-container {
    position: relative;
}

.shortcut-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: monospace;
    outline: none;
    transition: var(--transition);
}

.shortcut-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.custom-suggest-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 1000;
    overflow: hidden;
}

.custom-suggest-item {
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.custom-suggest-item:last-child {
    border-bottom: none;
}

.custom-suggest-item:hover,
.custom-suggest-item.active {
    background: var(--bg-surface-hover);
}

/* LOGS TABLE */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logs-header .section-title {
    margin-bottom: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 8px;
    border-radius: var(--radius-sm);
    vertical-align: middle;
    line-height: 1;
}

.icon-btn:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.table-container {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.modern-table th {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modern-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.modern-table tr:hover td {
    background: var(--bg-dark);
}

.modern-table tr:last-child td {
    border-bottom: none;
}

.time-col {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.font-medium {
    font-weight: 500;
}

.text-muted {
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-in {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.badge-out {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

/* TOAST NOTIFICATION */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--accent-green);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100000;
}

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

.toast.error {
    background: var(--accent-red);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Admin form (also used in modals on index) */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.admin-input:focus {
    border-color: var(--accent-blue);
}

.outline-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.outline-btn:hover {
    background: var(--bg-dark);
    border-color: var(--text-secondary);
}

.primary-btn {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.primary-btn:hover {
    background: var(--accent-blue-hover);
}

/* Action buttons in log table */
.action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    opacity: 0.7;
}

.action-btn:hover {
    opacity: 1;
    background: var(--bg-dark);
}

/* ===== MEMO BOARD (System Interwencji) ===== */

:root {
    --priority-critical: #ef4444;
    --priority-high:     #f97316;
    --priority-medium:   #3b82f6;
    --priority-low:      #6b7280;
}

.memo-board-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-subtle);
}

.memo-board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.memo-board-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.memo-count-badge {
    background: var(--priority-critical);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
    display: none;
    animation: pulse-badge 2s infinite;
}

.memo-count-badge.visible {
    display: inline-block;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.add-memo-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.add-memo-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

/* Memo Grid */
.memo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 2px;
}

.memo-grid::-webkit-scrollbar {
    width: 6px;
}

.memo-grid::-webkit-scrollbar-track {
    background: transparent;
}

.memo-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.memo-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 36px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.memo-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--priority-medium);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition);
    position: relative;
}

.memo-card:hover {
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

.memo-card[data-priority="Krytyczna"] { border-left-color: var(--priority-critical); }
.memo-card[data-priority="Wysoka"]    { border-left-color: var(--priority-high); }
.memo-card[data-priority="Średnia"]   { border-left-color: var(--priority-medium); }
.memo-card[data-priority="Niska"]     { border-left-color: var(--priority-low); }

.memo-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.memo-priority-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 3px 9px;
    border-radius: 999px;
}

.prio-Krytyczna { background: rgba(239,68,68,0.18);  color: var(--priority-critical); }
.prio-Wysoka    { background: rgba(249,115,22,0.18); color: var(--priority-high); }
.prio-Średnia   { background: rgba(59,130,246,0.18); color: var(--priority-medium); }
.prio-Niska     { background: rgba(107,114,128,0.18);color: var(--priority-low); }

.memo-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.memo-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.memo-content {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-primary);
    flex: 1;
    word-break: break-word;
}

.memo-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.memo-action-btn {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.memo-action-btn.resolve-btn:hover {
    background: rgba(16,185,129,0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.memo-action-btn.delete-btn:hover {
    background: rgba(239,68,68,0.12);
    border-color: var(--accent-red);
    color: var(--accent-red);
}


.memo-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    resize: vertical;
    min-height: 90px;
    transition: var(--transition);
    font-family: inherit;
    line-height: 1.5;
}

.memo-textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.priority-select-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.priority-radio { display: none; }

.priority-label {
    text-align: center;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.priority-radio:checked + .priority-label {
    color: white;
    border-color: transparent;
}

.priority-radio[value="Krytyczna"]:checked + .priority-label { background: var(--priority-critical); }
.priority-radio[value="Wysoka"]:checked    + .priority-label { background: var(--priority-high); }
.priority-radio[value="Średnia"]:checked   + .priority-label { background: var(--priority-medium); }
.priority-radio[value="Niska"]:checked     + .priority-label { background: var(--priority-low); }

/* Contextual Memos (below manual input) */
.contextual-memos-container {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom scrollbar for container */
.contextual-memos-container::-webkit-scrollbar {
    width: 4px;
}
.contextual-memos-container::-webkit-scrollbar-track {
    background: transparent;
}
.contextual-memos-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.contextual-memo {
    background: #1e222a;
    border-left: 4px solid var(--accent-blue);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-primary);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: memoSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.contextual-memo[data-priority="Krytyczna"] { border-left-color: var(--priority-critical); }
.contextual-memo[data-priority="Wysoka"]    { border-left-color: var(--priority-high); }
.contextual-memo[data-priority="Średnia"]   { border-left-color: var(--priority-medium); }
.contextual-memo[data-priority="Niska"]     { border-left-color: var(--priority-low); }

.contextual-memo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.contextual-memo-prio {
    padding: 1px 6px;
    border-radius: 4px;
}

.prio-crit-bg { background: rgba(239, 68, 68, 0.2); color: var(--priority-critical); }
.prio-high-bg { background: rgba(249, 115, 22, 0.2); color: var(--priority-high); }
.prio-med-bg  { background: rgba(59, 130, 246, 0.2); color: var(--priority-medium); }
.prio-low-bg  { background: rgba(107, 114, 128, 0.2); color: var(--priority-low); }

@keyframes memoSlideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.memo-alarm-active {
    border-left-color: #ef4444 !important;
    animation: memoAlarmPulse 1.2s ease-in-out infinite !important;
}

.memo-alarm-active[data-priority="Wysoka"] {
    border-left-color: #f97316 !important;
    animation: memoAlarmPulseOrange 1.2s ease-in-out infinite !important;
}

.memo-alarm-active[data-priority="Średnia"],
.memo-alarm-active[data-priority="Niska"] {
    border-left-color: #eab308 !important;
    animation: memoAlarmPulseYellow 1.2s ease-in-out infinite !important;
}

@keyframes memoAlarmPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3), 0 2px 5px rgba(0,0,0,0.2); background: rgba(239, 68, 68, 0.06); }
    50%       { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.5), 0 2px 12px rgba(239,68,68,0.25); background: rgba(239, 68, 68, 0.18); }
}
@keyframes memoAlarmPulseOrange {
    0%, 100% { box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.3), 0 2px 5px rgba(0,0,0,0.2); background: rgba(249, 115, 22, 0.06); }
    50%       { box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.5), 0 2px 12px rgba(249,115,22,0.25); background: rgba(249, 115, 22, 0.18); }
}
@keyframes memoAlarmPulseYellow {
    0%, 100% { box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.3), 0 2px 5px rgba(0,0,0,0.2); background: rgba(234, 179, 8, 0.04); }
    50%       { box-shadow: 0 0 0 6px rgba(234, 179, 8, 0.5), 0 2px 12px rgba(234,179,8,0.25); background: rgba(234, 179, 8, 0.14); }
}

/* ===== EMPTY STATE (prawy panel bez wyboru obiektu/operatora) ===== */
.panel-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
    animation: fadeIn 0.4s ease-out;
    flex: 1;
}

.panel-empty-icon {
    font-size: 3rem;
    opacity: 0.35;
    animation: floatIcon 3s ease-in-out infinite;
    line-height: 1;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-8px); }
}

.panel-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.8;
}

.panel-empty-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
    opacity: 0.5;
    max-width: 200px;
    line-height: 1.5;
}

/* Dotted border on right panel when idle */
.reasons-panel.idle-state {
    border-color: var(--border-color);
    border-style: dashed;
    box-shadow: none;
    display: flex !important;
}

/* ============================================================
   CUSTOM SCROLLBAR
   Smukły, ciemny pasek pasujący do palety BlankGate.
   ============================================================ */

/* Firefox — tylko główny scroll strony */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-dark);
}

/* Chromium / Safari */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

::-webkit-scrollbar-corner {
    background: var(--bg-dark);
}

/* ===== MEMO MODAL ===== */
.memo-date-gone {
    display: none !important;
}

.memo-modal-wide {
    max-width: 610px;
}

.memo-section {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 8px;
}

.memo-section-alarm {
    background: rgba(251,191,36,0.04);
    border-color: rgba(251,191,36,0.15);
}

.memo-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.memo-label-optional {
    font-weight: 400;
    opacity: 0.7;
}

/* Textarea z paddingiem */
.memo-textarea-tall {
    min-height: 80px;
    padding: 12px !important;
    color: rgba(255,255,255,0.85) !important;
}

.memo-alarm-textarea {
    resize: vertical;
    min-height: 85px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.88em;
    line-height: 1.5;
    padding: 12px !important;
    color: rgba(255,255,255,0.85) !important;
}

/* Placeholder kontrast */
.memo-textarea-tall::placeholder,
.memo-alarm-textarea::placeholder {
    color: rgba(255,255,255,0.3);
}

.memo-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}

/* Select z własną strzałką SVG */
.memo-select {
    color: rgba(255,255,255,0.85) !important;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.5)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px !important;
}

.memo-select option {
    color: #fff;
    background: #1a1d24;
}

/* Toggle switch */
.memo-toggle-label {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    margin-bottom: 6px;
    width: fit-content;
}

.memo-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.memo-toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.memo-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.memo-toggle-input:checked + .memo-toggle-track {
    background: var(--accent-blue, #3b82f6);
}

.memo-toggle-input:checked + .memo-toggle-track .memo-toggle-thumb {
    transform: translateX(16px);
}

.memo-toggle-text {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.85);
    user-select: none;
}

.memo-hint {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
    line-height: 1.4;
}

/* Przyciski akcji — spójna wysokość i radius */
.memo-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.memo-btn-cancel,
.memo-btn-save {
    padding: 9px 22px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    height: 38px;
    box-sizing: border-box;
}

.memo-btn-cancel {
    border: 1px solid rgba(255,255,255,0.2);
    background: transparent;
    color: rgba(255,255,255,0.7);
}

.memo-btn-cancel:hover {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.95);
}

.memo-btn-save {
    border: 1px solid transparent;
    background: var(--accent-blue, #3b82f6);
    color: #fff;
}

.memo-btn-save:hover {
    opacity: 0.87;
}

/* =============================================
   MEMO MODAL — nowy design (środek ekranu)
   ============================================= */

.memo-modal-inner {
    max-width: 580px;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 !important;
    overflow: hidden;
}

.memo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.memo-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255,255,255,0.92);
}

.memo-modal-close {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.55);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    font-family: inherit;
}

.memo-modal-close:hover {
    background: rgba(255,255,255,0.13);
    color: rgba(255,255,255,0.9);
}

.memo-modal-inner form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 24px 24px;
    overflow-y: auto;
    max-height: calc(90vh - 60px);
}

.memo-modal-textarea {
    width: 100%;
    min-height: 88px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: rgba(255,255,255,0.9);
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.5;
    padding: 12px 14px;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}

.memo-modal-textarea:focus {
    outline: none;
    border-color: rgba(59,130,246,0.55);
    background: rgba(255,255,255,0.07);
}

.memo-modal-textarea::placeholder { color: rgba(255,255,255,0.25); }

/* Przyciski priorytetu */
.memo-prio-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.memo-prio-btn {
    display: block;
    padding: 9px 4px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    border-left: 3px solid transparent;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.memo-prio-btn[data-priority="Niska"] {
    border-left-color: var(--priority-low);
    color: var(--priority-low);
    background: rgba(107,114,128,0.12);
}
.memo-prio-btn[data-priority="Średnia"] {
    border-left-color: var(--priority-medium);
    color: var(--priority-medium);
    background: rgba(59,130,246,0.10);
}
.memo-prio-btn[data-priority="Wysoka"] {
    border-left-color: var(--priority-high);
    color: var(--priority-high);
    background: rgba(249,115,22,0.10);
}
.memo-prio-btn[data-priority="Krytyczna"] {
    border-left-color: var(--priority-critical);
    color: var(--priority-critical);
    background: rgba(239,68,68,0.10);
}

.priority-radio[value="Niska"]:checked + .memo-prio-btn {
    background: rgba(107,114,128,0.30);
    border-color: var(--priority-low);
    box-shadow: 0 0 0 1px var(--priority-low);
}
.priority-radio[value="Średnia"]:checked + .memo-prio-btn {
    background: rgba(59,130,246,0.28);
    border-color: var(--priority-medium);
    box-shadow: 0 0 0 1px var(--priority-medium);
}
.priority-radio[value="Wysoka"]:checked + .memo-prio-btn {
    background: rgba(249,115,22,0.28);
    border-color: var(--priority-high);
    box-shadow: 0 0 0 1px var(--priority-high);
}
.priority-radio[value="Krytyczna"]:checked + .memo-prio-btn {
    background: rgba(239,68,68,0.28);
    border-color: var(--priority-critical);
    box-shadow: 0 0 0 1px var(--priority-critical);
}

.memo-modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.memo-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Akordeon alarmu */
.memo-alarm-details {
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    overflow: hidden;
}

.memo-alarm-summary {
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.memo-alarm-summary::-webkit-details-marker { display: none; }

.memo-alarm-summary::before {
    content: '▸';
    font-size: 0.68rem;
    color: rgba(255,255,255,0.4);
    transition: transform 0.15s;
    display: inline-block;
}

.memo-alarm-details[open] .memo-alarm-summary::before { transform: rotate(90deg); }

.memo-alarm-body {
    padding: 0 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.memo-alarm-body .memo-alarm-textarea {
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 600px) {
    .memo-modal-row   { grid-template-columns: 1fr; }
    .memo-prio-group  { grid-template-columns: repeat(2, 1fr); }
}

/* =============================================
   RESPONSIVE — breakpointy dla małych ekranów
   ============================================= */

/* Memo grid: wcześniej jedna kolumna już przy 600px */
@media (max-width: 600px) {
    .memo-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 10px;
        gap: 10px;
    }

    /* Modaly: mniejszy padding i pionowy scroll gdy treść nie mieści się na ekranie */
    .modal {
        padding: 12px !important;
        align-items: flex-start !important;
        overflow-y: auto !important;
    }

    .modal .card, .modal-inner {
        padding: 20px !important;
        border-radius: 14px !important;
        max-width: 100% !important;
        margin: auto !important;
    }

    .memo-modal-wide {
        max-width: 100% !important;
    }

    /* Nagłówek: logo + przyciski zawijają się */
    .header-content {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Nagłówek admina: przyciski "Powrót" i "Wyloguj" zawijają się pod logo */
    .header-content > div[style] {
        flex-wrap: wrap;
        gap: 6px;
    }

    .logo {
        font-size: 1.05rem;
    }

    .time-display {
        font-size: 0.85rem;
    }

    /* Workspace: zawsze jedna kolumna */
    .workspace {
        grid-template-columns: 1fr !important;
    }

    /* Controls: węższe pola */
    .controls-panel {
        gap: 14px;
        margin-bottom: 14px;
    }

    /* Siatka parkingów: mniejsze kafelki */
    .parking-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    /* Siatka powodów */
    .reasons-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }

    /* Tabela logów: poziomy scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modern-table {
        min-width: 520px;
    }

    /* Kolumny tabeli logów: min-width żeby się nie zgniatały */
    .modern-table th:nth-child(1),
    .modern-table td:nth-child(1) { min-width: 120px; }
    .modern-table th:nth-child(2),
    .modern-table td:nth-child(2) { min-width: 90px; }
    .modern-table th:nth-child(3),
    .modern-table td:nth-child(3) { min-width: 80px; }
    .modern-table th:nth-child(4),
    .modern-table td:nth-child(4) { min-width: 180px; }

    /* Logi header: zawiń */
    .logs-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Pasek filtrów logów — wiersz 1: każdy element rozciąga się do pełnej szerokości */
    .log-filter-row {
        flex-wrap: wrap;
    }

    .log-filter-select {
        width: 100% !important;
        min-width: unset !important;
    }

    .log-filter-search-wrap {
        max-width: 100% !important;
        flex: 1 1 100%;
    }

    .log-filter-date-range {
        flex: 1 1 100%;
    }

    .log-filter-btn,
    .log-filter-btn-clear {
        flex: 1;
    }

    /* Memo grid: jedna kolumna */
    .memo-grid {
        grid-template-columns: 1fr !important;
    }

    /* Panele: mniejszy padding */
    .card,
    .parkings-panel,
    .controls-panel {
        padding: 14px;
    }

    /* Pole daty/czasu przy wpisie: zawiń etykietę i input */
    .custom-timestamp-row {
        flex-wrap: wrap;
    }

    .custom-timestamp-row label {
        width: 100%;
    }

    .custom-timestamp-row input {
        flex: 1;
        width: auto !important;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 6px;
        gap: 8px;
    }

    /* Modaly: jeszcze mniejszy padding, pełna szerokość */
    .modal {
        padding: 8px !important;
    }

    .modal .card, .modal-inner {
        padding: 16px !important;
        border-radius: 10px !important;
    }

    .logo {
        font-size: 0.95rem;
    }

    /* Ukryj podpis autora na bardzo małych ekranach */
    .logo span[style*="italic"] {
        display: none;
    }

    .time-display {
        font-size: 0.78rem;
    }

    /* Siatka parkingów: 2 kolumny fixed */
    .parking-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Powody: 2 kolumny */
    .reasons-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    /* Tabela: jeszcze mniejszy min-width */
    .modern-table {
        min-width: 420px;
    }

    /* Przyciski nagłówka: tylko ikony */
    .icon-btn {
        font-size: 1rem;
        padding: 6px;
    }

    .card,
    .parkings-panel,
    .controls-panel {
        padding: 10px;
        border-radius: var(--radius-md);
    }
}

/* Dziennik audytu — kolory bloków diff przed/po w modalu szczegółów */
.audit-before {
    color: var(--accent-red);
}
.audit-after {
    color: var(--accent-green);
}
