:root {
    --bg: #0f172a;
    --bg-elevated: #111827;
    --bg-panel: #020617;
    --border: #1f2937;
    --accent: #3b82f6;
    --accent-soft: rgba(59,130,246,0.12);
    --accent-strong: #2563eb;
    --danger: #ef4444;
    --danger-soft: rgba(239,68,68,0.12);
    --text: #e5e7eb;
    --text-soft: #9ca3af;
    --radius: 8px;
    --shadow-soft: 0 20px 40px rgba(0,0,0,0.45);
    --shadow-small: 0 8px 18px rgba(0,0,0,0.4);
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1f2937 0, #020617 45%, #000 100%);
    color: var(--text);
}

/* Header */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(to right, rgba(15,23,42,0.9), rgba(15,23,42,0.6));
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-left {
    display: flex;
    align-items: center;   /* vertikal mittig */
    gap: 8px;              /* Abstand zwischen Logo und Text */
}

.header-left img {
    height: 40px;
    display: block;
}

.header-left h1 {
    margin: 0;
    font-size: 1.1rem;
    letter-spacing: .08em;
    /*text-transform: uppercase;*/
    color: #f9fafb;
}

.header-sub {
    font-size: .78rem;
    color: var(--text-soft);
    margin-top: 2px;
}

.header-right .btn {
    margin-left: 6px;
}

/* Layout
   Links: Liste + Karte untereinander
   Rechts: Details
*/


.main-layout {
    display: grid;
    /* Erste Spalte ~45%, zweite ~55% */
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-areas:
        "list details"
        "map  details";
    gap: 10px;
    padding: 10px 14px;
    height: calc(100vh - 60px);
}

.panel {
    background: radial-gradient(circle at top left, #1e293b 0, #020617 55%);
    border-radius: var(--radius);
    border: 1px solid rgba(15,23,42,0.9);
    box-shadow: var(--shadow-soft);
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel h2 {
    margin: 0 0 6px;
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #9ca3af;
}

/* Panels im Grid platzieren */

.panel-left {
    grid-area: list;
    min-height: 0;
}

.panel-middle {
    grid-area: map;
    min-height: 0;
    position: relative;
}

.panel-right {
    grid-area: details;
    min-height: 0;
}


.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 6px;
}

.panel-header h2 {
    margin: 0;
}

.panel-header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.route-anim-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #9ca3af;
}

/* einfacher Switch */

.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #374151;
    border-radius: 999px;
    transition: .2s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    top: 2px;
    background-color: #e5e7eb;
    border-radius: 50%;
    transition: .2s;
}

.switch input:checked + .slider {
    background-color: #22c55e;
}

.switch input:checked + .slider:before {
    transform: translateX(16px);
}

/* PIN */


.pin-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.pin-filter label {
    color: #9ca3af;
}

.pin-filter input {
    width: 155px;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid #4b5563;
    background-color: #111827;
    color: #e5e7eb;
    text-align: center;
    letter-spacing: 0.08em;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
}

.pin-filter input:focus {
    outline: none;
    border-color: #60a5fa;
}


/* Liste */

#sos-list-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    margin-top: 4px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.table thead {
    background: rgba(15,23,42,0.9);
    position: sticky;
    top: 0;
    z-index: 1;
}

.table th,
.table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(31,41,55,0.9);
    text-align: left;
    white-space: nowrap;
}

.table tbody tr {
    cursor: pointer;
}

.table tbody tr:hover {
    background: rgba(15,23,42,0.85);
}

#sos-table {
    table-layout: fixed;
    width: 100%;
}

#sos-table th,
#sos-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spaltenbreiten für:
   1 = ID
   2 = Start
   3 = Akku
   4 = GSM
   5 = Name
   6 = Rufnummer
*/

#sos-table th:nth-child(1),
#sos-table td:nth-child(1) {
    width: 8%;   /* ID */
}

#sos-table th:nth-child(2),
#sos-table td:nth-child(2) {
    width: 22%;  /* Start */
}

#sos-table th:nth-child(3),
#sos-table td:nth-child(3),
#sos-table th:nth-child(4),
#sos-table td:nth-child(4) {
    width: 10%;  /* Akku / GSM */
}

#sos-table th:nth-child(5),
#sos-table td:nth-child(5) {
    width: 25%;  /* Name */
}

#sos-table th:nth-child(6),
#sos-table td:nth-child(6) {
    width: 25%;  /* Rufnummer */
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #f9fafb;
    font-size: .8rem;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .13s ease, transform .05s ease, box-shadow .13s ease, border-color .13s ease;
    box-shadow: var(--shadow-small);
}

.btn:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border-color: rgba(148,163,184,0.5);
    color: var(--text-soft);
}

.btn-secondary:hover {
    border-color: rgba(148,163,184,0.9);
    background: rgba(15,23,42,0.9);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-small {
    padding: 3px 8px;
    font-size: .75rem;
}

/* Alerts */

.alert {
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 10px;
    font-size: .8rem;
}

.alert-error {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
}

.alert-info {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
}

/* Form */

.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    font-size: .8rem;
    color: var(--text-soft);
    margin-bottom: 3px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #d1d5db; /* helleres Grau */
    background: #52525d;
    color: #f9fafb;
    font-size: .85rem;
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}

