/* ========================================
   DataLog Scanner – PWA Stylesheet v2
   Dark theme, glassmorphism, mobile-first
   ======================================== */

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

:root {
    --bg: #0f172a;
    --bg2: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-glass: rgba(30, 41, 59, 0.6);
    --border: rgba(148, 163, 184, 0.15);
    --text: #f1f5f9;
    --text2: #94a3b8;
    --text3: #64748b;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --ok: #22c55e;
    --ok-bg: rgba(34, 197, 94, 0.15);
    --err: #ef4444;
    --err-bg: rgba(239, 68, 68, 0.15);
    --warn: #f59e0b;
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
    --tr: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, sans-serif;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

html, body {
    height: 100%; overflow: hidden;
    font-family: var(--font); background: var(--bg); color: var(--text);
    -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ---- Screens ---- */
.screen {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; transform: translateX(24px);
    transition: all 0.3s ease; z-index: 1;
}
.screen.active { opacity: 1; visibility: visible; transform: none; z-index: 10; }

/* ===== CONNECT SCREEN ===== */
.connect-container {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 24px; gap: 28px;
    background: radial-gradient(ellipse at 50% 0%, rgba(59,130,246,0.08) 0%, transparent 60%);
}

.logo-section { text-align: center; animation: fadeUp 0.5s ease-out; }

.logo-icon {
    width: 76px; height: 76px; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: var(--r-lg); color: #fff;
    box-shadow: 0 8px 32px var(--accent-glow);
    animation: glow 3s ease-in-out infinite;
}

.logo-section h1 {
    font-size: 26px; font-weight: 800; letter-spacing: -0.5px;
    background: linear-gradient(135deg, #f1f5f9, #94a3b8);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle { color: var(--text2); font-size: 13px; margin-top: 4px; }

.glass-card {
    width: 100%; max-width: 380px;
    background: var(--bg-glass); backdrop-filter: blur(20px);
    border: 1px solid var(--border); border-radius: var(--r-xl);
    padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: fadeUp 0.5s ease-out 0.1s both;
}

/* Client IP Badge */
.client-ip-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--r-md);
    margin-bottom: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--tr);
}
.client-ip-badge:active {
    transform: scale(0.98);
}
.client-ip-badge:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}
.client-ip-badge.detected {
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.25);
}
.client-ip-icon { font-size: 14px; }
.client-ip-label { color: var(--text3); font-weight: 500; }
.client-ip-val {
    color: var(--accent);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    flex: 1;
    text-align: right;
}
.client-ip-badge.detected .client-ip-val {
    color: var(--ok);
}

/* Status */
.status-indicator {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; background: var(--bg2); border-radius: var(--r-md);
    margin-bottom: 16px; font-size: 13px;
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--text3);
    transition: all var(--tr);
}
.status-indicator.connected .status-dot { background: var(--ok); box-shadow: 0 0 8px rgba(34,197,94,0.5); animation: blink 2s infinite; }
.status-indicator.error .status-dot { background: var(--err); }
.status-text { color: var(--text2); }
.status-indicator.connected .status-text { color: var(--ok); }
.status-indicator.error .status-text { color: var(--err); }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.input-hint { font-size: 11px; color: var(--text3); margin-top: 6px; }

.input-row { display: flex; gap: 8px; }
.input-row input {
    flex: 1; height: 48px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 0 16px; color: var(--text);
    font-size: 16px; font-family: var(--font); outline: none; transition: border-color var(--tr);
}
.input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-row input::placeholder { color: var(--text3); }

/* Scan network */
.btn-scan-network {
    width: 100%; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px;
    background: none; border: 1px dashed var(--border); border-radius: var(--r-md);
    color: var(--accent); font-size: 13px; font-weight: 500; font-family: var(--font);
    cursor: pointer; transition: all var(--tr); margin-bottom: 12px;
}
.btn-scan-network:active { background: rgba(59,130,246,0.08); border-color: var(--accent); }

.scan-section { margin-bottom: 12px; }
.scan-progress {
    height: 3px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-bottom: 8px;
}
.scan-progress-bar {
    height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 2px; transition: width 0.3s ease; width: 0%;
}
.scan-status-text { font-size: 11px; color: var(--text3); margin-bottom: 8px; }

