:root {
    --background: #080c12;
    --surface: #101720;
    --surface-light: #151e29;
    --border: #26313e;
    --text: #f5f7fa;
    --muted: #8c99a8;
    --primary: #4f8cff;
    --primary-hover: #6a9cff;
    --green: #2ecc71;
    --red: #ff5c6c;
    --yellow: #f1c40f;
    --sidebar-width: 248px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(
            circle at top right,
            rgba(79, 140, 255, 0.08),
            transparent 35%
        ),
        var(--background);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button {
    font: inherit;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    padding: 24px 18px;
    background: rgba(13, 19, 27, 0.96);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 26px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f8cff, #735cff);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 21px;
    box-shadow: 0 10px 30px rgba(79, 140, 255, 0.25);
}

.brand-name {
    font-size: 18px;
    font-weight: 750;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.nav-item {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 12px 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-align: left;
    transition: 160ms ease;
}

.nav-item:hover {
    background: var(--surface-light);
    color: var(--text);
}

.nav-item.active {
    background: rgba(79, 140, 255, 0.14);
    color: #8bb2ff;
}

.nav-icon {
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-dot,
.pulse-dot,
.service-dot {
    flex: 0 0 auto;
    border-radius: 50%;
}

.connection-dot {
    width: 9px;
    height: 9px;
    background: var(--green);
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.7);
}

.connection-title {
    font-size: 13px;
    font-weight: 650;
}

.connection-subtitle {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.app-shell {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    min-height: 92px;
    padding: 19px 30px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 12, 18, 0.78);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    margin: 0;
    font-size: 23px;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 22px;
}

.system-online {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #b9f6cd;
    font-size: 13px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    box-shadow: 0 0 0 6px rgba(46, 204, 113, 0.1);
}

.clock {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.main-content {
    max-width: 1540px;
    margin: 0 auto;
    padding: 24px 30px 40px;
}

.service-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    overflow: hidden;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 20px;
}

.service-item {
    background: var(--surface);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 11px;
}

.service-dot {
    display: block;
    width: 9px;
    height: 9px;
    min-width: 9px;
    flex-shrink: 0;
    border-radius: 50%;
}

.service-dot.online {
    background: var(--green);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.55);
}

.service-dot.offline {
    background: var(--red);
}

.service-label {
    color: var(--muted);
    font-size: 11px;
}

.service-value {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 650;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.8fr);
    gap: 20px;
}

.panel,
.metric-card {
    background: linear-gradient(
        180deg,
        rgba(21, 30, 41, 0.96),
        rgba(14, 21, 30, 0.96)
    );
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.17);
}

.panel {
    padding: 18px;
}

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

.panel-header.compact {
    margin-bottom: 14px;
}

.panel-header h2 {
    margin: 0;
    font-size: 16px;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    flex: 0 0 auto;

    padding: 6px 12px;

    color: #ff9ba5;
    background: rgba(255, 92, 108, 0.1);
    border: 1px solid rgba(255, 92, 108, 0.25);

    border-radius: 999px;

    font-size: 11px;
    font-weight: 600;
    line-height: 1;

    text-transform: uppercase;
    letter-spacing: 0.08em;

    white-space: nowrap;
}

.live-badge-dot {
    width: 7px;
    height: 7px;

    flex: 0 0 7px;

    border-radius: 50%;
    background: var(--red);
}

.live-badge-text {
    display: inline-block;
    white-space: nowrap;
}

#camera-live-text {
    display: block;
    width: auto;
    min-width: 0;

    white-space: nowrap;
}

.camera-frame {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    min-height: 320px;
    background: #05070a;
}

.camera-frame img {
    width: 100%;
    height: 100%;
    max-height: 620px;
    object-fit: contain;
    display: block;
}

.camera-overlay {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    gap: 8px;
}

.camera-overlay span {
    padding: 6px 9px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(8px);
    font-size: 11px;
}

.camera-audio-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.camera-audio-controls .secondary-button {
    width: auto;
    min-width: 110px;
    flex: 0 0 auto;
}

.camera-audio-controls .muted {
    white-space: nowrap;
}

.status-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 13px;
}

.gate-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.large-value {
    font-size: 29px;
    font-weight: 750;
}

.muted,
.metric-note {
    color: var(--muted);
    font-size: 11px;
    margin-top: 5px;
}

