:root {
    --bg-dark: #0f1117;
    --bg-card: #1c1e26;
    --bg-card-hover: #262933;
    --mint-accent: #3ecfb2;
    --mint-hover: #32b59b;
    --text-main: #f0f0f0;
    --text-muted: #a0a4b8;
    --danger: #ff5c5c;
    --danger-bg: rgba(255, 92, 92, 0.1);
    --success-bg: rgba(62, 207, 178, 0.1);
    --border-color: #333745;
    --header-h: 72px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    /* Prevent body scroll, so that panels scroll independently */
    display: flex;
    flex-direction: column;
    height: 100vh;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
}

/* Header */
header {
    height: var(--header-h);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.logo-fallback {
    height: 40px;
    width: 40px;
    background: var(--mint-accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--bg-dark);
    font-size: 20px;
}

.app-title {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ink-brand-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: -2px;
}

.ink-logo-text {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    padding-right: 2px;
    text-shadow: 0 0 10px rgba(62, 207, 178, 0.6), 0 0 20px rgba(62, 207, 178, 0.4), 0 0 5px rgba(62, 207, 178, 0.8);
}

.tagline {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.header-center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    flex: 2;
}

.nav-tab {
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: none;
    /* Hidden until login */
    align-items: center;
    gap: 8px;
}

.nav-tab:hover {
    color: var(--text-main);
}

.nav-tab.active {
    color: var(--mint-accent);
    border-bottom-color: var(--mint-accent);
}

.progress-container {
    width: 100%;
    max-width: 450px;
    display: none;
}

.progress-text {
    font-size: 13px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-bar-bg {
    height: 6px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--mint-accent);
    width: 0%;
    transition: width 0.4s ease-out;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 1;
    min-width: 250px;
}

#scanner-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--mint-accent);
    opacity: 0;
    transition: opacity 0.3s;
}

.dot {
    height: 8px;
    width: 8px;
    background-color: var(--mint-accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--mint-accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

button {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background-color: var(--bg-card-hover);
    transform: translateY(-1px);
}

button.primary {
    background-color: var(--mint-accent);
    color: var(--bg-dark);
    border-color: var(--mint-accent);
}

button.primary:hover {
    background-color: var(--mint-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-adaptive {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}

.btn-danger:hover {
    background-color: #ff4444;
    border-color: #ff4444;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
}

/* Scan input buffer display */
#scan-buffer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border: 1px solid var(--mint-accent);
    color: var(--mint-accent);
    padding: 10px 20px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 20px;
    font-weight: bold;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Views */
.view {
    flex: 1;
    display: none;
    overflow: hidden;
    position: relative;
}

.view.active {
    display: flex;
}

/* Page 0: Login */
#page-login {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.login-card {
    background-color: var(--bg-card);
    border: 1px solid rgba(62, 207, 178, 0.4);
    padding: 40px 30px;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: breathing 4.5s ease-in-out infinite;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card h2 {
    margin-bottom: 24px;
    font-size: 24px;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--mint-accent);
    box-shadow: 0 0 0 2px rgba(62, 207, 178, 0.2);
}

#login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: -8px;
    margin-bottom: 16px;
    display: none;
    text-align: left;
}

/* Page 1: Landing */
#page-landing {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 80px 40px;
    overflow-y: auto;
}

.landing-card {
    /* background-color: var(--bg-card); */
    /* border: 1px dashed var(--border-color); */
    padding: 60px 40px;
    border-radius: 16px;
    max-width: 540px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(62, 207, 178, 0.4);
    background-color: var(--bg-card);
    animation: breathing 4.5s ease-in-out infinite;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.landing-card.drag-active {
    background: var(--bg-card-hover);
    border-style: dashed;
    border-color: var(--mint-accent);
    animation: none;
    box-shadow: 0 0 20px rgba(62, 207, 178, 0.5);
}

@keyframes breathing {

    0%,
    100% {
        box-shadow: 0 0 0px rgba(62, 207, 178, 0);
        border-color: rgba(62, 207, 178, 0);
    }

    50% {
        box-shadow: 0 0 20px rgba(62, 207, 178, 0.4), 0 0 40px rgba(62, 207, 178, 0.1);
        border-color: rgba(62, 207, 178, 0.7);
    }
}

.landing-icon {
    width: 64px;
    height: 64px;
    background-color: rgba(62, 207, 178, 0.1);
    color: var(--mint-accent);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.landing-icon svg {
    width: 32px;
    height: 32px;
}

.landing-card h2 {
    margin-bottom: 16px;
    font-size: 26px;
}

.landing-card p {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 15px;
    line-height: 1.6;
}

#file-input {
    display: none;
}

.upload-btn {
    font-size: 16px;
    padding: 14px 32px;
    border-radius: 8px;
    width: 100%;
    max-width: 250px;
}

/* Page 2: Dashboard */
#page-dashboard {
    flex-direction: row;
    padding: 24px;
    gap: 24px;
}

.panel {
    flex: 1;
    background-color: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.015);
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    background-color: var(--bg-dark);
    color: var(--mint-accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.branch-badge-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 16px;
    align-self: center;
    line-height: 1;
}

.location-pin-icon {
    width: 13px;
    height: 15px;
    color: var(--mint-accent);
    fill: var(--mint-accent);
    flex-shrink: 0;
}

.branch-name-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(62, 207, 178, 0.6),
        0 0 20px rgba(62, 207, 178, 0.4),
        0 0 5px rgba(62, 207, 178, 0.8);
}

