:root {
    --primary: #22c55e;
    --primary-dark: #16a34a;
    --bg-dark: #09090b;
    --card-bg: #18181b;
    --text-main: #fafafa;
    --text-muted: #a1a1aa;
    --border: #27272a;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
    margin-top: 20px;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.header-logo {
    height: 38px;
    /* Refined size */
    width: auto;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #4ade80);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 4px;
    /* Manual nudge to balance with SVG baseline */
}

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

.user-identity {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(39, 39, 42, 0.6);
    padding: 6px 12px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.user-identity i {
    color: var(--primary);
    font-size: 1rem;
}

.user-identity span {
    color: var(--text-dim);
    font-weight: 500;
}

/* Busy Banner */
.busy-banner {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #eab308;
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

/* Bot Busy Overlay */
.busy-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 9, 11, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.busy-card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.busy-icon {
    font-size: 3.5rem;
    color: #eab308;
    /* Yellow warning color */
    margin-bottom: 20px;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.busy-card h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: #fff;
}

.busy-user {
    background: #27272a;
    color: var(--primary);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    margin: 15px auto;
    display: inline-block;
    border: 1px solid var(--primary);
}

/* Queue Styling */
.queue-status {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 25px;
}

.queue-label {
    display: block;
    font-size: 0.9rem;
    color: #a1a1aa;
    margin-bottom: 5px;
}

.queue-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: #22c55e;
    text-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.busy-card p {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 20px;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

input[type="number"],
input[type="text"],
select {
    flex: 1;
    background: #09090b;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
    padding-right: 45px;
}

select option {
    background: var(--card-bg);
    color: white;
}

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

button {
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    transition: all 0.2s;
}

#start-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 40px;
    font-size: 0.95rem;
    min-width: 160px;
}

#start-btn:active {
    transform: scale(0.95);
}

#start-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.result-card h3,
.mgmt-card h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    font-weight: 600;
    color: var(--primary);
}

.data-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-box {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 16px;
    font-size: 0.95rem;
    color: #e2e8f0;
    animation: slideUp 0.4s ease-out;
}

.product-box.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.product-box.clickable:hover {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.1);
}

.product-box.clickable:active {
    transform: translateY(0);
    background: rgba(34, 197, 94, 0.25);
}

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

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

.status-msg {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
    border-radius: 8px;
}

.loading-placeholder {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Management Card Styles */
.mgmt-card {
    position: relative;
    border: 2px solid var(--primary);
    background: #1c1c1f;
    /* Solid dark color, more distinct */
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 5px;
}

.mgmt-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.serial-tag {
    background: #27272a;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 1rem;
    color: #4ade80;
}

.mgmt-form {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-with-action {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: #27272a;
    border: 1px solid var(--border);
    color: white;
    width: 54px;
    border-radius: 12px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active {
    background: #3f3f46;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 1rem;
    margin-top: 10px;
}

.secondary-btn {
    background: #27272a;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px;
    margin-top: 10px;
    width: 100%;
}

/* Scanner Styles */
.scanner-wrapper {
    position: fixed;
    /* Use fixed to cover screen correctly on mobile */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    height: 380px;
    /* Increased to fit buttons */
    background: var(--bg-dark);
    border: 2px solid var(--primary);
    border-radius: 20px;
    z-index: 1000;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.8);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.scanner-actions {
    display: flex;
    gap: 10px;
}

.scanner-actions .secondary-btn {
    flex: 1;
    margin-top: 0;
}

#reader {
    flex: 1;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.login-card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.login-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.login-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #fff;
}


.login-header p {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 30px;
}

.login-form {
    text-align: left;
}

#login-btn {
    display: block;
    width: fit-content;
    margin: 30px auto 0;
    padding-left: 50px;
    padding-right: 50px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    margin-top: 5px;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.remember-me {
    margin: 20px 0;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dim);
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: #27272a;
    border-radius: 6px;
    border: 1px solid #3f3f46;
    transition: all 0.2s;
}

.checkbox-container:hover input~.checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.error-msg {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 20px;
    text-align: center;
}

footer {
    margin-top: auto;
    padding: 20px 0;
    text-align: center;
}

.dev-info {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.release-btn-bottom {
    width: 100%;
    max-width: 440px;
    margin: 20px auto 10px;
    padding: 16px;
    background: #18181b;
    color: #ef4444;
    border: 1px solid #ef4444;
    border-radius: 16px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.release-btn-bottom:hover {
    background: #ef4444;
    color: #fff;
    transform: translateY(-2px);
}

.release-btn-bottom i {
    font-size: 1.1rem;
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
}


/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 1500;
    /* Below cards (2000), above content */
}

/* UI Feedback Cards */
.feedback-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 20px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.9);
}