.gate-icon {
    width: 58px;
    height: 58px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    font-size: 26px;
}

.gate-icon.closed {
    background: rgba(79, 140, 255, 0.13);
    color: #8bb2ff;
}

.button-row,
.test-buttons {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.secondary-button,
.primary-button,
.danger-button {
    border-radius: 9px;
    padding: 10px 13px;
    cursor: pointer;
    border: 1px solid transparent;
    font-weight: 650;
    font-size: 12px;
}

.secondary-button {
    flex: 1;
    background: var(--surface-light);
    border-color: var(--border);
    color: var(--muted);
}

.primary-button {
    flex: 1;
    background: var(--primary);
    color: white;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.danger-button {
    flex: 1;
    background: rgba(255, 92, 108, 0.12);
    border-color: rgba(255, 92, 108, 0.28);
    color: #ff9ba5;
}

.plate-display {
    border: 2px solid #d3d8df;
    background: #f4f6f8;
    color: #111820;
    border-radius: 8px;
    padding: 13px;
    text-align: center;
    font-size: 23px;
    font-weight: 850;
    letter-spacing: 0.12em;
    margin-bottom: 15px;
}

.detail-list {
    display: flex;
    flex-direction: column;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.detail-row span {
    color: var(--muted);
}

.status-authorized {
    color: var(--green);
}

.status-unauthorized {
    color: var(--red);
}

.status-neutral {
    color: var(--muted);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.metric-card {
    padding: 17px;
}

.metric-label {
    color: var(--muted);
    font-size: 12px;
}

.metric-value {
    font-size: 25px;
    font-weight: 750;
    margin: 8px 0 10px;
}

.progress-track {
    height: 6px;
    background: #0a0f15;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4f8cff, #7c6cff);
    border-radius: inherit;
    transition: width 300ms ease;
}

.activity-panel {
    margin-top: 20px;
}

.text-button {
    border: 0;
    background: transparent;
    color: #8bb2ff;
    cursor: pointer;
}

.empty-state {
    padding: 34px 20px 42px;
    text-align: center;
    color: var(--muted);
}

.empty-icon {
    width: 48px;
    height: 48px;
    margin: auto;
    border-radius: 14px;
    background: var(--surface-light);
    display: grid;
    place-items: center;
    font-size: 22px;
}

.empty-state h3 {
    color: var(--text);
    margin: 14px 0 5px;
    font-size: 15px;
}

.empty-state p {
    margin: 0;
    font-size: 12px;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(340px, calc(100vw - 48px));
    padding: 15px 17px;
    background: #17212d;
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
    transition: 200ms ease;
    z-index: 50;
}

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

.toast-title {
    font-weight: 750;
    font-size: 14px;
}

.toast-message {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .status-column {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 760px) {
    :root {
        --sidebar-width: 74px;
    }

    .sidebar {
        padding: 18px 10px;
    }

    .brand {
        padding: 0 6px 22px;
    }

    .sidebar .brand-name,
    .sidebar .brand-subtitle,
    .nav-item:not(.active) {
        font-size: 0;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .nav-item.active {
        font-size: 0;
    }

    .nav-icon {
        font-size: 18px;
    }

    .sidebar-footer {
        justify-content: center;
    }

    .sidebar-footer div:not(.connection-dot) {
        display: none;
    }

    .topbar,
    .main-content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .topbar p,
    .system-online {
        display: none;
    }

    .service-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .status-column,
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

.hidden {
    display: none !important;
}

.vehicle-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr auto;
    gap: 14px;
    align-items: end;
    padding: 18px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.vehicle-form label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
}

.vehicle-form input,
.unknown-simulator input {
    width: 100%;
    padding: 11px 12px;
    color: var(--text);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
}

.vehicle-form input:focus,
.unknown-simulator input:focus {
    border-color: var(--primary);
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    padding-bottom: 11px;
}

.checkbox-label input {
    width: auto;
}

.vehicle-form-actions {
    display: flex;
    gap: 8px;
}

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

.vehicle-card {
    padding: 17px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
}

.vehicle-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.vehicle-card h3 {
    margin: 0;
}

.vehicle-card p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.vehicle-badge {
    height: fit-content;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 10px;
}

.vehicle-badge.authorized {
    color: var(--green);
    background: rgba(46, 204, 113, 0.12);
}

.vehicle-badge.blocked {
    color: var(--red);
    background: rgba(255, 92, 108, 0.12);
}

.vehicle-plate {
    margin: 18px 0;
    padding: 11px;
    color: #111820;
    background: #f4f6f8;
    border: 2px solid #d3d8df;
    border-radius: 7px;
    text-align: center;
    font-size: 20px;
    font-weight: 850;
    letter-spacing: 0.12em;
}

.vehicle-actions {
    display: flex;
    gap: 9px;
}

.simulator-panel {
    margin-top: 20px;
}

.unknown-simulator {
    display: flex;
    gap: 10px;
}

.unknown-simulator input {
    flex: 1;
}

@media (max-width: 900px) {
    .vehicle-form {
        grid-template-columns: 1fr;
    }

    .unknown-simulator {
        flex-direction: column;
    }
}

.history-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.history-toolbar input,
.history-toolbar select {
    padding: 10px 12px;
    color: var(--text);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
}

.history-toolbar input {
    flex: 1;
}

.history-toolbar input:focus,
.history-toolbar select:focus {
    border-color: var(--primary);
}

.history-table-wrapper {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.history-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-table td {
    font-size: 13px;
}

@media (max-width: 760px) {
    .history-toolbar {
        flex-direction: column;
    }
}

/* =========================================================
   CAMERA PAGE
   ========================================================= */

.camera-info-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(190px, 1fr)
    );
    gap: 12px;
}

.camera-info-card {
    display: flex;
    flex-direction: column;
    gap: 7px;

    padding: 16px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.camera-info-card strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.camera-info-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;

    text-transform: uppercase;
    letter-spacing: 0.06em;
}


/* Offline camera display */

.camera-offline {
    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    background: var(--background);

    text-align: center;
}

.camera-offline h3 {
    margin: 0 0 6px;
    color: var(--text);
}

.camera-offline p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}


/* Make sure offline overlay positions correctly */

.camera-frame {
    position: relative;
}


/* =========================================================
   SETTINGS
   =========================================================*/

.setting-row input[type="number"] {
    width: 110px;
    padding: 8px 10px;

    color: var(--text);
    background: var(--background);

    border: 1px solid var(--border);
    border-radius: 8px;

    outline: none;
}

.setting-row input[type="number"]:focus {
    border-color: var(--primary);
}

.setting-row input[type="checkbox"] {
    width: 18px;
    height: 18px;

    cursor: pointer;
}

.settings-save-bar {
    position: sticky;
    bottom: 18px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-top: 20px;
    padding: 15px 18px;

    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 13px;

    box-shadow:
        0 8px 30px
        rgba(0, 0, 0, 0.18);
}

.settings-save-bar strong {
    font-size: 13px;
}

.settings-save-bar p {
    margin: 3px 0 0;

    color: var(--muted);
    font-size: 11px;
}

@media (max-width: 600px) {
    .settings-save-bar {
        align-items: stretch;
        flex-direction: column;
    }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 760px) {

    .camera-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .setting-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 9px;
    }
}


@media (max-width: 520px) {

    .camera-info-grid {
        grid-template-columns: 1fr;
    }
}

.recordings-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.recordings-panel .panel-header > div {
    min-width: 0;
}

#refresh-recordings {
    width: auto;
    min-width: 90px;
    flex: 0 0 auto;

    padding: 8px 14px;
}

.recordings-browser {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recording-folder {
    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface);
}

.recording-folder-header {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px 16px;

    color: var(--text);
    background: transparent;

    border: none;

    cursor: pointer;
}

.recording-folder-header span {
    color: var(--muted);
    font-size: 11px;
}

.recording-folder-content {
    border-top: 1px solid var(--border);
}

.recording-folder-content.hidden {
    display: none;
}

.recording-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 12px 16px;

    border-bottom: 1px solid var(--border);
}

.recording-file-row:last-child {
    border-bottom: none;
}

.recording-file-row a {
    color: var(--text);
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
}

.recording-file-row a:hover {
    color: var(--primary);
}

.recording-file-row span {
    color: var(--muted);
    font-size: 11px;
}

.recording-file-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.recording-file-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.recording-delete-button {
    padding: 8px 12px;

    color: var(--red);
    background: rgba(255, 92, 108, 0.08);

    border: 1px solid rgba(255, 92, 108, 0.3);
    border-radius: 8px;

    font-size: 11px;
    font-weight: 650;

    cursor: pointer;
}

.recording-delete-button:hover {
    background: rgba(255, 92, 108, 0.15);
}

@media (max-width: 700px) {
    .recording-file-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

.recording-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.recording-plate {
    color: var(--text);
    font-size: 14px;
    font-weight: 750;
    letter-spacing: 0.04em;
}

.recording-meta {
    color: var(--muted);
    font-size: 11px;
}

.recording-status-badge {
    display: inline-flex;
    align-items: center;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 9px;
    font-weight: 750;

    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.recording-status-badge.authorized {
    color: var(--green);
    background: rgba(
        46,
        204,
        113,
        0.12
    );

    border: 1px solid rgba(
        46,
        204,
        113,
        0.22
    );
}

.recording-status-badge.unauthorized {
    color: var(--red);
    background: rgba(
        255,
        92,
        108,
        0.12
    );

    border: 1px solid rgba(
        255,
        92,
        108,
        0.22
    );
}

.recording-status-badge.unknown {
    color: var(--muted);

    background: rgba(
        255,
        255,
        255,
        0.05
    );

    border: 1px solid var(--border);
}

.recording-player-row {
    padding: 16px;

    background: rgba(
        0,
        0,
        0,
        0.18
    );

    border-bottom:
        1px solid var(--border);
}

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

    gap: 16px;

    margin-bottom: 12px;
}

.recording-player-header strong {
    overflow: hidden;

    color: var(--text);

    font-size: 12px;
    font-weight: 650;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.recording-inline-video {
    display: block;

    width: 100%;
    max-height: 620px;

    background: #000;

    border-radius: 10px;

    object-fit: contain;
}

.recording-player-close {
    flex-shrink: 0;

    padding: 7px 11px;

    color: var(--muted);
    background: transparent;

    border: 1px solid var(--border);
    border-radius: 8px;

    font-size: 11px;

    cursor: pointer;
}

.recording-player-close:hover {
    color: var(--text);
    background: var(--surface);
}

.user-footer {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: rgba(255, 255, 255, 0.08);

    font-size: 14px;
    font-weight: 700;
}

.user-footer-info {
    flex: 1;
    min-width: 0;
}

.user-footer-info .connection-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-button {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 8px;

    color: inherit;
    text-decoration: none;

    opacity: 0.65;

    transition:
        background 0.2s ease,
        opacity 0.2s ease;
}

.logout-button:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
}

/* =========================
   GateAI Mobile Layout
   ========================= */

@media (max-width: 768px) {

    html,
    body {
        width: 100%;
        overflow-x: hidden;
    }

    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom:
            calc(
                74px
                + env(safe-area-inset-bottom)
            );
    }

    .sidebar {
        display: none;
    }

    .app-shell {
        margin-left: 0;
        width: 100%;
        min-width: 0;
    }

    .topbar {
        padding:
            18px
            18px
            14px;
    }

    .topbar h1 {
        font-size: 30px;
    }

    .topbar-right {
        gap: 10px;
    }

    .system-online {
        display: none;
    }

    .clock {
        font-size: 14px;
    }

    .main-content {
        padding: 12px;
    }

    .service-bar {
        display: grid;
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 8px;

        margin-bottom: 12px;
    }

    .service-item {
        min-width: 0;
        padding: 12px;
    }

    .dashboard-grid {
        display: block;
    }

    .status-column {
        display: grid;
        gap: 12px;
        margin-top: 12px;
    }

    .panel {
        border-radius: 18px;
    }

    .camera-panel {
        width: 100%;
    }

    .camera-frame {
        width: 100%;
        aspect-ratio: 16 / 9;
        height: auto;
        min-height: 0;
    }

    .camera-frame img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .panel-header {
        gap: 10px;
    }

    .panel-header h2 {
        font-size: 20px;
    }

    .live-badge {
        flex-shrink: 0;
    }

    .metrics-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 10px;
    }

    .metric-card {
        min-width: 0;
    }
}

