.login-logo { max-width: 220px; max-height: 60px; margin-bottom: 20px; }
.admin-logo { max-width: 200px; max-height: 50px; display: block; margin-bottom: 16px; }
.topbar-logo { height: 24px; margin-right: 12px; filter: brightness(0) invert(1); }

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1f2430;
}

/* ---- Logowanie ---- */
.login-body {
    background: #0f1b2d;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 340px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.login-box h1 { font-size: 20px; margin-bottom: 6px; color: #28272A; }
.subtitle { color: #6b7280; font-size: 13px; margin-bottom: 20px; }
.login-box input[type="text"] {
    width: 100%; padding: 12px; font-size: 16px; text-align: center;
    border: 1px solid #c9ccd1; border-radius: 8px; margin-bottom: 14px;
    letter-spacing: 1px;
}
.login-box button, .admin-body button {
    width: 100%; padding: 12px; font-size: 15px; font-weight: 600;
    background: #F05626; color: white; border: none; border-radius: 8px;
    cursor: pointer;
}
.login-box button:hover { background: #d1451a; }
.error { color: #c0392b; font-size: 13px; margin-bottom: 10px; }

/* ---- Admin ---- */
.admin-wrap { max-width: 900px; margin: 30px auto; padding: 0 20px; }
.card {
    background: #f8f9fa; border: 1px solid #e2e4e8; border-radius: 10px;
    padding: 20px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin-top: 0; color: #28272A; }
.card form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card input[type="text"], .card select {
    padding: 8px; border: 1px solid #c9ccd1; border-radius: 6px; font-size: 14px;
}
.card button {
    padding: 8px 16px; background: #28272A; color: white; border: none;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.card button:disabled { opacity: 0.4; cursor: not-allowed; }
.card textarea {
    padding: 8px; border: 1px solid #c9ccd1; border-radius: 6px; font-size: 14px;
    font-family: inherit; resize: vertical; width: 100%;
}
.ai-analysis-form { flex-direction: column; align-items: stretch; }
.ai-analysis-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #495057; }

/* ---- Nawigacja panelu admina ---- */
.admin-nav { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid #e2e4e8; }
.admin-nav a {
    padding: 10px 16px; text-decoration: none; color: #6b7280; font-size: 14px;
    font-weight: 600; border-bottom: 2px solid transparent;
}
.admin-nav a.active { color: #F05626; border-bottom-color: #F05626; }
.admin-nav a:hover { color: #28272A; }

/* ---- Podmenu (np. instrukcja: Mozaika / QGIS) ---- */
.sub-nav { display: flex; gap: 8px; margin-bottom: 20px; }
.sub-nav a {
    padding: 6px 14px; text-decoration: none; color: #495057; font-size: 13px;
    font-weight: 600; background: #eef0f3; border-radius: 20px;
}
.sub-nav a.active { background: #28272A; color: white; }
.sub-nav a:hover:not(.active) { background: #e2e4e8; }

/* ---- Formularz dodawania/edycji pojedynczej anomalii ---- */
.anomaly-form-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.anomaly-form-grid label {
    display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #495057;
}
.anomaly-form-grid input {
    padding: 8px; border: 1px solid #c9ccd1; border-radius: 6px; font-size: 14px;
}
.anomaly-form-wide { grid-column: 1 / -1; }

/* ---- Mapka w formularzu dodawania/edycji anomalii ---- */
.anomaly-map-wrap { position: relative; height: 420px; border-radius: 8px; overflow: hidden; }
.anomaly-map-wrap #anomaly-map { height: 100%; }
.anomaly-map-wrap .anomaly-map-controls {
    position: absolute; bottom: 10px; left: 10px; z-index: 1000;
    background: white; padding: 8px 10px; border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2); font-size: 12px; display: flex; gap: 10px; align-items: center;
}
.anomaly-map-wrap .anomaly-map-controls .control-row { margin-bottom: 0; }
.anomaly-map-wrap .anomaly-map-controls input[type="range"] { width: 90px; }
.anomaly-map-wrap .temp-toolbar { top: 10px; left: 10px; width: 116px; }
.ai-describe-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.ai-describe-row input[type="text"] {
    flex: 1; min-width: 260px; padding: 8px; border: 1px solid #c9ccd1; border-radius: 6px; font-size: 13px;
}
.anomaly-form-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-secondary {
    background: white; color: #28272A; border: 1px solid #c9ccd1 !important;
}
.btn-secondary:hover { background: #f8f9fa; }
.success-banner {
    background: #d4edda; color: #155724; padding: 10px 14px; border-radius: 6px;
    font-size: 14px; margin-bottom: 16px;
}
.admin-comment { padding: 10px 0; border-bottom: 1px solid #f1f2f4; }
.admin-comment-meta { font-size: 13px; margin-bottom: 4px; }
.admin-comment-text { font-size: 13px; color: #374151; white-space: pre-wrap; margin: 0 0 6px; }
.ai-suggestion-thumb { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; display: block; }

/* ---- Ramka z instrukcja (konwerter termiczny) ---- */
.callout {
    background: #fff8f0; border: 1px solid #ffddb8; border-radius: 8px;
    padding: 14px 16px; margin: 14px 0; font-size: 13px; color: #4a3c2a;
}
.callout strong { display: block; margin-bottom: 6px; color: #28272A; }
.callout ol { margin: 8px 0; padding-left: 20px; }
.callout li { margin-bottom: 4px; }
.projects-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.projects-table th, .projects-table td {
    text-align: left; padding: 8px; border-bottom: 1px solid #e2e4e8; vertical-align: top;
}
.status { padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.status-ready { background: #d4edda; color: #155724; }
.status-processing { background: #fff3cd; color: #856404; }
.status-error { background: #f8d7da; color: #721c24; }
.status-empty { background: #e2e4e8; color: #555; }
.error-detail { color: #c0392b; font-size: 11px; margin-top: 4px; max-width: 300px; }
.layer-flags { font-size: 11px; color: #6b7280; margin-top: 4px; }
.upload-form { flex-direction: column; align-items: flex-start; gap: 6px; }
.upload-form label { font-size: 12px; }
.hint { font-size: 12px; color: #6b7280; }

/* ---- Viewer ---- */
.viewer-body { margin: 0; height: 100vh; overflow: hidden; }
#topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
    background: #28272A; color: white; padding: 10px 16px;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px;
}
.logout-link { color: #ffd7c2; text-decoration: none; font-size: 13px; }
#map { position: absolute; top: 42px; bottom: 0; left: 0; right: 0; }
.topbar-left { display: flex; align-items: center; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.project-date { font-weight: 400; color: #ffd7c2; font-size: 12px; margin-left: 4px; }
.project-switcher {
    padding: 5px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.35);
    background: #28272A; color: white; font-size: 13px; margin-right: 10px; max-width: 220px;
}
#controls {
    position: absolute; bottom: 20px; left: 20px; z-index: 1000;
    background: white; padding: 12px 16px; border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2); font-size: 13px;
}
.control-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.control-row input[type="range"] { width: 140px; }

/* ---- Panel boczny z lista anomalii ---- */
.anomaly-toggle-btn {
    position: absolute; top: 56px; right: 16px; z-index: 1000;
    background: #28272A; color: white; border: none; padding: 8px 14px;
    border-radius: 6px; font-size: 13px; cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.anomaly-toggle-btn:hover { background: #3a393d; }

.area-toggle-btn {
    position: absolute; top: 100px; right: 16px; z-index: 1000;
    background: #28272A; color: white; border: none; padding: 8px 14px;
    border-radius: 6px; font-size: 13px; cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2); max-width: 220px;
}
.area-toggle-btn:hover { background: #3a393d; }
.area-toggle-btn.active { background: #F05626; }

.temp-toolbar {
    position: absolute; top: 130px; left: 16px; z-index: 1000;
    background: white; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    padding: 8px; display: flex; flex-direction: column; gap: 6px; width: 132px;
}
.temp-toolbar-title {
    font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase;
    letter-spacing: 0.03em; padding: 2px 4px 4px;
}
.temp-tool-btn {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: none;
    border-radius: 6px; background: #f8f9fa; cursor: pointer; font-size: 13px;
    color: #28272A; text-align: left; width: 100%;
}
.temp-tool-btn:hover { background: #eef0f3; }
.temp-tool-btn.active { background: #F05626; color: white; }
.temp-tool-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }
.temp-tool-clear { color: #c0392b; }
.temp-tool-clear:hover { background: #fdecea; }

.anomaly-panel {
    position: absolute; top: 42px; bottom: 0; right: 0; width: 320px;
    max-width: 90vw; background: white; z-index: 1001;
    box-shadow: -2px 0 10px rgba(0,0,0,0.15);
    transform: translateX(100%); transition: transform 0.2s ease;
    display: flex; flex-direction: column;
}
.anomaly-panel.open { transform: translateX(0); }
.anomaly-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid #e2e4e8; font-weight: 600;
    color: #28272A; flex-shrink: 0;
}
.anomaly-panel-close-btn {
    background: none; border: none; font-size: 22px; line-height: 1;
    cursor: pointer; color: #6b7280;
}
.anomaly-panel-body { overflow-y: auto; flex: 1; padding: 8px 0; }
.anomaly-group-header {
    padding: 8px 16px; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em; color: #495057; border-left: 4px solid; margin-top: 6px;
    background: #f8f9fa;
}
.anomaly-item {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px;
    cursor: pointer; border-bottom: 1px solid #f1f2f4; font-size: 13px;
}
.anomaly-item:hover { background: #f8f9fa; }
.anomaly-item.active { background: #fff1ea; }
.anomaly-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }

.highlight-marker-pulse {
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(240, 86, 38, 0.5); border: 3px solid #F05626;
    animation: highlight-pulse 1.6s ease-out infinite;
}
@keyframes highlight-pulse {
    0% { transform: scale(0.6); box-shadow: 0 0 0 0 rgba(240, 86, 38, 0.5); }
    70% { transform: scale(1); box-shadow: 0 0 0 14px rgba(240, 86, 38, 0); }
    100% { transform: scale(0.6); box-shadow: 0 0 0 0 rgba(240, 86, 38, 0); }
}
.anomaly-item-text strong { display: block; color: #1f2430; }
.anomaly-item-sub { color: #6b7280; font-size: 12px; margin-top: 2px; }

.anomaly-comments { margin-top: 8px; border-top: 1px solid #f1f2f4; padding-top: 8px; }
.anomaly-comment { margin-bottom: 8px; font-size: 12px; }
.anomaly-comment strong { color: #1f2430; }
.anomaly-comment-date { color: #9ca3af; font-size: 11px; margin-left: 6px; }
.anomaly-comment p { margin: 3px 0 0; color: #374151; white-space: pre-wrap; }
.anomaly-comment-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.anomaly-comment-form input, .anomaly-comment-form textarea {
    padding: 6px 8px; border: 1px solid #d7dae0; border-radius: 6px; font-size: 12px; font-family: inherit;
}
.anomaly-comment-form textarea { resize: vertical; min-height: 50px; }
.anomaly-comment-form button {
    align-self: flex-start; padding: 6px 12px; background: #28272A; color: white;
    border: none; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.anomaly-comment-form button:hover { background: #F05626; }
.anomaly-comment-form button:disabled { opacity: 0.5; cursor: not-allowed; }
.comment-status { display: block; margin-top: 2px; }

/* ---- Formularz danych inspekcji ---- */
.meta-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; align-items: end; }
.meta-form label {
    display: flex; flex-direction: column; gap: 4px; font-size: 12px;
    color: #495057; font-weight: 600;
}
.meta-form input[type="text"], .meta-form input[type="date"] {
    padding: 8px; border: 1px solid #c9ccd1; border-radius: 6px;
    font-size: 14px; font-weight: normal; color: #1f2430;
}
.meta-submit { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 720px) { .meta-form { grid-template-columns: 1fr; } }

/* ---- Przycisk raportu w widoku klienta ---- */
.report-link {
    color: white; text-decoration: none; font-size: 13px;
    background: #F05626; padding: 6px 12px; border-radius: 6px; margin-right: 14px;
}
.report-link:hover { background: #d1451a; }

.projects-link {
    color: white; text-decoration: none; font-size: 13px;
    background: transparent; padding: 6px 12px; border-radius: 6px; margin-right: 10px;
    border: 1px solid rgba(255,255,255,0.35);
}
.projects-link:hover { background: rgba(255,255,255,0.12); }

/* ---- Wyszukiwanie i sortowanie tabeli projektow ---- */
.table-toolbar { margin-bottom: 12px; }
.table-toolbar input[type="text"] {
    width: 100%; max-width: 420px; padding: 8px; border: 1px solid #c9ccd1;
    border-radius: 6px; font-size: 14px;
}
.projects-table th.sortable {
    cursor: pointer; user-select: none; white-space: nowrap;
}
.projects-table th.sortable:hover { color: #F05626; }
.projects-table th.sortable[data-sort-active="asc"]::after { content: " \25B2"; font-size: 10px; }
.projects-table th.sortable[data-sort-active="desc"]::after { content: " \25BC"; font-size: 10px; }
.delete-btn {
    background: #c0392b; padding: 6px 12px; font-size: 13px; white-space: nowrap;
}
.delete-btn:hover { background: #96281b; }

/* ---- Strona instrukcji ---- */
.steps-list { padding-left: 22px; line-height: 1.6; }
.steps-list li { margin-bottom: 10px; }
.steps-list pre {
    background: #1f2430; color: #e2e4e8; padding: 12px 14px; border-radius: 6px;
    overflow-x: auto; margin: 8px 0; font-size: 12px; line-height: 1.5;
}
.steps-list code, .card p code, .card h2 code {
    background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 0.92em;
}
.steps-list pre code { background: none; padding: 0; }

/* ---- Galeria zdjec termowizyjnych falownikow ---- */
.photo-gallery {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px; margin-top: 14px;
}
.photo-gallery-item {
    border: 1px solid #e2e4e8; border-radius: 8px; overflow: hidden;
    background: #fff; display: flex; flex-direction: column;
}
.photo-gallery-item img {
    width: 100%; height: 100px; object-fit: cover; display: block; background: #eef0f3;
}
.photo-gallery-name {
    font-size: 11px; padding: 6px 8px; color: #495057; word-break: break-all; flex: 1;
}
.photo-gallery-item form { padding: 0 8px 8px; }
.photo-gallery-item .delete-btn { width: 100%; padding: 4px; font-size: 11px; }
.photo-gallery-temp-form { display: flex; gap: 4px; }
.photo-gallery-temp-form input {
    width: 100%; padding: 4px 6px; font-size: 11px; border: 1px solid #c9ccd1;
    border-radius: 4px; min-width: 0;
}
.photo-gallery-temp-form button {
    padding: 4px 8px; font-size: 11px; flex-shrink: 0;
}

.actions-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.action-link {
    display: inline-block; padding: 6px 12px; background: #28272A; color: white;
    text-decoration: none; border-radius: 6px; font-size: 13px; white-space: nowrap;
}
.action-link:hover { background: #3a393d; }