.scan-results { display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }
.scan-result-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: var(--bg2); border-radius: var(--r-sm);
    cursor: pointer; transition: background var(--tr); border: 1px solid transparent;
}
.scan-result-item:active { background: var(--bg); }
.scan-result-item.ready { border-color: rgba(34,197,94,0.2); }
.scan-result-item.no-data { border-color: rgba(245,158,11,0.2); }

.scan-result-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--ok); box-shadow: 0 0 6px rgba(34,197,94,0.4);
    animation: blink 2s infinite;
}
.scan-result-item.no-data .scan-result-dot { background: var(--warn); box-shadow: 0 0 6px rgba(245,158,11,0.3); }

.scan-result-info { flex: 1; min-width: 0; }
.scan-result-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-result-addr { font-size: 11px; color: var(--text3); font-family: 'Courier New', monospace; }

.divider { height: 1px; background: var(--border); margin: 4px 0 12px; }

/* Saved connections */
.saved-connections { margin-top: 14px; }
.saved-label { font-size: 12px; color: var(--text3); margin-bottom: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.saved-list { display: flex; flex-direction: column; gap: 4px; }
.saved-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; background: var(--bg2); border-radius: var(--r-sm);
    cursor: pointer; transition: background var(--tr);
}
.saved-item:active { background: var(--bg); }
.saved-item-info { flex: 1; min-width: 0; }
.saved-item-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-item-addr { font-size: 11px; color: var(--text3); font-family: 'Courier New', monospace; }

/* Buttons */
.btn-primary {
    width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border: none; border-radius: var(--r-md); color: #fff;
    font-size: 16px; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: all var(--tr);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
.btn-lg { height: 54px; font-size: 17px; border-radius: var(--r-lg); }

.btn-secondary {
    flex: 1; height: 46px; display: flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-md);
    color: var(--text2); font-size: 13px; font-weight: 500; font-family: var(--font);
    cursor: pointer; transition: all var(--tr);
}
.btn-secondary:active { background: var(--bg); }
.btn-secondary:disabled { opacity: 0.3; }

.btn-submit {
    flex: 2; height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(135deg, var(--ok), #16a34a);
    border: none; border-radius: var(--r-md); color: #fff;
    font-size: 15px; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: all var(--tr);
    box-shadow: 0 4px 16px rgba(34,197,94,0.25);
}
.btn-submit:active { transform: scale(0.97); }
.btn-submit:disabled { opacity: 0.3; box-shadow: none; }

.btn-icon-sm {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: var(--r-sm);
    color: var(--text); cursor: pointer; transition: all var(--tr); flex-shrink: 0;
}
.btn-icon-sm:active { background: rgba(255,255,255,0.1); transform: scale(0.9); }
.btn-icon-sm.active { color: var(--warn); }

.btn-text {
    background: none; border: none; color: var(--text3); font-size: 14px;
    font-family: var(--font); cursor: pointer; padding: 12px;
}

.btn-expand {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text3); cursor: pointer;
    transition: transform 0.3s ease;
}
.code-list-panel.expanded .btn-expand { transform: rotate(180deg); }

/* Server info */
.server-info {
    margin-top: 14px; padding: 12px; background: var(--ok-bg);
    border: 1px solid rgba(34,197,94,0.2); border-radius: var(--r-md);
}
.info-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.info-row span:first-child { color: var(--text3); }
.info-row span:last-child { color: var(--ok); font-weight: 500; }

/* Saved connections */
.saved-connections { margin-top: 14px; }
.saved-label { font-size: 12px; color: var(--text3); margin-bottom: 8px; }
.saved-list { display: flex; flex-direction: column; gap: 6px; }
.saved-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; background: var(--bg2); border-radius: var(--r-sm);
    cursor: pointer; transition: background var(--tr);
}
.saved-item:active { background: var(--bg); }
.saved-item-addr { font-size: 14px; font-family: 'Courier New', monospace; }
.saved-item-name { font-size: 11px; color: var(--text3); }

/* ===== SCANNER SCREEN ===== */
.scanner-header {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; padding-top: max(6px, var(--safe-t));
    background: rgba(15,23,42,0.92); backdrop-filter: blur(12px); z-index: 20;
}