.feedback-card h3 {
    font-size: 1.5rem;
    margin: 20px 0 10px;
    color: #fff;
    font-weight: 600;
}

.feedback-card p {
    color: #a1a1aa;
    margin-bottom: 25px;
    font-size: 1rem;
    line-height: 1.5;
}

.icon-large {
    font-size: 4rem;
    margin-bottom: 10px;
}

/* Specific States */
.success {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
    /* Subtle green tint */
}

.success .icon-large {
    color: #22c55e;
}

.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    /* Subtle red tint */
}

.error .icon-large {
    color: #ef4444;
}

/* Clock Loader Animation */
.clock-loader {
    font-size: 4rem;
    color: #3b82f6;
    /* Blue for neutral loading */
    animation: pulse-rotate 2s infinite ease-in-out;
    margin: 20px 0;
}

@keyframes pulse-rotate {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.8;
    }

    50% {
        transform: rotate(180deg) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: rotate(360deg) scale(1);
        opacity: 0.8;
    }
}

/* Force hide status message when modal is active */
body.has-modal #status-msg {
    display: none !important;
}

/* Logout Button */
.logout-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 10px;
    padding: 5px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn:hover {
    color: #ff4d4d;
    transform: scale(1.1);
}

.user-identity {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Action Selection Card */
.action-card {
    border: 2px solid var(--primary);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 15px 0;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 24px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.05) 100%);
    border: 2px solid rgba(34, 197, 94, 0.4);
    border-radius: 16px;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 0;
}

.action-btn:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.25);
}

.action-btn:hover::before {
    opacity: 0.15;
}

.action-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.2);
}

.action-btn i {
    font-size: 2rem;
    color: var(--primary);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 12px;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.action-btn span {
    flex: 1;
    text-align: left;
    position: relative;
    z-index: 1;
}

.action-btn .action-desc {
    display: block;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===================== ADMIN PANEL ===================== */

.admin-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.admin-btn:hover {
    background: rgba(34, 197, 94, 0.15);
}

.admin-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 3000;
    padding: 20px;
    overflow-y: auto;
}

.admin-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 500px;
    margin: 20px 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.admin-header h2 {
    font-size: 1.3rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-section {
    margin-bottom: 30px;
}

.admin-section h3 {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(39, 39, 42, 0.5);
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

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

.user-info i {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.user-info .username {
    font-weight: 600;
    color: var(--text-main);
}

.user-info .role-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    font-weight: 600;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.role-badge.user {
    background: rgba(34, 197, 94, 0.2);
    color: var(--primary);
}

.delete-user-btn {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.delete-user-btn:hover {
    background: var(--danger);
    color: white;
}

.delete-user-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.admin-form .form-group {
    margin-bottom: 0;
}

.admin-form input,
.admin-form select {
    width: 100%;
    padding: 12px;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    margin-top: 5px;
}

.admin-form select {
    cursor: pointer;
}

.admin-form input:focus,
.admin-form select:focus {
    outline: none;
    border-color: var(--primary);
}

.admin-message {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}

.admin-message.success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.admin-message.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-right: 45px;
}

.toggle-pass-btn {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    font-size: 1rem;
}

.toggle-pass-btn:hover {
    color: var(--primary);
}

.admin-section h3 i {
    margin-right: 8px;
    color: var(--primary);
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.info-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--primary);
}

.info-badge i {
    font-size: 1rem;
}

.admin-form input[type="number"] {
    width: 100%;
    padding: 12px;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    margin-top: 5px;
}

.admin-form input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}