.mobile-bottom-nav,
.mobile-more-menu {
    display: none;
}

@media (max-width: 768px) {

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;

        z-index: 1000;

        display: grid;
        grid-template-columns: repeat(4, 1fr);

        padding:
            8px
            10px
            calc(
                8px
                + env(safe-area-inset-bottom)
            );

        background: rgba(11, 15, 23, 0.96);
        backdrop-filter: blur(18px);

        border-top:
            1px solid rgba(
                255,
                255,
                255,
                0.08
            );
    }

    .mobile-nav-item {
        min-height: 52px;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        gap: 4px;

        border: 0;
        background: transparent;

        color: #8f9bab;
        text-decoration: none;

        font: inherit;
        font-size: 11px;

        cursor: pointer;
    }

    .mobile-nav-icon {
        font-size: 21px;
        line-height: 1;
    }

    .mobile-nav-item.active {
        color: #7aa2ff;
    }

    .mobile-more-menu {
        position: fixed;
        inset: 0;

        z-index: 1100;

        align-items: flex-end;

        background: rgba(0, 0, 0, 0.5);
    }

    .mobile-more-menu.open {
        display: flex;
    }

    .mobile-more-sheet {
        width: 100%;

        padding:
            10px
            18px
            calc(
                22px
                + env(safe-area-inset-bottom)
            );

        background: #121923;

        border-radius: 22px 22px 0 0;
    }

    .mobile-more-handle {
        width: 42px;
        height: 5px;

        margin:
            0 auto
            16px;

        border-radius: 999px;

        background: rgba(
            255,
            255,
            255,
            0.2
        );
    }

    .mobile-more-sheet a {
        display: block;

        padding: 16px 6px;

        color: #eef3f8;
        text-decoration: none;

        font-size: 17px;

        border-bottom:
            1px solid rgba(
                255,
                255,
                255,
                0.06
            );
    }

    .mobile-more-sheet a:last-child {
        border-bottom: 0;
    }

    .mobile-logout-link {
        color: #ff7b86 !important;
    }
}