.stats-bar {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 0;
    background: var(--bg2); border-radius: var(--r-md); padding: 6px 12px;
}
.stat-item { display: flex; flex-direction: column; align-items: center; flex: 1; }
.stat-value { font-size: 20px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-ok .stat-value { color: var(--ok); }
.stat-fail .stat-value { color: var(--err); }
.stat-divider { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }

.header-actions { display: flex; gap: 2px; }

/* Camera viewport */
.scanner-viewport { flex: 1; position: relative; background: #000; overflow: hidden; }

#qr-reader { width: 100%; height: 100%; }
#qr-reader video { width: 100% !important; height: 100% !important; object-fit: cover !important; }
#qr-reader__scan_region { min-height: 100% !important; }
#qr-reader__dashboard, #qr-reader__status_span, #qr-reader__header_message { display: none !important; }

.scan-overlay {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; pointer-events: none;
}

.scan-frame {
    width: 230px; height: 230px; position: relative;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
    border-radius: var(--r-md);
}

/* Corners */
.corner { position: absolute; width: 28px; height: 28px; }
.corner::before, .corner::after { content: ''; position: absolute; background: var(--accent); border-radius: 2px; }
.corner::before { width: 28px; height: 3px; }
.corner::after { width: 3px; height: 28px; }
.tl { top: -1px; left: -1px; }
.tr { top: -1px; right: -1px; }
.tr::before { right: 0; }
.tr::after { right: 0; }
.bl { bottom: -1px; left: -1px; }
.bl::before { bottom: 0; }
.bl::after { bottom: 0; }
.br { bottom: -1px; right: -1px; }
.br::before { right: 0; bottom: 0; }
.br::after { right: 0; bottom: 0; }

/* Scan line animation */
.scan-line {
    position: absolute; left: 4px; right: 4px; height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    border-radius: 1px; opacity: 0.7;
    animation: scanLine 2.5s ease-in-out infinite;
}

/* Fullscreen border flash */
.scan-flash {
    position: absolute; inset: 0; pointer-events: none; z-index: 15;
    border: 4px solid transparent; border-radius: 0;
    opacity: 0; transition: opacity 0.15s ease;
}
.scan-flash.flash-ok { border-color: var(--ok); opacity: 1; }
.scan-flash.flash-err { border-color: var(--err); opacity: 1; }
.scan-flash.flash-dup { border-color: var(--warn); opacity: 1; }

/* Toast */
.scan-toast {
    position: fixed; top: max(60px, calc(var(--safe-t) + 56px));
    left: 50%; transform: translateX(-50%) translateY(-10px);
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--r-lg);
    font-size: 14px; font-weight: 500; backdrop-filter: blur(16px);
    z-index: 30; opacity: 0; transition: all 0.25s ease;
    max-width: calc(100vw - 32px); pointer-events: none;
}
.scan-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.scan-toast.success { background: rgba(34,197,94,0.9); color: #fff; }
.scan-toast.error { background: rgba(239,68,68,0.9); color: #fff; }
.scan-toast.duplicate { background: rgba(245,158,11,0.9); color: #fff; }

/* ===== CODE LIST PANEL ===== */
.code-list-panel {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: var(--bg-card); backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    z-index: 25; display: flex; flex-direction: column;
    max-height: 55vh; transition: max-height 0.35s ease;
}
.code-list-panel.collapsed { max-height: 52px; }
.code-list-panel.expanded { max-height: 70vh; }

.panel-handle {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 16px 6px; cursor: pointer; flex-shrink: 0;
}
.handle-bar { width: 32px; height: 4px; background: var(--text3); border-radius: 2px; margin-bottom: 6px; }
.panel-header-row {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
}
.panel-title { font-size: 13px; color: var(--text2); }
.panel-title strong { color: var(--text); }

.panel-content {
    flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 0 14px;
}

.code-list {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}

.empty-state {
    display: flex; align-items: center; justify-content: center;
    padding: 16px; color: var(--text3); font-size: 13px;
}

.code-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; background: var(--bg2); border-radius: var(--r-sm);
    margin-bottom: 4px; animation: slideIn 0.15s ease-out;
}
.code-status {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.code-status.found { background: var(--ok); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.code-status.not-found { background: var(--err); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.code-status.pending { background: var(--warn); animation: blink 1s infinite; }

.code-text {
    flex: 1; font-size: 12px; font-family: 'Courier New', monospace;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-time { font-size: 10px; color: var(--text3); flex-shrink: 0; }
.btn-remove {
    width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text3); cursor: pointer;
    border-radius: var(--r-sm); flex-shrink: 0;
}
.btn-remove:active { color: var(--err); background: var(--err-bg); }

.panel-actions {
    display: flex; gap: 8px; padding: 10px 0;
    padding-bottom: max(10px, var(--safe-b)); flex-shrink: 0;
}

/* ===== RESULT SCREEN ===== */
.result-container {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 32px; gap: 16px; text-align: center;
}
.result-icon {
    width: 96px; height: 96px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; animation: scaleIn 0.4s ease-out;
}
.result-icon.success { background: var(--ok-bg); color: var(--ok); }
.result-container h2 { font-size: 22px; font-weight: 700; }
.result-container p { color: var(--text2); font-size: 14px; }

.result-stats {
    display: flex; gap: 16px; margin: 8px 0;
}
.result-stat {
    display: flex; flex-direction: column; align-items: center;
    padding: 10px 20px; background: var(--bg2); border-radius: var(--r-md);
}
.result-stat-val { font-size: 24px; font-weight: 700; }
.result-stat-val.ok { color: var(--ok); }
.result-stat-val.fail { color: var(--err); }
.result-stat-label { font-size: 11px; color: var(--text3); margin-top: 2px; }

.result-container .btn-primary { max-width: 300px; margin-top: 8px; }

/* ===== UTILITY ===== */
.hidden { display: none !important; }
.spinner-small {
    width: 14px; height: 14px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes glow { 0%,100% { box-shadow: 0 8px 32px var(--accent-glow); } 50% { box-shadow: 0 8px 48px rgba(59,130,246,0.4); } }

@keyframes scanLine {
    0% { top: 8px; }
    50% { top: calc(100% - 10px); }
    100% { top: 8px; }
}

@media (min-width: 480px) { .scan-frame { width: 260px; height: 260px; } }

/* Install PWA Button */
.btn-install-pwa {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    transition: all 0.2s ease;
}
.btn-install-pwa:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}
.btn-install-pwa.hidden {
    display: none !important;
}

/* ===== SCREEN TOP BAR ===== */
.screen-top-bar {
    position: absolute;
    top: max(12px, var(--safe-t));
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
}
.top-bar-spacer { flex: 1; }

/* ===== RIGHT DRAWER MENU ===== */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 100;
}
.drawer-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.drawer-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 86vw);
    background: #131c31;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 101;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
    padding-top: max(16px, var(--safe-t));
    padding-bottom: max(16px, var(--safe-b));
}
.drawer-right.active {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.drawer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.drawer-logo {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text2);
    cursor: pointer;
    transition: all var(--tr);
}
.drawer-nav-item:hover, .drawer-nav-item:active {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}
.drawer-nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}
.drawer-nav-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.drawer-nav-item.active .drawer-nav-icon {
    background: var(--accent);
    color: white;
}
.drawer-nav-text {
    flex: 1;
    min-width: 0;
}
.drawer-nav-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.drawer-nav-desc {
    font-size: 11px;
    color: var(--text3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}
.drawer-server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.drawer-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text3);
}
.status-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}
.status-tag.connected {
    background: var(--ok-bg);
    color: var(--ok);
}
.status-tag.disconnected {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text3);
}
.drawer-server-name {
    font-size: 12px;
    color: var(--text2);
    word-break: break-all;
}