.search-box {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.2);
}

.search-input {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 14px;
    padding-right: 40px;
    /* Space for clear button */
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--mint-accent);
    box-shadow: 0 0 0 2px rgba(62, 207, 178, 0.2);
}

.search-input::placeholder {
    color: #666a7b;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.btn-clear-search {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    transition: all 0.2s;
    /* Override default button styles */
    margin: 0;
}

.btn-clear-search:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    transform: translateY(-50%);
}

.btn-clear-search.visible {
    display: flex;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    /* Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #3f4455 transparent;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 15px;
    gap: 16px;
    text-align: center;
    opacity: 0.7;
    padding: 20px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--mint-accent);
    opacity: 0.5;
    margin-bottom: 8px;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-thumb {
    background-color: #3f4455;
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

/* Package Cards */
.pkg-card {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.pkg-card-top {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.pkg-chevron {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    transition: transform 0.3s, background 0.2s;
}

.pkg-card.expanded .pkg-chevron {
    transform: rotate(180deg);
    background: rgba(62, 207, 178, 0.15);
    color: var(--mint-accent);
}

.pkg-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.pkg-card.expanded .pkg-detail {
    max-height: 600px;
}

.pkg-detail-inner {
    padding: 0 16px 16px 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 0;
    padding-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-field.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.detail-value {
    font-size: 13px;
    color: var(--text-main);
    word-break: break-word;
}

.pkg-card:hover {
    border-color: #444a5e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pkg-card.hidden {
    display: none !important;
}

/* Transition animations */
.pkg-card.animating-out {
    transform: scale(0.95);
    opacity: 0;
    pointer-events: none;
}

.pkg-card.animating-in {
    animation: slideInFade 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes slideInFade {
    from {
        transform: translateX(20px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

.pkg-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    flex-shrink: 0;
}

.pkg-card.status-imported {
    border-left: 3px solid var(--mint-accent);
}

.pkg-card.status-imported .pkg-icon {
    background-color: var(--success-bg);
    color: var(--mint-accent);
}

.pkg-details {
    flex: 1;
    min-width: 0;
}

.pkg-item {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.pkg-id {
    font-size: 13px;
    color: var(--text-muted);
    font-family: monospace;
    background: rgba(255, 255, 255, 0.03);
    padding: 3px 6px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.05);

    /* Improved Affordance */
    position: relative;
    padding-right: 26px;
    /* Space for icon */
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    cursor: copy;
}

.pkg-id:hover,
.pkg-id:focus-visible {
    background: rgba(62, 207, 178, 0.12);
    border-color: rgba(62, 207, 178, 0.3);
    color: var(--text-main);
    outline: none;
    box-shadow: 0 0 0 2px rgba(62, 207, 178, 0.2);
}

.pkg-id::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    /* Feather Icon: copy (color: #3ecfb2) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233ecfb2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.pkg-id:hover::after,
.pkg-id:focus-visible::after {
    opacity: 1;
}

.pkg-time {
    color: var(--text-muted);
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
}

/* Empty States */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: toastEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards, toastExit 0.4s 3s forwards;
    background-color: #2a2e3b;
    border: 1px solid var(--border-color);
    pointer-events: auto;
}

.toast.success {
    border-left: 4px solid var(--mint-accent);
}

.toast.success .toast-icon {
    color: var(--mint-accent);
}

.toast.error {
    border-left: 4px solid var(--danger);
    animation: toastEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    cursor: pointer;
}

.toast.error .toast-icon {
    color: var(--danger);
}

@keyframes toastEnter {
    from {
        transform: translateY(100%) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastExit {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    to {
        transform: translateY(100%) scale(0.9);
        opacity: 1;
    }
}

/* Custom Confirm & Prompt Modals */
#confirm-modal,
#prompt-modal,
#inactivity-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.85);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

#confirm-modal.visible,
#prompt-modal.visible,
#inactivity-modal.visible {
    display: flex;
    animation: fadeIn 0.3s forwards;
}

.confirm-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.confirm-box h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--text-main);
}

.confirm-box p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-actions button {
    min-width: 100px;
    padding: 10px 20px;
}

/* Celebration Screen */
#success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.95);
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    backdrop-filter: blur(8px);
}

#success-overlay.visible {
    display: flex;
    animation: fadeIn 0.6s forwards;
}

.success-circle {
    width: 120px;
    height: 120px;
    background: var(--success-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    box-shadow: 0 0 40px rgba(62, 207, 178, 0.2);
}

.success-circle svg {
    width: 60px;
    height: 60px;
    color: var(--mint-accent);
}

#success-overlay h2 {
    font-size: 36px;
    margin-bottom: 16px;
    color: var(--text-main);
}

#success-overlay p {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.overlay-actions {
    display: flex;
    gap: 16px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Page 3: Branches */
#page-branches {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Changed from center to prevent scroll cut-off */
    padding: 40px;
    overflow-y: auto;
}

#page-branches>div {
    margin: auto 0;
}

.branch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 900px;
    margin-top: 32px;
}

