* {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    padding: 10px;
    margin: 0;
    background: #f5f5f5;
	overflow-x: hidden;
}

button, select, input {
    font-size: 18px;
    width: 100%;
    margin: 5px 0;
    padding: 8px;
}

ul {
    list-style: none;
    padding: 0;
}

li {
    background: #fff;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 6px;
}

a {
    text-decoration: none;
    color: #000;
    display: block;
}

img {
    max-width: 100%;
    height: auto;
}
input,
select,
button,
textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Device Form - kompakt */
.device-form button {
    margin-top: 8px;
}

.device-form h3 {
    margin: 12px 0 8px 0;
    font-size: 16px;
}

/* Admin Devices - Layout */
body.admin-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.admin-top-section {
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 60%;
    padding-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.admin-bottom-section {
    flex-grow: 1;
    overflow-y: auto;
    padding-top: 20px;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* ⛔ Body darf nicht scrollen */
}

.device-header {
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    z-index: 1000;
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.scan-buttons {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.scan-buttons button {
    flex: 1;
}

.qr-reader {
    margin-top: 120px; /* Platz für Header */
    display: none;
}

.device-content {
    padding-bottom: 20px;
}

.device-card {
    background: #fff;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.device-card img {
    max-height: 80px;
    margin-bottom: 5px;
}

/* Device Image Container */
.device-image-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.device-image {
    display: block;
}

.device-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

/* Device Image Modal */
.device-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
    padding: 20px;
}

.device-image-modal img {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
}

/* Edit Entry Modal */
.edit-entry-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.edit-entry-modal-content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.edit-entry-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.edit-entry-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.edit-entry-modal-subtitle {
    margin: 3px 0 0 0;
    font-size: 0.85rem;
    color: #666;
}

.edit-entry-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-entry-modal-close:hover {
    color: #333;
}

#editEntryForm .form-group {
    margin-bottom: 15px;
}

#editEntryForm label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

#editEntryForm input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

#editEntryForm input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.edit-entry-modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.edit-entry-modal-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save {
    background: #28a745;
    color: white;
}

.btn-save:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.back-button {
    display: block;
    margin-bottom: 15px;
    font-size: 16px;
    text-decoration: none;
    color: #007bff;
}
.dashboard-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    z-index: 1000;
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.dashboard-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    font-size: 14px;
    color: #555;
}

.scan-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.scan-buttons button {
    flex: 1;
}

.qr-reader {
    display: none;
}

/* Suchfeld für Dashboard */
.dashboard-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-top: 8px;
}

.search-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.dashboard-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.dashboard-search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.dashboard-content {
    margin-top: 230px;
    padding-bottom: 20px;
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.device-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    font-size: 40px;
    text-decoration: none;
    color: #007bff;
    border-radius: 50%;
}

.nav-icon:active {
    background: #e6f0ff;
}
.device-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.device-image-wrapper {
    flex: 1;
}

.device-image {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    border-radius: 8px;
}

.qr-code-short {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    font-weight: normal;
}

.scan-btn {
    width: 48px;
    height: 48px;
    font-size: 22px;
    border-radius: 50%;
    border: none;
    background: #007bff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-btn:active {
    background: #0056b3;
}
/* Ganze Seite */
.device-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}


/* Oberer fixer Bereich */
.device-top {
    flex-shrink: 0;
    background: #fff;
    padding: 10px;
    border-bottom: 1px solid #ddd;
}


/* Header mit Bild & Scan */
.device-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.device-image {
    max-height: 80px;
    object-fit: contain;
    flex: 1;
}

/* Scan Buttons */
.scan-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
    border-radius: 50%;
    border: none;
}

.scan-btn.cancel {
    background: #eee;
}

/* Scrollbarer Verlauf */
.device-history {
    flex: 1;
    overflow-y: auto;      /* ✅ NUR HIER scrollen */
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    background: #fafafa;
}
.device-history {
    overscroll-behavior: contain;
}


.device-history ul {
    padding-left: 0;
}

.device-history li {
    list-style: none;
    padding: 8px;
    border-bottom: 1px solid #ddd;
}