/* ===== SCREEN 4: RECEIPT (NHẬN HÀNG) ===== */
.receipt-header {
    height: 56px;
    padding: 0 16px;
    padding-top: max(0px, var(--safe-t));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 15;
}
.receipt-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.receipt-scrollable-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: max(32px, var(--safe-b));
}

.receipt-card {
    max-width: 100%;
    padding: 18px;
}

/* Warehouse Selector */
/* Warehouse Pill Selector - Compact & Clean */
.warehouse-pill-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.wh-pill-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    white-space: nowrap;
}
.warehouse-pill-bar {
    display: flex;
    flex: 1;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 3px;
    gap: 4px;
}
.wh-pill-opt {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr);
    white-space: nowrap;
}
.wh-pill-opt:active {
    transform: scale(0.97);
}
.wh-pill-opt.selected {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
@media (max-width: 480px) {
    .warehouse-pill-wrap {
        gap: 6px;
    }
    .wh-pill-opt {
        padding: 6px 3px;
        font-size: 11px;
    }
}

/* 2-Column form row */
.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 14px;
}
.receipt-meta-row {
    margin-top: 0;
}
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    height: 44px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--tr);
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
.po-input {
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Password input wrap with toggle button */
.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.password-input-wrap .form-input {
    padding-right: 38px;
}
.btn-toggle-pass {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    transition: color var(--tr), opacity var(--tr);
}
.btn-toggle-pass:hover, .btn-toggle-pass:active {
    color: var(--text);
}

/* Auth Config Card in Screen Connect */
.auth-config-card {
    margin-top: 14px;
    padding: 0;
    overflow: hidden;
}
.auth-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    user-select: none;
}
.auth-card-desc {
    font-size: 11.5px;
    color: var(--text3);
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Receipt Auth Summary Bar */
.receipt-auth-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding: 7px 12px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.auth-summary-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-summary-label {
    color: var(--text3);
}
.auth-summary-user {
    color: #93c5fd;
    font-weight: 600;
}
.btn-text-sm {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background var(--tr);
}
.btn-text-sm:hover, .btn-text-sm:active {
    background: rgba(59, 130, 246, 0.15);
}

/* Auth Credentials & Permissions Box for UNC */
.auth-box {
    margin-top: 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: all var(--tr);
}
.auth-toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    user-select: none;
}
.auth-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.auth-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.auth-shield-icon {
    font-size: 14px;
}
.auth-toggle-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
}
.auth-status-pill {
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.auth-status-pill.unverified {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text3);
}
.auth-status-pill.checking {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.4);
}
.auth-status-pill.valid {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
}
.auth-status-pill.invalid {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.auth-toggle-arrow {
    font-size: 10px;
    color: var(--text3);
    transition: transform var(--tr);
}
.auth-toggle-arrow.collapsed {
    transform: rotate(-90deg);
}
.auth-fields-row {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}
.auth-fields-row.collapsed {
    display: none;
}

/* Auth Action Buttons */
.auth-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.btn-test-auth {
    flex: 1;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border: none;
    border-radius: var(--r-sm);
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
    transition: all var(--tr);
}
.btn-test-auth:active {
    transform: scale(0.98);
}
.btn-test-auth:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-save-auth {
    height: 38px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr);
}
.btn-save-auth:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}
.btn-save-auth:active {
    transform: scale(0.98);
}

