* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; margin: 0; background: #f0f2f5; color: #1a1a1a; }
.header { background: #1e3a5f; color: #fff; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.header h1 { margin: 0; font-size: 1.35rem; font-weight: 600; }
.nav { display: flex; gap: 0.5rem; }
.nav a { color: rgba(255,255,255,0.9); text-decoration: none; padding: 0.5rem 1rem; border-radius: 6px; }
.nav a:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav a.active { background: rgba(255,255,255,0.25); color: #fff; }
.main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-success { background: #c6f6d5; color: #22543d; }
.flash-error { background: #fed7d7; color: #742a2a; }

.table-view .toolbar { margin-bottom: 1rem; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.data-table th, .data-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid #e8eaed; }
.data-table th { background: #2c5282; color: #fff; font-weight: 600; }
.data-table tbody tr:hover { background: #f7fafc; }
.data-table .loading { color: #718096; text-align: center; }
.data-table .plates-cell { font-size: 0.9rem; max-width: 180px; }
.data-table .actions { white-space: nowrap; }
.data-table .btn-link, .data-table a.btn-link { background: none; border: none; color: #2b6cb0; cursor: pointer; padding: 0.25rem 0.5rem; font-size: 0.9rem; text-decoration: none; }
.data-table .btn-link:hover, .data-table a.btn-link:hover { text-decoration: underline; }
.data-table .btn-link.danger, .data-table a.btn-link.danger { color: #c53030; }

.btn { display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; border: none; cursor: pointer; font-size: 0.95rem; }
.btn-primary { background: #2b6cb0; color: #fff; }
.btn-primary:hover { background: #2c5282; }
.btn-secondary { background: #e2e8f0; color: #2d3748; }
.btn-secondary:hover { background: #cbd5e0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-content { background: #fff; border-radius: 10px; padding: 1.5rem; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #718096; line-height: 1; }
.modal-close:hover { color: #2d3748; }
.modal h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.modal label { display: block; margin-bottom: 0.75rem; }
.modal label input, .modal label select { display: block; width: 100%; padding: 0.5rem; margin-top: 0.25rem; border: 1px solid #cbd5e0; border-radius: 6px; }
.modal .plates legend { margin-bottom: 0.5rem; }
.modal .plates .plate-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.modal .plates .plate-row input { flex: 1; }
.modal .form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.map-view { padding: 0; max-width: 85%; margin-left: auto; margin-right: auto; }
.map-hint { color: #4a5568; font-size: 0.9rem; margin-bottom: 0.5rem; }
.map-toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.map-toolbar .editor-toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.map-toolbar .editor-toggle input { margin: 0; }
.map-editor-mode .spot-marker { cursor: move; }
.map-editor-mode .spot-marker:active { cursor: grabbing; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.map-container { position: relative; max-width: 100%; background: #e2e8f0; border-radius: 8px; overflow: hidden; min-height: 300px; touch-action: none; }
.map-zoom-wrapper { position: absolute; inset: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
.map-zoom-wrapper .map-image { display: block; width: 100%; height: 100%; object-fit: contain; vertical-align: top; }
.map-zoom-wrapper .map-placeholder { padding: 3rem; text-align: center; color: #718096; min-height: 400px; display: flex; align-items: center; justify-content: center; }
.map-placeholder code { background: #edf2f7; padding: 0.2rem 0.5rem; border-radius: 4px; }
.map-overlay { position: absolute; inset: 0; pointer-events: none; }
.map-editor-mode .map-overlay { pointer-events: auto; }
/* Метки в масштабе карты: размер в % от карты, при приближении (zoom) увеличиваются вместе с overlay */
.map-overlay .spot-marker { position: absolute; pointer-events: auto; transform-origin: center center; transform: translate(-50%, -50%); width: 5%; height: 1.8%; min-width: 56px; min-height: 20px; max-width: 76px; max-height: 30px; padding: 2px 6px; border-radius: 3px; font-size: clamp(7px, 1vw, 10px); font-weight: 600; text-align: center; cursor: pointer; transition: box-shadow 0.15s; display: flex; flex-direction: column; align-items: center; justify-content: center; box-sizing: border-box; }
.map-overlay .spot-marker:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.3); z-index: 5; }
.map-overlay .spot-marker .spot-num { display: block; line-height: 1.1; }
.map-overlay .spot-marker .spot-label { display: block; font-size: 0.7em; font-weight: normal; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.map-overlay .spot-marker .spot-rotate-handle { display: none; position: absolute; right: -8px; top: 50%; margin-top: -6px; width: 12px; height: 12px; border-radius: 50%; background: #2d3748; color: #fff; font-size: 10px; line-height: 12px; text-align: center; cursor: grab; pointer-events: auto; }
.map-editor-mode .spot-marker .spot-rotate-handle { display: block; }
.map-editor-mode .spot-marker .spot-rotate-handle:active { cursor: grabbing; }
.map-overlay .spot-marker .spot-delete-handle { display: none; position: absolute; left: -6px; top: -6px; width: 14px; height: 14px; border-radius: 50%; background: #c53030; color: #fff; font-size: 10px; line-height: 14px; text-align: center; cursor: pointer; pointer-events: auto; z-index: 6; }
.map-editor-mode .spot-marker .spot-delete-handle { display: block; }
.map-editor-mode .spot-marker .spot-delete-handle:hover { background: #9b2c2c; }
.spot-marker.assigned { background: #c53030; color: #fff; border: 1px solid #9b2c2c; }
.spot-marker.guest { background: #805ad5; color: #fff; border: 1px solid #6b46c1; }
.spot-marker.free { background: #276749; color: #fff; border: 1px solid #22543d; }
.spot-tooltip { position: fixed; background: #2d3748; color: #fff; padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.85rem; max-width: 220px; z-index: 100; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.spot-tooltip[hidden] { display: none !important; }

@media (min-width: 769px) {
    .map-overlay .spot-marker { min-width: 58px; min-height: 22px; font-size: 10px; padding: 2px 6px; }
    .map-overlay .spot-marker .spot-num { display: block; }
    .map-overlay .spot-marker .spot-label { display: block; font-size: 9px; visibility: visible; }
}

@media (max-width: 768px) {
    .header { flex-direction: column; align-items: flex-start; }
    .data-table { font-size: 0.85rem; }
    .data-table th, .data-table td { padding: 0.5rem; }
    .map-overlay .spot-marker { width: 2.2%; height: 1%; min-width: 20px; min-height: 14px; max-width: 32px; max-height: 22px; padding: 1px 3px; font-size: 8px; }
    .map-overlay .spot-marker .spot-label { display: none; }
}