.branch-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 32px 24px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.branch-card:hover {
    border-color: var(--mint-accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(62, 207, 178, 0.15);
}

.branch-icon {
    width: 48px;
    height: 48px;
    background-color: rgba(62, 207, 178, 0.1);
    color: var(--mint-accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.branch-card h3 {
    font-size: 18px;
    color: var(--text-main);
    margin: 0;
}

/* StashBox Specific Styles */
.stashbox-view {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 60px 40px;
    overflow-y: auto;
}

.stashbox-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stashbox-header {
    text-align: center;
    margin-bottom: 48px;
}

.stashbox-title {
    font-size: 32px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stashbox-subtitle {
    color: var(--text-muted);
    font-size: 16px;
}

.stashbox-grid {
    margin-top: 0 !important;
    justify-content: center;
}

.premium-card {
    background: linear-gradient(145deg, var(--bg-card) 0%, #22252e 100%);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 40px 30px !important;
}

.premium-card:hover {
    border-color: var(--mint-accent);
    box-shadow: 0 15px 40px rgba(62, 207, 178, 0.15);
}

.locked-card {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
    background: rgba(28, 30, 38, 0.5);
}

.card-description {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 12px;
    line-height: 1.5;
}

.stashbox-buffer {
    flex: 1.5;
    /* This pushes the grid and header up */
    min-height: 100px;
}

@media (max-width: 600px) {
    .stashbox-view {
        padding: 40px 20px;
    }

    .stashbox-title {
        font-size: 28px;
    }

    .stashbox-header {
        margin-bottom: 32px;
    }

    .premium-card {
        padding: 30px 20px !important;
    }

    .stashbox-buffer {
        flex: 0.5;
    }
}

@media (max-width: 900px) {
    body {
        padding-bottom: 70px;
        /* Space for bottom nav */
        overflow-y: auto;
        /* Allow body scroll on mobile if panels stack */
    }

    #page-dashboard {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
        overflow-y: visible;
        /* Let body handle scrolling */
    }

    .panel {
        overflow: visible;
        /* Let body handle scrolling */
        min-height: 300px;
    }

    .header-center {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        background-color: var(--bg-card);
        border-top: 1px solid var(--border-color);
        padding: 8px 16px;
        z-index: 2000;
        gap: 0;
        justify-content: space-around;
        height: 70px;
    }

    .nav-tab {
        flex-direction: column;
        gap: 4px;
        font-size: 11px;
        padding: 4px;
        flex: 1;
        justify-content: center;
        border-bottom: none;
    }

    .nav-tab.active {
        color: var(--mint-accent);
    }

    .nav-tab svg {
        width: 20px;
        height: 20px;
    }

    /* Hide progress bar on small screens if needed */
}

@media (max-width: 1200px) and (min-width: 901px) {
    .header-center {
        gap: 12px;
    }

    .nav-tab {
        padding: 8px 12px;
    }

    .header-right {
        gap: 8px;
    }

    .header-right button .btn-text {
        display: none;
    }

    #location-name {
        margin-right: 8px;
        padding: 6px 10px;
    }
}

@media (max-width: 600px) {
    header {
        padding: 0 12px;
    }

    .header-left {
        width: auto;
        gap: 6px;
    }

    .logo {
        height: 28px;
        width: 28px;
    }

    .logo-fallback {
        height: 28px;
        width: 28px;
        font-size: 14px;
    }

    .app-title {
        font-size: 16px;
    }

    .header-right {
        gap: 6px;
        min-width: unset;
    }

    .header-right button {
        padding: 6px;
    }

    .header-right button .btn-text {
        display: none;
    }

    #location-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 4px 6px;
        margin-right: 4px;
        font-size: 10px;
    }

    #scanner-status {
        font-size: 10px;
        gap: 4px;
    }

    .login-card {
        padding: 32px 20px;
    }

    .landing-card {
        padding: 32px 20px;
    }

    .branch-grid {
        grid-template-columns: 1fr;
    }

    #page-branches {
        padding: 20px 16px;
    }

    .branch-card {
        padding: 20px 16px;
    }

    #page-login,
    #page-landing {
        padding: 20px 16px;
    }

    #page-archive,
    #page-archive-detail {
        padding: 20px 12px !important;
    }

    #page-archive h2,
    #page-archive-detail h2 {
        font-size: 20px !important;
    }

    #btn-clear-archive .btn-text {
        display: none;
    }

    #btn-clear-archive {
        padding: 8px;
    }

    .confirm-box {
        padding: 24px 16px;
        width: 95%;
    }

    #success-overlay h2 {
        font-size: 24px;
    }

    #success-overlay p {
        font-size: 15px;
    }

    .success-circle {
        width: 80px;
        height: 80px;
    }

    .success-circle svg {
        width: 40px;
        height: 40px;
    }

    .btn-adaptive {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
    opacity: 0.8;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Staged Manifest Cards */
.staged-manifest-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.staged-manifest-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.staged-manifest-name {
    font-weight: 600;
    color: var(--mint-accent);
    font-size: 15px;
    white-space: normal;
    word-break: break-all;
}

.staged-manifest-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.staged-manifest-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.btn-delete-manifest {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--danger);
    transition: background 0.15s;
    margin-left: 8px;
    border: none;
    padding: 0;
    background: transparent;
}