/* Auth Test Result Card */
.auth-test-result {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border);
    transition: all var(--tr);
}
.auth-test-result.success {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.08);
}
.auth-test-result.error {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.08);
}
.result-badges-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}
.perm-pill {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text2);
}
.perm-pill.ok {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}
.perm-pill.fail {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}
.result-detail-text {
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--text2);
}
.auth-test-result.success .result-detail-text {
    color: #86efac;
}
.auth-test-result.error .result-detail-text {
    color: #fca5a5;
}

.spinner-tiny {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.auth-hint {
    font-size: 11px;
    color: var(--text3);
    margin-top: 8px;
    line-height: 1.4;
}

/* Photo Action Buttons */
.photo-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.btn-photo-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    border-radius: var(--r-md);
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all var(--tr);
}
.btn-photo-action:active {
    transform: scale(0.97);
}
.btn-camera {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-gallery {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.photo-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text2);
}
.photo-count-label strong {
    color: var(--accent);
    font-size: 15px;
}
.btn-text-danger {
    background: none;
    border: none;
    color: var(--err);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--r-sm);
}
.btn-text-danger:hover {
    background: var(--err-bg);
}

/* Photo Grid */
.receipt-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    min-height: 110px;
}
.empty-photos-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgba(0, 0, 0, 0.15);
    border: 1.5px dashed var(--border);
    border-radius: var(--r-md);
    text-align: center;
}
.empty-photos-placeholder .empty-icon-svg {
    color: var(--text3);
    margin-bottom: 8px;
    opacity: 0.7;
}
.empty-photos-placeholder .empty-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text2);
}
.empty-photos-placeholder .empty-desc {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
    max-width: 240px;
}