/* =========================
   Login Page
   ========================= */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow:
        0 24px 70px rgba(0, 0, 0, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.login-card > p {
    margin: 0 0 26px;
    color: var(--muted);
}

.login-card form {
    display: flex;
    flex-direction: column;
}

.login-card label {
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.login-card input[type="text"],
.login-card input[type="email"],
.login-card input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    margin-bottom: 18px;
    color: var(--text);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    font-size: 15px;
}

.login-card input:focus {
    border-color: var(--primary);
}

.login-card .primary-button {
    width: 100%;
    margin-top: 6px;
    padding: 12px 16px;
}

.login-error {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255, 80, 80, 0.10);
    border: 1px solid rgba(255, 80, 80, 0.25);
}

@media (max-width: 760px) {
    .login-page .brand-name {
        font-size: 18px;
    }

    .login-page .brand-subtitle {
        font-size: 12px;
    }

    .login-card {
        padding: 26px 22px;
    }
}

.login-card input[type="email"],
.forgot-password-link {
    display: inline-block;
    width: fit-content;
    align-self: flex-start;
    margin: -6px 0 18px;
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
}

.forgot-password-link:hover {
    text-decoration: underline;
}

.danger-button {
    width: 100%;
    padding: 12px 16px;
    margin-top: 8px;
    margin-bottom: 20px;
    border: none;
    border-radius: 10px;
    background: #c93434;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.danger-button:hover {
    background: #b12b2b;
}

