:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-border: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #2563eb;
    --ok: #22c55e;
    --alert: #ef4444;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

.page-dashboard {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.panel {
    width: 360px;
    min-width: 320px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(2, 6, 23, 0.98));
    border-right: 1px solid var(--panel-border);
    padding: 24px 20px;
    z-index: 1000;
}

.brand h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.3px;
}

.brand p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
}

.card {
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.65);
}

.card span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.card strong {
    font-size: 18px;
    font-weight: 700;
}

.legend {
    margin-top: 24px;
    border-top: 1px solid var(--panel-border);
    padding-top: 18px;
    color: var(--muted);
    font-size: 14px;
}

.legend h2 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 15px;
}

.legend .dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.dot.green {
    background: var(--ok);
}

.dot.red {
    background: var(--alert);
}

#map {
    flex: 1;
    height: 100%;
}

.vehicle-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.vehicle-marker.closed {
    background: var(--ok);
}

.vehicle-marker.open {
    background: var(--alert);
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .panel {
        width: 100%;
        min-width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--panel-border);
    }

    #map {
        height: calc(100% - 340px);
    }
}

/* —— Giriş —— */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: rgba(17, 24, 39, 0.95);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
    margin: 0;
    font-size: 22px;
}

.login-sub {
    margin: 8px 0 20px;
    color: var(--muted);
    font-size: 14px;
}

.login-form label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
}

.login-form input {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: #0b1220;
    color: var(--text);
}

.btn-primary {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.alert-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
    font-size: 14px;
    margin-bottom: 16px;
}

/* —— Dashboard (responsive) —— */
.layout-dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-height: 100dvh;
}

.dash-core {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: row;
    align-items: stretch;
}

.layout-dashboard .panel-wide {
    width: min(560px, 44vw);
    min-width: min(100%, 320px);
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 18px 24px;
    box-sizing: border-box;
}

.map-wrap {
    flex: 1;
    min-width: 0;
    min-height: 320px;
    position: relative;
}

.layout-dashboard #map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.brand-meta {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
}

.admin-card {
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.5);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.form-grid-tight {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.table-wrap-sm {
    max-height: 220px;
}

.links-cell {
    font-size: 11px;
    max-width: 220px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    margin: 2px 4px 2px 0;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.2);
    border: 1px solid rgba(37, 99, 235, 0.35);
    white-space: nowrap;
    max-width: 100%;
}

.pill-remove {
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    min-width: 28px;
    min-height: 28px;
}

.alarm-item-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.topbar-actions .btn-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}

.stat-grid-4 {
    grid-template-columns: 1fr 1fr;
}

.panel-section {
    margin-top: 20px;
}

.panel-section h2 {
    margin: 0 0 10px;
    font-size: 15px;
}

.table-wrap {
    overflow: auto;
    max-height: 42vh;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th,
.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--panel-border);
    vertical-align: top;
}

.data-table th {
    text-align: left;
    color: var(--muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.98);
    z-index: 1;
}

.data-table code {
    font-size: 11px;
}

.muted {
    color: var(--muted);
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.tag-ok {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.tag-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

.actions {
    white-space: normal;
}

.btn-xs {
    margin: 2px 2px 0 0;
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: #0b1220;
    color: var(--text);
    cursor: pointer;
    min-height: 36px;
}

.btn-secondary {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: #0b1220;
    color: var(--text);
    cursor: pointer;
}

.tm-target-select {
    display: block;
    width: 100%;
    max-width: 160px;
    margin-bottom: 6px;
    padding: 4px;
    font-size: 11px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: #0b1220;
    color: var(--text);
}

.alarm-strip {
    margin: 14px 0;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.25);
}

.alarm-strip.hidden {
    display: none;
}

.alarm-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.alarm-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alarm-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    font-size: 12px;
    flex-wrap: wrap;
}

.admin-assign .assign-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.admin-assign input,
.admin-assign select {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: #0b1220;
    color: var(--text);
}

.hint {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 10px;
}

@media (max-width: 1023px) {
    .dash-core {
        flex-direction: column;
    }

    .map-wrap {
        flex: 0 0 auto;
        height: min(42dvh, 380px);
        min-height: 260px;
        order: 0;
        border-bottom: 1px solid var(--panel-border);
    }

    .layout-dashboard .panel-wide {
        width: 100%;
        order: 1;
        flex: 1 1 auto;
        max-height: none;
    }

    .stat-grid-4 {
        grid-template-columns: 1fr 1fr;
    }

    .table-wrap {
        max-height: none;
    }
}

@media (max-width: 520px) {
    .stat-grid-4 {
        grid-template-columns: 1fr;
    }

    .links-cell {
        max-width: none;
    }

    .pill {
        white-space: normal;
    }
}