.btn-delete-manifest:hover {
    background: var(--danger-bg);
}

@media (max-width: 600px) {
    .staged-manifest-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .staged-manifest-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Scoped overrides for Deal Spy control panel */
#page-deal-spy .deal-spy-control-panel {
    padding: 12px 16px;
    width: 100%;
    max-width: 100%;
    margin-bottom: 24px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;

    /* New Overrides to match Deal Cards exactly */
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    /* retain the animation per previous request, if landing-card provides it */
}

#page-deal-spy .deal-spy-control-panel label {
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}

#page-deal-spy .deal-spy-control-panel select.form-control {
    flex: 1;
    margin: 0 16px;
    width: auto;
    min-width: 200px;
    height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    /* match UI border radius */
}

#page-deal-spy .deal-spy-control-panel button {
    width: auto;
    height: 38px;
    padding: 0 16px;
    margin: 0;
    white-space: nowrap;
}

#page-deal-spy #deal-spy-search {
    display: none;
    width: 100%;
    height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 16px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

#page-deal-spy #deal-spy-search::placeholder {
    color: var(--text-muted);
}

#page-deal-spy #deal-spy-search:focus {
    border-color: var(--mint-accent);
}

@media (max-width: 600px) {
    #page-deal-spy .deal-spy-control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    #page-deal-spy .deal-spy-control-panel button,
    #page-deal-spy .deal-spy-control-panel select.form-control {
        width: 100%;
        margin: 0;
    }
}

