:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #ffffff;
    --text-muted: #b0b0b0;
    --ups-brown: #351c15;
    --ups-gold: #ffb500;
    --action-green: #00e676;
    --alert-red: #ff1744;
    --btn-height: 60px;
}

#toast-container {
    position: fixed;
    bottom: 80px;
    /* Raised to avoid covering bottom back button */
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: #333;
    color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    text-align: center;
    border-left: 5px solid var(--ups-gold);
    animation: slideUp 0.3s ease-out;
    opacity: 1;
    transition: opacity 0.5s;
}

.toast-error {
    border-left-color: var(--alert-red);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.fade-out {
    opacity: 0;
}


body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

/* VIEW MANAGEMENT */
section {
    padding: 20px;
    height: 100vh;
    display: none;
    flex-direction: column;
}

section.active-view {
    display: flex;
}

/* LOGIN */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    gap: 20px;
}

h1#app-logo {
    color: var(--ups-gold);
    text-align: center;
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 15px;
    background: var(--card-bg);
    border: 2px solid #333;
    color: white;
    font-size: 1.2rem;
    border-radius: 8px;
    text-transform: uppercase;
}

input:focus {
    border-color: var(--ups-gold);
    outline: none;
}

button {
    background: var(--ups-gold);
    color: black;
    border: none;
    font-weight: bold;
    border-radius: 8px;
    font-size: 1.2rem;
    padding: 0 20px;
    height: var(--btn-height);
    cursor: pointer;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.98);
}

.btn-large {
    width: 100%;
    font-size: 1.5rem;
}

.btn-primary {
    background-color: var(--ups-gold);
    color: black;
}

.btn-action {
    background-color: #333;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    height: 80px;
    font-size: 1.5rem;
    width: 100%;
    border: 2px solid var(--ups-gold);
}

.btn-back {
    background: transparent;
    color: var(--ups-gold);
    padding: 10px;
    width: auto;
    height: auto;
    font-size: 1rem;
}

.bottom-btn {
    margin-top: auto;
    /* Push to bottom in flex container */
    width: 100%;
    border: 1px solid #333;
    padding: 15px;
    text-align: center;
}

/* DASHBOARD */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.sync-status.online {
    color: var(--action-green);
}

.sync-status.offline {
    color: var(--alert-red);
}

.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 30px;
}

.stat-box {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.express-triangle {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid red;
    position: relative;
    margin-right: 10px;
}

.express-triangle::after {
    content: '!';
    position: absolute;
    top: 2px;
    left: -3px;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.stat-val {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--ups-gold);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Progress Bar */
.progress-container {
    width: 90%;
    margin: 10px auto;
    background: #333;
    height: 20px;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid #555;
}

.progress-bar {
    height: 100%;
    background: #ffb500;
    /* UPS Gold */
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    position: absolute;
    width: 100%;
    text-align: center;
    top: 0;
    line-height: 20px;
    font-size: 12px;
    color: #000;
    font-weight: bold;
}

/* Grouping Badges */
.count-badge {
    background: #351c15;
    /* UPS Brown */
    color: #fff;
    /* White Text */
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    border: 1px solid #fff;
    /* White Thin Border */
    margin-right: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.camera-section {
    position: relative;
    background: black;
    height: 300px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px dashed #444;
}

video#camera-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

button#snap-btn {
    position: absolute;
    bottom: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    width: 120px;
}

.manual-input {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

/* LIST / AUSLIEFERN */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.filter-btn {
    background: #333;
    color: white;
    flex: 1;
    font-size: 1rem;
    height: 50px;
}

.filter-btn.active {
    background: var(--ups-gold);
    color: black;
}

ul.package-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.package-item {
    background: var(--card-bg);
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 8px;
    border-left: 5px solid #444;
    position: relative;
    user-select: none;
    transition: transform 0.2s, opacity 0.2s;
}

.package-item.express {
    border-left-color: var(--alert-red);
}

.package-item.done {
    opacity: 0.5;
}

.pkg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.pkg-fach {
    background: #333;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    color: var(--ups-gold);
}

.pkg-addr {
    font-size: 1.2rem;
    font-weight: bold;
}

.pkg-name {
    color: var(--text-muted);
}

.pkg-meta {
    font-size: 0.8rem;
    margin-top: 5px;
    color: var(--action-green);
}

/* SWIPE ACTIONS (Visual indicator) */
.swipe-bg-right {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--action-green);
    z-index: -1;
    border-radius: 8px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-left: 20px;
    font-weight: bold;
    color: black;
    display: none;
    /* Toggled by JS logic mainly */
}

.pkg-note {
    background: #444;
    padding: 5px;
    margin-top: 5px;
    border-radius: 4px;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--ups-gold);
}

.btn-small {
    background: #333;
    border: 1px solid #666;
    color: white;
    padding: 5px 10px;
    font-size: 0.9rem;
    height: auto;
}

/* ADMIN */
#admin-trigger-area {
    height: 50px;
    width: 100px;
    margin: 0 auto;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.modal-content {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Admin Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid #333;
}

.admin-table th {
    background: #333;
    color: var(--ups-gold);
}