.photo-thumbnail-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--r-md);
    overflow: hidden;
    background: #0f172a;
    border: 1px solid var(--border);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform var(--tr);
}
.photo-thumbnail-card:active {
    transform: scale(0.96);
}
.photo-thumbnail-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.photo-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}
.photo-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 2;
}
.photo-remove-btn:active {
    transform: scale(1.15);
}

/* Upload Button in Receipt Footer */
.receipt-footer {
    margin-top: 4px;
}
.btn-upload {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}
.btn-upload:disabled {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text3);
    box-shadow: none;
    cursor: not-allowed;
}

/* ===== PHOTO LIGHTBOX MODAL (FULLSCREEN PREVIEW) ===== */
.photo-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    z-index: 10050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}
.photo-modal.active {
    opacity: 1;
    visibility: visible;
}
.photo-modal-header {
    height: 52px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: white;
    z-index: 5;
}
.photo-modal-header-left {
    flex: 1;
    min-width: 0;
}
.photo-modal-title {
    font-size: 14.5px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.photo-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.photo-modal-header-actions .btn-icon-sm {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--tr);
}
.photo-modal-header-actions .btn-icon-sm:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
    color: #ffffff;
}
.photo-modal-body {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
    touch-action: pan-y;
}
.photo-modal-img-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-modal-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--r-sm);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.9);
    user-select: none;
    -webkit-user-drag: none;
}
.photo-modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s ease;
}
.photo-modal-nav-btn.prev {
    left: 8px;
}
.photo-modal-nav-btn.next {
    right: 8px;
}
.photo-modal-nav-btn:active {
    transform: translateY(-50%) scale(0.92);
    background: rgba(30, 58, 138, 0.9);
    border-color: #3b82f6;
}
.photo-modal-footer {
    height: 38px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.photo-modal-counter {
    font-size: 12px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

/* ===== INTRANET GUARD (CHẶN NGOÀI INTERNET) ===== */
.guard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}
.guard-overlay.hidden {
    display: none !important;
}
.guard-card {
    max-width: 420px;
    width: 100%;
    text-align: center;
    padding: 32px 24px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(239, 68, 68, 0.15);
    border-radius: var(--r-xl);
}
.guard-icon-wrap {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseErr 2s infinite ease-in-out;
}
@keyframes pulseErr {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 20px 4px rgba(239, 68, 68, 0.25); }
}
.guard-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: #f87171;
    margin-bottom: 10px;
}
.guard-desc {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text2);
    margin-bottom: 20px;
}
.guard-ip-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--r-md);
    margin-bottom: 16px;
    font-size: 13px;
}
.guard-ip-label {
    color: var(--text3);
}
.guard-ip-val {
    font-family: monospace;
    font-weight: 700;
    color: #f1f5f9;
}
.guard-tag-external {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.guard-hint {
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 24px;
}
.btn-guard-recheck {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

/* Client IP Badge styling */
.client-ip-badge.external {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #fca5a5 !important;
}
.client-ip-badge.internal {
    background: rgba(34, 197, 94, 0.12) !important;
    border-color: rgba(34, 197, 94, 0.35) !important;
    color: #86efac !important;
}

/* ===== Drawer User Profile Section ===== */
.drawer-user-section {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.65);
    flex-shrink: 0;
}
.user-card-guest, .user-card-logged {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar-guest {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.user-avatar-logged {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.35);
    flex-shrink: 0;
}
.user-meta {
    flex: 1;
    min-width: 0;
}
.user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-sub, .user-dept {
    font-size: 11px;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-dept {
    color: #38bdf8;
    font-weight: 500;
}
.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: var(--r-sm);
    font-weight: 600;
    flex-shrink: 0;
}
.btn-icon-xs {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text3);
    border-radius: var(--r-sm);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--tr);
    flex-shrink: 0;
}
.btn-icon-xs:hover, .btn-icon-xs:active {
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ===== Login Modal ===== */
.login-card {
    max-width: 380px;
    width: 90%;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--r-lg);
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(24px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.login-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}
.login-logo-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.login-icon-box {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(59, 130, 246, 0.2));
    border: 1px solid rgba(14, 165, 233, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.login-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.login-subtitle {
    font-size: 11.5px;
    color: var(--text3);
    margin: 3px 0 0;
}
.login-form-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.login-error-msg {
    padding: 8px 12px;
    border-radius: var(--r-sm);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 12px;
    line-height: 1.4;
}
.login-notice-msg {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fcd34d;
    font-size: 12.5px;
    line-height: 1.45;
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-block {
    width: 100%;
}

.logo-icon-auth {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6) !important;
    box-shadow: 0 8px 32px rgba(14, 165, 233, 0.4) !important;
}

.status-dot-auth {
    background: #38bdf8 !important;
    box-shadow: 0 0 8px #38bdf8 !important;
}

/* Screen Top Bar on Connect Screen */
.screen-top-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 16px 0;
    width: 100%;
    z-index: 10;
}

/* Remember Password Checkbox */
.remember-group {
    margin-top: -4px;
    margin-bottom: 2px;
}
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text2);
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
    border-radius: 4px;
}
.checkbox-text {
    font-size: 12.5px;
    color: var(--text2);
    transition: color var(--tr);
}
.checkbox-label:hover .checkbox-text {
    color: var(--text);
}