/* Pulse EKG Animation */
#page-deal-spy #pulse-monitor-canvas {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.35;
    -webkit-mask-image: linear-gradient(to right, black calc(50% - 70px), transparent calc(50% - 35px), transparent calc(50% + 35px), black calc(50% + 70px));
    mask-image: linear-gradient(to right, black calc(50% - 70px), transparent calc(50% - 35px), transparent calc(50% + 35px), black calc(50% + 70px));
}

/* --- Deal Spy Overrides --- */
#page-deal-spy {
    padding: 60px 40px;
}

#page-deal-spy .deal-spy-hero {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
    padding-top: 24px;
    padding-bottom: 32px;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

#page-deal-spy .deal-spy-hero .ink-logo-text {
    font-size: 32px;
}

#page-deal-spy #pulse-monitor-canvas {
    z-index: 1;
}

#page-deal-spy .ink-brand-wrapper {
    position: relative;
    z-index: 2;
}

#page-deal-spy .deal-spy-control-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#page-deal-spy .deal-spy-view-toggles {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
}

#page-deal-spy .view-toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#page-deal-spy .view-toggle-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
}

#page-deal-spy .view-toggle-btn.active {
    background: rgba(62, 207, 178, 0.1);
    color: var(--mint-accent);
    border-color: var(--mint-accent);
}


#page-deal-spy .deal-spy-control-panel label {
    display: none;
}

#page-deal-spy .deal-spy-dropdown-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

#page-deal-spy .deal-spy-dropdown-wrapper .chevron-icon {
    position: absolute;
    right: 16px;
    pointer-events: none;
    color: var(--text-muted);
}

#page-deal-spy .deal-spy-dropdown {
    width: 100%;
    margin: 0;
    transition: all 0.2s;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 40px 12px 16px;
    border-radius: 8px;
    font-size: 15px;
    appearance: none;
}

#page-deal-spy .deal-spy-dropdown:focus {
    border-color: var(--mint-accent);
    box-shadow: 0 0 0 2px rgba(62, 207, 178, 0.2);
    outline: none;
}

#page-deal-spy .deal-spy-refresh-btn {
    margin: 0;
    padding: 12px 24px;
    font-weight: 600;
    transition: filter 0.2s, background-color 0.2s;
}

#page-deal-spy .deal-spy-refresh-btn:hover {
    filter: brightness(1.1);
}

/* Search Wrapper */
#page-deal-spy .deal-spy-search-wrapper {
    margin-bottom: 32px;
    position: relative;
    width: 100%;
}

#page-deal-spy .deal-spy-search-wrapper .search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border-radius: 8px;
    padding-right: 48px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    transition: all 0.2s;
}

#page-deal-spy .deal-spy-search-wrapper .search-input:focus {
    border-color: var(--mint-accent);
    box-shadow: 0 0 0 2px rgba(62, 207, 178, 0.2);
    outline: none;
}

/* Deal Group Cards */
#page-deal-spy .deal-spy-card.group-card {
    padding: 16px 20px;
    border-radius: 12px;
    background-color: var(--bg-card);
    margin-bottom: 0;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s, border-color 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 16px;
}

#page-deal-spy .deal-spy-card.group-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border-color: rgba(62, 207, 178, 0.4);
    background-color: var(--bg-card-hover);
}

#page-deal-spy .deal-spy-card.group-card.expanded {
    border-color: var(--mint-accent);
}

/* Products inside deals */
#page-deal-spy .deal-spy-products {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 16px;
    padding-right: 16px;
    margin-top: 8px;
    padding-bottom: 12px;
}

#page-deal-spy .deal-spy-products .prod-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 16px;
}

#page-deal-spy .deal-spy-products .prod-row:last-child {
    border-bottom: none;
}

#page-deal-spy .shop-btn {
    border-radius: 20px !important;
    padding: 6px 16px !important;
    background: rgba(255, 255, 255, 0.05);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s, background 0.2s;
    display: inline-block;
}

#page-deal-spy .shop-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--mint-accent);
}

/* Loading States */
#page-deal-spy .deal-spy-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

#page-deal-spy .deal-spy-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(62, 207, 178, 0.2);
    border-top-color: var(--mint-accent);
    border-radius: 50%;
    animation: deal-spy-spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes deal-spy-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
#page-deal-spy .deal-spy-empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

/* Warning Banner */
#page-deal-spy .deal-spy-warning {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}