.family-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    padding: 16px 0;

    border-bottom:
        1px solid
        var(--border-color);
}


.family-member-info {
    min-width: 0;
}


.family-member-email,


.family-member-actions {
    display: flex;
    align-items: center;

    gap: 10px;

    flex-shrink: 0;
}


.family-role-select {
    min-width: 100px;

    padding: 7px 10px;

    border-radius: 8px;

    font-size: 13px;
}


.family-remove-button {
    padding: 7px 12px;

    border: 1px solid
        var(--danger);

    border-radius: 8px;

    background: transparent;

    color: var(--danger);

    font-size: 13px;

    cursor: pointer;
}

.family-role-badge {
    display: inline-block;

    margin-top: 6px;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 12px;
    font-weight: 600;

    background: var(--surface-secondary);
    color: var(--text-muted);
}


.family-role-owner {
    font-weight: 700;
}


.family-role-admin {
    font-weight: 600;
}


.family-role-user {
    font-weight: 500;
}

.family-you-label {
    margin-left: 6px;
    font-size: 12px;
    color: var(--text-muted);
}


/* =========================
   GateAI Mobile Side Menu
   ========================= */

.mobile-menu-button,
.mobile-menu-drawer,
.mobile-menu-overlay {
    display: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}


@media (max-width: 768px) {

    body {
        padding-bottom: 0;
    }


    .mobile-bottom-nav,
    .mobile-more-menu {
        display: none !important;
    }


    .topbar {
        min-height: 76px;
        padding:
            14px
            16px;
    }


    .topbar-left {
        min-width: 0;
        flex: 1;
    }


    .topbar-left > div {
        min-width: 0;
    }


    .topbar h1 {
        font-size: 24px;
    }


    .mobile-menu-button {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;

        display: flex;
        align-items: center;
        justify-content: center;

        padding: 0;

        border:
            1px solid
            var(--border);

        border-radius: 11px;

        background:
            var(--surface);

        color:
            var(--text);

        font-size: 24px;
        line-height: 1;

        cursor: pointer;
    }


    .mobile-menu-button:active {
        background:
            var(--surface-light);
    }


    .mobile-menu-overlay {
        position: fixed;
        inset: 0;

        z-index: 1190;

        background:
            rgba(
                0,
                0,
                0,
                0.58
            );

        opacity: 0;
        visibility: hidden;

        transition:
            opacity 180ms ease,
            visibility 180ms ease;
    }


    .mobile-menu-overlay.open {
        display: block;
        opacity: 1;
        visibility: visible;
    }


    .mobile-menu-drawer {
        position: fixed;

        top: 0;
        bottom: 0;
        left: 0;

        z-index: 1200;

        width: min(
            82vw,
            310px
        );

        display: flex;
        flex-direction: column;

        padding:
            calc(
                18px
                + env(safe-area-inset-top)
            )
            16px
            calc(
                18px
                + env(safe-area-inset-bottom)
            );

        background:
            rgba(
                13,
                19,
                27,
                0.99
            );

        border-right:
            1px solid
            var(--border);

        transform:
            translateX(-105%);

        transition:
            transform 220ms ease;

        overflow-y: auto;
    }


    .mobile-menu-drawer.open {
        transform:
            translateX(0);
    }


    .mobile-menu-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;

        gap: 12px;

        margin-bottom: 10px;
    }


    .mobile-menu-header .brand {
        padding:
            0
            0
            18px;
    }


    .mobile-menu-header .brand-name {
        display: block;
        font-size: 18px;
    }


    .mobile-menu-header .brand-subtitle {
        display: block;
        font-size: 12px;
    }


    .mobile-menu-close {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;

        display: flex;
        align-items: center;
        justify-content: center;

        padding: 0;

        border: 0;

        border-radius: 10px;

        background:
            transparent;

        color:
            var(--muted);

        font-size: 32px;
        line-height: 1;

        cursor: pointer;
    }


    .mobile-menu-close:active {
        background:
            var(--surface-light);

        color:
            var(--text);
    }


    .mobile-menu-navigation {
        display: flex;
        flex-direction: column;
        gap: 7px;
    }


    .mobile-menu-navigation .nav-item {
        justify-content: flex-start;

        padding:
            13px
            14px;

        font-size: 15px;
    }


    .mobile-menu-navigation
    .nav-item:not(.active) {
        font-size: 15px;
    }


    .mobile-menu-navigation
    .nav-item.active {
        font-size: 15px;
    }


    .mobile-menu-navigation
    .nav-icon {
        width: 24px;

        font-size: 18px;
    }


    .mobile-menu-footer {
        margin-top: auto;

        display: flex;
        align-items: center;

        gap: 10px;

        padding: 14px;

        background:
            var(--surface);

        border:
            1px solid
            var(--border);

        border-radius: 12px;
    }


    .mobile-menu-footer
    .user-footer-info {
        min-width: 0;
        flex: 1;
    }


    .mobile-menu-footer
    .connection-title,
    .mobile-menu-footer
    .connection-subtitle {
        display: block;
    }


    .mobile-menu-footer form {
        margin: 0;
    }
}

.camera-talk-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.camera-talk-controls .secondary-button {
    width: auto;
    min-width: 140px;
    flex: 0 0 auto;
}

.camera-talk-controls .muted {
    white-space: nowrap;
}

.camera-talk-controls .secondary-button.talking {
    transform: scale(0.98);
}