/* ===== Global Modern Toast Pill ===== */
.app-global-toast {
    position: fixed;
    top: max(16px, var(--safe-t));
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    opacity: 0;
    z-index: 10000;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    pointer-events: none;
}
.app-global-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.toast-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(59, 130, 246, 0.25);
    max-width: 90vw;
}
.toast-pill.toast-success {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.3);
}
.toast-pill.toast-error {
    border-color: rgba(239, 68, 68, 0.45);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(239, 68, 68, 0.3);
}
.toast-pill.toast-warning {
    border-color: rgba(245, 158, 11, 0.45);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(245, 158, 11, 0.3);
}
.toast-pill-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    flex-shrink: 0;
}
.toast-pill.toast-success .toast-pill-icon {
    background: #10b981;
}
.toast-pill.toast-error .toast-pill-icon {
    background: #ef4444;
}
.toast-pill.toast-warning .toast-pill-icon {
    background: #f59e0b;
}
.toast-pill-text {
    font-size: 13.5px;
    font-weight: 600;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Global Modern Alert / Confirm Dialog ===== */
.app-dialog-card {
    max-width: 360px;
    width: 90%;
    padding: 26px 20px 22px;
    text-align: center;
    border-radius: var(--r-xl);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.97) 0%, rgba(15, 23, 42, 0.99) 100%);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.75);
    animation: dialogPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dialogPopIn {
    from {
        transform: scale(0.88);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}
.app-dialog-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all var(--tr);
}
.app-dialog-icon.error {
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.45);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.35);
}
.app-dialog-icon.warning {
    background: rgba(245, 158, 11, 0.16);
    border: 1px solid rgba(245, 158, 11, 0.45);
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.35);
}
.app-dialog-icon.success {
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.45);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.35);
}
.app-dialog-icon.info {
    background: rgba(59, 130, 246, 0.16);
    border: 1px solid rgba(59, 130, 246, 0.45);
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.35);
}
.app-dialog-title {
    font-size: 18px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 8px 0;
}
.app-dialog-message {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text2);
    margin-bottom: 24px;
    white-space: pre-line;
    word-break: break-word;
}
.app-dialog-actions {
    display: flex;
    gap: 10px;
}
.btn-dialog {
    flex: 1;
    height: 46px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--tr);
}
.btn-dialog:active {
    transform: scale(0.97);
}

/* ===== Existing Photos Confirmation & Gallery Modals ===== */
.existing-confirm-card {
    max-width: 440px;
    width: 94%;
    padding: 22px 18px 20px;
    border-radius: var(--r-xl);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.99) 100%);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.85);
    animation: dialogPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}