/* Gesamte Seite */
.device-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 🔝 Oberer fixer Bereich */
.device-top {
    background: #fff;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

/* Header */
.device-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Bild */
.device-image {
    max-height: 90px;
    object-fit: contain;
    flex: 1;
}

/* Formular */
.device-form {
    margin-top: 10px;
}

/* 🔽 NUR HIER SCROLL */
.device-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #fafafa;
    -webkit-overflow-scrolling: touch;
}
.login-container {
    max-width: 360px;
    margin: 40px auto;
    padding: 20px;
}
/* Bild */
.login-image {
    max-height: 80px;
    object-fit: contain;
    flex: 1;
	box-align: middle;
}
.login-container input,
.login-container button {
    width: 100%;
    margin-bottom: 10px;
}

.message {
    background: #eef;
    padding: 10px;
    border-radius: 4px;
}

/* Input mit Label-Suffix */
.input-with-label {
    position: relative;
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.input-with-label input {
    flex: 1;
    margin: 0;
    padding: 8px;
    padding-right: 80px;
}

.input-with-label .label {
    position: absolute;
    right: 12px;
    font-size: 12px;
    color: #666;
    pointer-events: none;
}

/* Login-Links */
.login-links {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.link-group {
    margin-bottom: 15px;
}

.link-group p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
}

.link-group:last-child p {
    display: none;
}

.link-button {
    display: block;
    width: 100%;
    background: #007bff;
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.3s;
    text-align: center;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.link-button:hover {
    background: #0056b3;
}

.link-button.secondary {
    background: #6c757d;
}

.link-button.secondary:hover {
    background: #545b62;
}

/* History Container */
.device-history {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
}

/* History Tabelle */
.history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-table thead {
    background: #007bff;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid #0056b3;
}

.history-table th small {
    font-weight: 500;
    font-size: 11px;
}

.history-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.history-table .history-day-separator td {
    padding: 6px;
    border-top: 3px solid #0056b3;
    background: #f0f6ff;
    color: #0056b3;
    font-weight: 600;
    font-size: 12px;
    text-align: left;
}

.history-table .history-day-separator:hover {
    background: #f0f6ff;
}

.history-table tbody tr:hover {
    background: #f9f9f9;
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.history-table small {
    color: #999;
    font-size: 12px;
}

.unit-inline {
    color: #666;
    font-size: 0.9em;
    margin-left: 4px;
}

/* Admin Devices Tabelle */
.admin-devices-container {
    max-height: 600px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.admin-devices-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.admin-devices-table thead {
    background: #007bff;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-devices-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #0056b3;
}

.admin-devices-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.admin-devices-table code {
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.admin-devices-table tbody tr:hover {
    background: #f9f9f9;
}

.admin-devices-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-devices-table td a {
    display: inline-block;
    margin-right: 8px;
    font-size: 18px;
    text-decoration: none;
    cursor: pointer;
}

.admin-devices-table td a:hover {
    opacity: 0.7;
}
/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #555;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.footer-link:hover {
    opacity: 0.7;
}

.footer-logo {
    height: 24px;
    max-width: 100px;
    object-fit: contain;
}

/* ==================== ANALYTICS PAGE STYLES ==================== */

.analytics-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.analytics-header {
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 1px solid #ddd;
}

.analytics-filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.analytics-filters label {
    display: block;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 3px;
}

.analytics-filters input,
.analytics-filters select {
    width: 100%;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.9rem;
}

.analytics-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.analytics-buttons button,
.analytics-buttons a {
    padding: 0 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    flex: 1;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 0;
}

.analytics-buttons button:hover,
.analytics-buttons a:hover {
    background: #0056b3;
}

.analytics-buttons button:nth-child(2) {
    background: #dc3545;
}

.analytics-buttons button:nth-child(2):hover {
    background: #c82333;
}

.analytics-buttons button:nth-child(3) {
    background: #28a745;
}

.analytics-buttons button:nth-child(3):hover {
    background: #218838;
}

.analytics-content {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    flex: 1;
    overflow: hidden;
    padding: 15px;
}

.analytics-table-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.analytics-table-section h3 {
    margin: 0;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    font-size: 0.95rem;
}

.analytics-table-wrapper {
    overflow-y: auto;
    flex: 1;
}

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

.analytics-table thead {
    position: sticky;
    top: 0;
    background: #e9ecef;
    z-index: 10;
}

.analytics-table th {
    padding: 8px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-weight: bold;
}

.analytics-table td {
    padding: 8px;
    border-bottom: 1px solid #ddd;
}

.analytics-table tbody tr:hover {
    background: #f5f5f5;
}

.analytics-chart-section {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    overflow: hidden;
}

.analytics-chart-section h3 {
    margin: 0;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    font-size: 0.95rem;
}

.analytics-chart-wrapper {
    flex: 1;
    padding: 15px;
    overflow: auto;
    position: relative;
}

.analytics-tab-btn {
    flex: 1;
    padding: 12px;
    background: #e9ecef;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.analytics-tab-btn.active {
    background: white;
    border-bottom-color: #007bff;
    color: #007bff;
}

.analytics-tab-content {
    display: flex;
    flex-direction: column;
}

.analytics-tab-content.active {
    display: flex;
    flex-direction: column;
}

.analytics-tabs {
    display: none !important;
}

/* Mobile Chart Mode Buttons */
.analytics-chart-wrapper-header {
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 15px;
}

.analytics-chart-wrapper-header label {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .analytics-tabs {
        display: flex !important;
        flex-shrink: 0;
        gap: 0;
        background: #f8f9fa;
        border-bottom: 2px solid #007bff;
        padding: 0;
    }

    .analytics-page {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .analytics-header {
        padding: 6px;
        flex-shrink: 0;
    }

    .analytics-filters {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 6px;
    }

    .analytics-filters > div {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .analytics-filters > div > div {
        display: flex;
        gap: 4px;
        flex: 1;
    }

    .analytics-filters label {
        font-size: 0.75rem;
        font-weight: bold;
        margin: 0;
        white-space: nowrap;
        min-width: 70px;
    }

    .analytics-filters input,
    .analytics-filters select {
        padding: 4px;
        font-size: 0.8rem;
        flex: 1;
    }

    .analytics-buttons {
        display: flex;
        gap: 6px;
        margin-top: 6px;
    }

    .analytics-buttons button,
    .analytics-buttons a {
        padding: 5px 8px;
        font-size: 0.8rem;
        flex: 1;
        min-width: auto;
    }

    .analytics-content {
        display: grid;
        grid-template-rows: 1fr;
        gap: 8px;
        flex: 1;
        overflow: hidden;
        padding: 8px 8px 60px 8px;
    }

    .analytics-table-section.analytics-tab-content,
    .analytics-chart-section.analytics-tab-content {
        display: none;
    }

    .analytics-table-section.analytics-tab-content.active,
    .analytics-chart-section.analytics-tab-content.active {
        display: flex;
    }

    .analytics-table-section {
        max-height: none;
        overflow: hidden;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .analytics-table-section h3 {
        margin: 0;
        padding: 4px 6px;
        background: #f8f9fa;
        border-bottom: 1px solid #ddd;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    .analytics-table-wrapper {
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    .analytics-table th,
    .analytics-table td {
        padding: 4px;
    }

    .analytics-chart-section {
        min-height: auto;
        overflow: hidden;
        flex: 1;
    }

    .analytics-chart-wrapper {
        padding: 8px;
        position: relative;
        height: 100%;
        overflow: auto;
    }

    .analytics-chart-wrapper-header {
        padding: 6px !important;
        gap: 6px !important;
        flex-wrap: wrap;
    }

    .analytics-chart-wrapper-header label {
        margin: 0 !important;
        font-size: 0.7rem !important;
        white-space: nowrap;
        flex: 0 1 auto;
    }

    .analytics-chart-wrapper-header input {
        margin-right: 2px !important;
    }
}

@media (max-width: 480px) {
    .analytics-filters {
        grid-template-columns: 1fr;
    }

    .analytics-filters div:has(> div) {
        grid-template-columns: 1fr;
    }

    .analytics-buttons button,
    .analytics-buttons a {
        min-width: 100px;
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    .analytics-table-section {
        max-height: 250px;
    }

    .analytics-table {
        font-size: 0.75rem;
    }

    .analytics-table th,
    .analytics-table td {
        padding: 3px;
    }
}