:root {
    --bg: #F4F1E9;
    --text: #3B3B3B;
    --primary: #C98474;
    --secondary: #7A8C69;
    --border: #A08970;
    --danger: #c75b5b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Nunito", sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 16px;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { color: var(--primary); }

.container {
    max-width: 1400px;
    margin: auto;
    padding: 16px;
    background: #ffffffee;
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px #00000010;
}

header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
}

.brand {
    font-family: "Amatic SC", cursive;
    font-size: 36px;
}

nav {
    margin-left: auto;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 999px;
    background: #00000005;
}

nav a.active {
    background: var(--secondary);
    color: #fff;
}

/* Buttons */
button, .btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: .15s;
}
button:hover, .btn:hover {
    filter: brightness(0.95);
}
.btn.secondary { background: var(--secondary); }
.btn.danger { background: var(--danger); }

/* Inputs */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
}

/* Chrome-Datepicker Bugfix */
input[type="date"] {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 3px 6px !important; /* WICHTIG */
    font-size: 14px;
}

/* Layout helpers */
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.col { flex: 1 1 0; }

.form-row { margin-bottom: 10px; }
label { display: block; margin-bottom: 4px; font-weight: 600; }

/* Messages */
.notice, .error {
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 14px;
}
.notice {
    background: #e8f6ea;
    color: #234f2a;
}
.error {
    background: #fdecea;
    color: #7a1f1f;
}

/* Table */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    max-height: 55vh;         /* Scrollbereich */
    overflow-y: auto;         /* vertikales Scrollen aktivieren */
}

.table {
    width: 100%;         /* NEU: volle Breite nutzen */
    max-width: 1400px;   /* NEU: mehr Platz geben! */
    margin: auto;        /* zentriert */
    border-collapse: collapse;
}

/* Standard-Tabellenkopf NICHT einfärben */
.table th {
    background: #f6f4ee;   /* Giesswerk hellbeige */
    color: var(--text);
    font-weight: 700;
}

.table td, .table th {
    border-right: 1px solid #ddd;  /* schmale Trennung */
}

.table th:last-child,
.table td:last-child {
    border-right: none;  /* letzte Spalte ohne Rand */
}

.table td {
    padding: 10px 14px;      /* mehr Raum → besser lesbar */
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

.table th {
    padding: 12px 14px;
    letter-spacing: 0.5px;
}

.table tr {
    transition: .1s ease-in-out;
}

.table tr:hover {
    background: #faf9f5;   /* sanftes Beige */
    filter: brightness(1.02);
}

@media (max-width: 768px) {
    .table {
        font-size: 13px;
        max-width: 100%;
    }
    .table th, .table td {
        padding: 8px;
    }
}


/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: #00000055;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(3px);
}
.modal-box {
    background: white;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
    width: 95%;
    max-width: 800px;
    box-shadow: 0 10px 25px #00000033;
    animation: fadeIn .18s ease-out;
	position: relative; 
}
.modal-box img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.modal-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #c75b5b;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: bold;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.footer {
    margin-top: 16px;
    font-size: 12px;
    text-align: center;
    color: #777;
}

/* Search Bar */
.searchbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}
.searchbar input {
    max-width: 250px;
}

/* Stats cards */
.stat-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 10px 0 16px;
}
.stat-card {
    flex: 1 1 100px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #eee;
    padding: 10px 12px;
    box-shadow: 0 3px 8px #00000010;
}
.stat-card-title {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}
.stat-card-value {
    font-size: 18px;
    font-weight: 700;
}


/* Highlight der sortierten Spalte (nur Zellen, nicht ganze Zeile!) */
th.active-sort {
    background: #e7e4d6 !important; /* nur leicht dunkler */
    color: var(--text);
}

.search-box {
    border-radius: 10px;
    border: 1px solid #ccc;
}

label {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    margin-bottom: 12px;
}
#csvResult {
    border: 1px solid var(--border);
    background: #fafafa;
    padding: 10px;
    border-radius: 12px;
}

#csvPreviewTable td {
    font-size: 14px;
    padding: 6px 10px;
}