.existing-confirm-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}
.existing-confirm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.16);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #f59e0b;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.existing-confirm-title {
    font-size: 19px;
    font-weight: 800;
    color: #f8fafc;
    margin: 4px 0 0 0;
    line-height: 1.25;
}
.existing-confirm-msg {
    margin-top: 10px;
}
.confirm-info-banner {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.confirm-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.confirm-info-k {
    color: var(--text3);
    font-size: 12.5px;
}
.confirm-info-v {
    color: #f1f5f9;
    font-weight: 600;
}
.po-code-highlight {
    color: #38bdf8;
    font-family: monospace;
    font-size: 14px;
    font-weight: 800;
}
.confirm-info-count {
    display: inline-block;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
}
.confirm-prompt-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
    margin: 12px 0 8px 0;
}

/* Action Cards for Mobile Touch Ergonomics */
.existing-action-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
    width: 100%;
}
.action-card-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 12px 14px;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform var(--tr), background var(--tr), border-color var(--tr);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.action-card-btn:active {
    transform: scale(0.98);
}
.action-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.action-card-text {
    flex: 1;
    min-width: 0;
}
.action-card-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 2px;
}
.action-card-desc {
    font-size: 12px;
    line-height: 1.35;
}
.action-card-arrow {
    font-size: 20px;
    font-weight: 700;
    opacity: 0.7;
    padding-left: 2px;
    flex-shrink: 0;
}

/* Option 1: Primary - Tiếp tục tải lên */
.action-card-primary {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.22) 0%, rgba(30, 58, 138, 0.38) 100%);
    border: 1.5px solid rgba(59, 130, 246, 0.65);
    color: #ffffff;
}
.action-card-primary .action-card-icon {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.action-card-primary .action-card-title {
    color: #ffffff;
}
.action-card-primary .action-card-desc {
    color: #bfdbfe;
}
.action-card-primary .action-card-arrow {
    color: #60a5fa;
}
.action-card-primary:hover,
.action-card-primary:focus {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.32) 0%, rgba(30, 58, 138, 0.52) 100%);
    border-color: #3b82f6;
}

/* Option 2: Info - Xem ảnh hiện có */
.action-card-info {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.18) 0%, rgba(3, 105, 161, 0.32) 100%);
    border: 1.5px solid rgba(56, 189, 248, 0.55);
    color: #ffffff;
}
.action-card-info .action-card-icon {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}
.action-card-info .action-card-title {
    color: #e0f2fe;
}
.action-card-info .action-card-desc {
    color: #bae6fd;
}
.action-card-info .action-card-arrow {
    color: #38bdf8;
}
.action-card-info:hover,
.action-card-info:focus {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.28) 0%, rgba(3, 105, 161, 0.45) 100%);
    border-color: #0ea5e9;
}

/* Option 3: Cancel - Bỏ qua */
.action-card-cancel {
    min-height: 52px;
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #94a3b8;
}
.action-card-cancel .action-card-icon {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
}
.action-card-cancel .action-card-title {
    color: #cbd5e1;
    font-size: 14px;
}
.action-card-cancel .action-card-desc {
    color: #64748b;
    font-size: 11.5px;
}
.action-card-cancel .action-card-arrow {
    color: #64748b;
    font-size: 14px;
}
.action-card-cancel:hover,
.action-card-cancel:focus {
    background: rgba(51, 65, 85, 0.85);
    border-color: rgba(255, 255, 255, 0.22);
}

.existing-gallery-card {
    max-width: 520px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 20px 18px;
    border-radius: var(--r-lg);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.99) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 65px rgba(0, 0, 0, 0.8);
    animation: dialogPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.existing-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.existing-gallery-title {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}
.existing-gallery-subtitle {
    font-size: 12px;
    color: var(--text3);
    margin-top: 2px;
}
.existing-gallery-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    min-height: 140px;
    max-height: 52vh;
}
.existing-photo-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform var(--tr), border-color var(--tr);
}
.existing-photo-thumb:hover {
    border-color: rgba(59, 130, 246, 0.6);
}
.existing-photo-thumb:active {
    transform: scale(0.96);
}
.existing-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.existing-photo-tag {
    position: absolute;
    bottom: 3px;
    left: 3px;
    background: rgba(15, 23, 42, 0.8);
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.existing-photo-zoom-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.existing-gallery-hint {
    font-size: 11.5px;
    color: #38bdf8;
    font-weight: 500;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.existing-gallery-footer {
    display: flex;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}