/* Fokus-Zustand klar sichtbar */
.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(59,130,246,0.6);
    background: #020617;
}

/* Platzhalter heller machen */
.form-group input::placeholder {
    color: rgba(209,213,219,0.7);
}

/* Detail */

#detail-container {
    flex: 1;
    overflow: auto;
    padding-right: 2px;
    min-height: 0;
}

.detail-block {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(55,65,81,0.9);
    font-size: .85rem;
}

.detail-block h3 {
    margin: 0 0 4px;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-soft);
}

/* Klickbare Werte im Detailbereich (Copy-to-Clipboard) */
.copyable {
    cursor: pointer;
    border-bottom: 1px dotted #4b5563;
}

.copyable:hover {
    color: #bfdbfe;
    border-bottom-color: #60a5fa;
}

.copyable.copied {
    border-bottom-color: #22c55e;
    color: #bbf7d0;
}


/* Accordion im Detailbereich */

.accordion-block {
    border-top: 1px solid #1f2937;
    margin-top: 6px;
    padding-top: 0;
}

/* Titelzeile klickbar hervorheben */
.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    cursor: pointer;
    user-select: none;
    padding: 6px 8px;
    margin: 0 -6px; /* leicht über den Block ziehen */
    border-radius: 6px;
    background: rgba(31,41,55,0.9); /* etwas heller/differenter als der Panel-Hintergrund */
    transition: background-color 0.15s ease, color 0.15s ease;
}

.accordion-header:hover {
    background: rgba(55,65,81,0.95);
}

.accordion-header h3 {
    margin: 0;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.accordion-toggle-indicator {
    font-size: .9rem;
    color: #9ca3af;
}

/* Inhalt darunter, standardmäßig versteckt */
.accordion-body {
    margin-top: 6px;
    display: none;
    padding: 0 2px 2px;
}

.accordion-block.open .accordion-body {
    display: block;
}


/* Dokumentenliste im Detailbereich */
.doc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.doc-list li {
    margin-bottom: 4px;
}

/* Link-Chip für Dokumente */
.doc-list a {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;              /* Pill-Optik */
    font-size: 0.85rem;
    text-decoration: none;
    color: #e5e7eb;                     /* helles Grau */
    background-color: #27272f;          /* dunkler Hintergrund */
    border: 1px solid #3f3f46;
    transition:
            background-color 0.15s ease,
            border-color 0.15s ease,
            color 0.15s ease,
            transform 0.1s ease;
}

.doc-list a::before {
    content: "📎";
    margin-right: 6px;
    font-size: 0.9em;
}

/* Hover-Effekt */
.doc-list a:hover {
    background-color: #4b5563;          /* etwas heller */
    border-color: #60a5fa;              /* bläuliche Akzentfarbe */
    color: #f9fafb;
    transform: translateY(-1px);
}

/* Notizen */

.notes-textarea {
    width: 100%;
    min-height: 90px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #4b5563;
    background-color: #1f2933;
    color: #e5e7eb;
    resize: vertical;
    font-size: 0.9rem;
}

.notes-textarea:focus {
    outline: none;
    border-color: #60a5fa;
}

.notes-status {
    margin-top: 4px;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Map */

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

#map-container {
    flex: 1;
    margin-top: 5px;
    min-height: 0;
}

#map,
#map-full {
    width: 100%;
    height: 100%;
    min-height: 200px;
    border-radius: 6px;
    overflow: hidden;
}

/* Vollbild-Karte */

.map-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.map-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.map-overlay .map-overlay-inner {
    transform: scale(1);
    transition: transform 0.25s ease;
}

.map-overlay.hidden .map-overlay-inner {
    transform: scale(0.96);
}

.map-overlay-inner {
    width: 94%;
    height: 92%;
    background: #020617;
    border-radius: var(--radius);
    border: 1px solid rgba(31,41,55,0.9);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


.map-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #111827;
    background: radial-gradient(circle at top left, #1e293b 0, #020617 55%);
}

.map-overlay-header h2 {
    margin: 0;
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #9ca3af;
}

.map-overlay-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Login */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #1f2937 0, #020617 45%, #000 100%);
}

.login-container {
    width: 400px;
    background: rgba(15,23,42,0.96);
    border-radius: 10px;
    border: 1px solid rgba(31,41,55,0.9);
    box-shadow: var(--shadow-soft);
    padding: 18px 18px 16px;
}

.login-container h1 {
    margin: 0 0 4px;
    font-size: 1rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #e5e7eb;
}

.login-sub {
    font-size: .75rem;
    color: var(--text-soft);
    margin-bottom: 10px;
}

/* Single-page Layout (Admin) */

.main-single {
    padding: 14px 18px;
}

.main-single h1 {
    margin-top: 0;
    font-size: 1rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #e5e7eb;
}

/* Small utilities */

.hint {
    font-size: .8rem;
    color: var(--text-soft);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: .7rem;
    border: 1px solid rgba(148,163,184,0.6);
    color: #e5e7eb;
}