.status-ok { color: #3B7A3D; font-weight: 600; }
.status-error { color: #B93535; font-weight: bold; }

.pagination {
    margin-top: 18px;
    text-align: center;
    font-size: 14px;
}
.pagination-buttons {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
.page-btn {
    padding: 6px 10px;
    border-radius: 8px;
    background: #00000010;
}
.page-btn.active {
    background: var(--secondary);
    color: white;
}
.page-btn:hover {
    filter: brightness(0.9);
}

.pagination button {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 6px 14px;
    margin: 0 5px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}
.pagination button:hover {
    filter: brightness(0.9);
}

/* Sortierte Spalte hervorheben */
th.sorted {
    background: var(--secondary);
    color: #fff;
}
/* Sortierbare Spalten im Verkäufe-Table */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
}

/* Pfeile je nach Sortierreihenfolge */
th.sortable.asc::after {
    content: "▲";
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    opacity: 0.8;
}

th.sortable.desc::after {
    content: "▼";
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    opacity: 0.8;
}

/* Hervorhebung der aktuell sortierten Spalte */
th.sorted {
    background: #d6cfbf !important; /* leicht dunkler als Standard */
    color: #333 !important;          /* gut lesbar */
    font-weight: 700;
}

/* Aktionen in Verkaufs-Tabelle kompakter darstellen */
.action-buttons {
    display: flex;
    gap: 6px;          /* Abstand zwischen Buttons */
    flex-wrap: nowrap; /* verhindert Umbruch */
}

.action-buttons .btn {
    padding: 5px 10px;     /* Buttons etwas kleiner */
    font-size: 12px;
}
/* Zeilen mit fehlendem Datum markieren */
tr.unpaid {
    background: #fff2f2 !important;   /* sehr sanftes Rot */
}


.table thead th {
    position: sticky;
    top: 0;
    background: #f6f4ee;      /* Giesswerk-Farbton */
    z-index: 5;
    padding: 8px; 
    border-bottom: 2px solid var(--border);
	box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
/* Verhindert Zeilenumbruch bei Umsatz & Einkauf */
.nowrap {
    white-space: nowrap;
}

/* 📌 Filterbereich – modern & responsive */
.filter-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.filter-item label {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 3px;
}

.filter-input,
.filter-select,
.filter-date {
    width: 200px;
    height: 38px;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
}

/* zwei Buttons rechts bündig */
.filter-buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.reset-btn {
    background: #c9ccb2 !important;  /* etwas helleres Grün/Beige */
    color: #414141;
}

.reset-btn:hover {
    filter: brightness(0.92);
}

/* 💡 Mobile */
@media (max-width: 600px) {
    .filter-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-buttons {
        margin-left: 0;
        justify-content: flex-start;
    }
}

.product-thumb {
    width: 60px;
    cursor: pointer;
    border-radius: 8px;
    transition: .2s;
}
.product-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#productImageArea img {
    max-width: 90%;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.form-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row > label {
    flex: 1;
    margin: 0;
}

.form-row .small {
    flex: 0 0 180px;
}
.form-row-inline {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    gap: 8px;
}

@media (max-width: 480px) {
    .form-row-inline {
        grid-template-columns: 70px 1fr 70px;
        gap: 6px;
    }
}


.btn-small {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
    background: var(--secondary);
    color: white;
    border: none;
    cursor: pointer;
}

.btn-small:hover {
    filter: brightness(0.9);
}

.toast-msg {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    color: white;
    padding: 14px 22px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    z-index: 99999;
    opacity: 1;
    transition: opacity 0.4s ease-in-out;
}


.no-image {
    color: #aaa;
    font-size: 12px;
}

.ts-wrapper {
    font-family: "Nunito", sans-serif;
	font-size: 14px !important;
}
.ts-control {
    border-radius: 12px !important;
    border: 1px solid var(--border);
    background: #fff;
}
.ts-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 5px var(--primary);
}

.date-input {
    color: #aaa;
}

.date-input:focus,
.date-input.has-value {
    color: #000;
}

input[type="date"].date-input {
    color: #aaa;
}

input[type="date"].date-input.has-value {
    color: #000 !important;
}



.date-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.today-btn {
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.status-cell {
    white-space: nowrap;
    text-align: center;
}

.status-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    opacity: 0.2;
    font-size: 1.1em;
}

.status-icon.ok {
    opacity: 1;
}

/* Container für die Status-Einträge */
.status-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.74rem; /* Kleinere Schriftgröße für bessere Lesbarkeit */
    line-height: 1.2;
}

/* Einzeilige Ausrichtung pro Status-Typ */
.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #888; /* Standardfarbe für unerledigte Datumsangaben */
}

/* Grüne Hervorhebung für gesetzte Daten */
.status-item.ok {
    color: #2e7d32;
    font-weight: 500;
}

/* Icon-Fixierung für einheitliche Spaltenausrichtung */
.status-item .status-icon {
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
}

/* Datumstext */
.status-item .status-date {
    font-variant-numeric: tabular-nums; /* Sorgt für gleichmäßig breite Zahlen */
}

/* Tabellenzelle anpassen */
.table td.status-cell {
    vertical-align: middle;
    padding-top: 6px;
    padding-bottom: 6px;
    white-space: nowrap;
}

/* Checkboxen etwas kleiner & zentriert */
.row-checkbox, #selectAllCheckbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #007bff;
    vertical-align: middle;
    margin: 0;
}

/* Optional: Spalte ganz schmal halten */
.table th:first-child, 
.table td:first-child {
    width: 30px;
    text-align: center;
}

/* Schwebe-Leiste am unteren Bildschirmrand */
.selected-total-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 999;
    animation: slideUp 0.2s ease-out;
    width: 90%;
    max-width: 420px;
}

.total-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.total-amount strong {
    font-size: 1.15rem;
    color: #4ade80; /* Grüne Preisanzeige */
    margin-left: 6px;
}

/* Animation beim Erscheinen */
@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Zelle klickbar machen und visueller Effekt */
.checkbox-cell {
    cursor: pointer;
    text-align: center;
}

.checkbox-cell:hover {
    background-color: rgba(0, 0, 0, 0.03); /* Leichter Hover-Effekt */
}

/* Styling für das Bild-Modal */
.modal-overlay#imageModal {
    display: none;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    z-index: 3000;
}

/* Modal-Box richtet sich nach der Bildgröße aus (fit-content) */
.image-modal-box {
    position: relative;
    width: fit-content;
    max-width: 90vw;
    max-height: 90vh;
    padding: 12px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bild skaliert sauber innerhalb des Modals */
.image-modal-box img {
    max-width: 85vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

/* Schließen-Button oben rechts über dem Bild */
.image-modal-box .close-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    background: #ffffff;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 10;
}
.image-modal-box .close-btn:hover {
    background: #f0f0f0;
}