/* CSS Variables */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #242444;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 8px;
}

:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.theme-toggle {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 30;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

.theme-toggle-fixed {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: var(--shadow);
    z-index: 1000;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Responsive visibility classes */
.show-desktop {
    display: none;
}

.hide-desktop {
    display: table-cell;
}

.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .show-desktop {
        display: table-cell;
    }

    .hide-desktop {
        display: none;
    }

    .hide-mobile {
        display: table-header-group;
    }
}

/* Helper classes */
.text-muted {
    color: var(--text-muted);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.logo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.header-logo {
    width: 336px;
    height: auto;
    object-fit: contain;
}

/* Logo theme switching - light theme is default */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

:root[data-theme="dark"] .logo-light {
    display: none;
}

:root[data-theme="dark"] .logo-dark {
    display: block;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.total-count {
    margin-top: 0.75rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.total-count strong {
    color: var(--accent-secondary);
    font-size: 1.25rem;
}

/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-bottom: 0;
}

.top-nav .nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.top-nav .nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.top-nav .nav-link.active {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.1);
}

/* Footer Controls */
.footer-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.logout-btn {
    width: auto;
    height: 2.25rem;
    padding: 0 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.875rem;
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    border: 1px solid var(--border-color);
    max-width: 400px;
    width: 100%;
}

.login-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.login-card h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: white;
    color: #333;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.google-btn:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.google-btn svg {
    flex-shrink: 0;
}

/* Packages Section */
.packages-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    width: 100%;
}

.packages-header {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    text-align: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.packages-icon {
    font-size: 1.5rem;
}

.packages-header h2 {
    font-size: 1rem;
    font-weight: 600;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.packages-header .package-count {
    flex: 0 0 auto;
    margin: 0;
}

/* Box Separator Row */
.box-separator {
    background: var(--bg-primary);
}

.box-separator td {
    padding: 0.5rem 0.75rem !important;
    border-bottom: none !important;
    text-align: center;
}

.box-header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.box-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.box-logos {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    vertical-align: middle;
}

.box-company-logo {
    height: 18px;
    width: auto;
    max-width: 30px;
    object-fit: contain;
    opacity: 0.85;
    vertical-align: middle;
    margin-left: 0.5rem;
}

/* Legacy - keep for compatibility */
.box-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.box-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.box-icon {
    font-size: 1.5rem;
}

.box-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.package-count {
    background: var(--accent-gradient);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
}

/* Packages Grid - changed to List view */
.packages-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 100%;
    /* Ensure it fits on mobile */
}

@media (min-width: 640px) {
    .packages-grid {
        max-width: 600px;
        /* Prevent being too wide on desktop for readability */
    }
}

/* Packages Table */
.table-responsive {
    display: block;
}

.packages-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.packages-table th,
.packages-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.packages-table th {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.packages-table td {
    font-size: 0.9rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.packages-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Clickable rows */
.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: rgba(99, 102, 241, 0.1) !important;
}

/* Column Specifics */
.action-cell {
    text-align: center;
    padding-left: 0 !important;
}

.code-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 700;
    color: var(--accent-secondary);
    letter-spacing: 1px;
    font-size: 0.95rem;
}

.sender-cell {
    max-width: 120px;
    /* Reduced to make room for other columns */
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.user-email-micro {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.arrived-cell {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.deadline-cell {
    text-align: left;
}

.deadline-wrapper {
    font-weight: 600;
}

/* Stacked cells */
.stacked-cell {
    vertical-align: middle;
}

.cell-primary {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    min-height: 1.1rem;
}

.cell-secondary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    min-height: 1.1rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-tertiary {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    min-height: 1.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remaining-time {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Deadline urgency colors */
.deadline-ok {
    color: #22c55e !important;
    /* Green: >24h */
}

.deadline-soon {
    color: #eab308 !important;
    /* Yellow: >6h */
}

.deadline-urgent {
    color: #ef4444 !important;
    /* Red: <=6h */
}

.deadline-expired {
    color: #ef4444 !important;
    /* Red: expired */
}

.code-text {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 700;
    font-size: 1rem;
    color: #7c3aed;
    /* Dark purple */
    letter-spacing: 1px;
}

.pickup-btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 auto;
}

.pickup-btn-icon:hover {
    background: var(--success);
    color: white;
    transform: scale(1.1);
}

.pickup-form-inline {
    margin: 0;
}

/* ==========================================
   Modal Styles (Shared between Packages & Archive)
   ========================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-content.modal-compact {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    position: relative;
    padding: 2rem 1.5rem 1.5rem;
    transition: all 0.3s ease;
}

.modal-content.modal-fullscreen {
    max-height: 95vh;
    height: 95vh;
}

.modal-close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

/* Modal Box Header */
.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-box-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Modal Summary */
.modal-summary {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-summary-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-company-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.modal-summary-info {
    flex: 1;
    min-width: 0;
}

.modal-summary-sender {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-summary-user {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-summary-time {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.modal-summary-dates {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* Modal PIN Code Display */
.modal-pin-display {
    text-align: center;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.75rem;
}

.modal-pin-label {
    font-family: 'Inter', sans-serif;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-muted);
}

#modal-pin-code,
#archive-pin-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: #7c3aed;
    letter-spacing: 6px;
}

/* Modal Action Buttons */
.modal-btn-pickup-large {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.modal-btn-pickup-large:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.4);
}

.modal-btn-pickup-large:active {
    transform: translateY(0);
}

.modal-btn-unpickup-large {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.modal-btn-unpickup-large:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.modal-btn-unpickup-large:active {
    transform: translateY(0);
}

.modal-btn-delete-small {
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn-delete-small:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Modal Expandable Section */
.modal-expandable-section {
    margin-top: 0.5rem;
}

.modal-tabs-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.modal-tab-btn {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-tab-btn:hover {
    background: var(--bg-primary);
    border-color: rgba(124, 58, 237, 0.5);
    color: var(--text-primary);
}

.modal-tab-btn.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15) 0%, rgba(124, 58, 237, 0.05) 100%);
    border-color: #7c3aed;
    color: #7c3aed;
}

.expandable-tab-content {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Modal Details Section */
.modal-details-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.modal-detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.modal-detail-value {
    font-size: 0.8rem;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

/* Modal Email Section */
.modal-email-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-height: 300px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.email-loading-indicator {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.email-loading-indicator.hidden {
    display: none;
}

.email-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.email-preview-iframe {
    width: 100%;
    flex: 1;
    border: none;
    background: white;
    min-height: 250px;
}

.loading-spinner-small {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal Fullscreen overrides */
.modal-fullscreen .modal-expandable-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
}

.modal-fullscreen #tabbed-content,
.modal-fullscreen #archive-tabbed-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal-fullscreen #tab-email.active,
.modal-fullscreen #archive-tab-email.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-fullscreen #tab-email.active .modal-email-section,
.modal-fullscreen #archive-tab-email.active .modal-email-section {
    flex: 1;
    min-height: 0;
}

/* End Modal Styles */

/* Mobile pickup cell - clickable entire cell */
.mobile-pickup-cell {
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: var(--radius-sm);
}

.mobile-pickup-cell:hover {
    background-color: rgba(34, 197, 94, 0.25) !important;
}

.mobile-pickup-cell:active {
    background-color: rgba(34, 197, 94, 0.4) !important;
}

/* Mobile email cell - clickable to show email preview */
.mobile-email-cell {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* First email cell gets left rounded corners */
.mobile-email-cell:first-of-type {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* Last email cell (before pickup cell) gets right rounded corners */
.mobile-email-cell:nth-of-type(3) {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Highlight all email cells together when hovering any of them */
.package-row:has(.mobile-email-cell:hover) .mobile-email-cell {
    background-color: rgba(99, 102, 241, 0.25) !important;
}

.package-row:has(.mobile-email-cell:active) .mobile-email-cell {
    background-color: rgba(99, 102, 241, 0.4) !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .packages-grid {
        grid-template-columns: 1fr;
    }

    .box-header {
        flex-wrap: wrap;
    }

    .box-header .package-count {
        margin-left: auto;
    }
}

/* Archive Section */
.archive-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 3rem;
    border: 1px solid var(--border-color);
    width: 100%;
}

.archive-header {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    text-align: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.archive-icon {
    font-size: 1.5rem;
}

.archive-header h2 {
    font-size: 1rem;
    font-weight: 600;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.archive-header .package-count {
    flex: 0 0 auto;
    margin: 0;
}

/* Archive Table */
.archive-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.archive-table th,
.archive-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.archive-table th {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.archive-table td {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.archive-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.archive-table .code-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
    color: var(--accent-secondary);
    letter-spacing: 1px;
}

.company-badge-small {
    background: var(--accent-gradient);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Company Logo Styles */
.company-logo {
    height: 27px;
    width: auto;
    max-width: 52px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.logo-cell {
    width: 55px;
    min-width: 55px;
    max-width: 55px;
    text-align: center;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem !important;
}

@media (min-width: 768px) {
    .company-logo {
        height: 36px;
        max-width: 68px;
    }

    .logo-cell {
        width: 75px;
        min-width: 75px;
        max-width: 75px;
        padding: 0.5rem 0.5rem 0.5rem 1rem !important;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.page-link {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.page-link:hover:not(.disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.page-link.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

/* Undo Button */
.undo-form {
    margin: 0;
    display: inline-flex;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.archive-table td:last-child {
    white-space: nowrap;
}

.undo-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.undo-btn:hover {
    background: #ef4444;
    color: white;
}

.delete-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.25rem;
    vertical-align: middle;
}

.delete-btn:hover {
    background: #ef4444;
    color: white;
}

.retry-btn {
    background: var(--bg-card);
    color: var(--accent-secondary);
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.625rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.25rem;
}

.retry-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Responsive Tables (Mobile) */
@media (max-width: 768px) {

    .packages-table th,
    .packages-table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }

    .archive-table th,
    .archive-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .archive-table .action-buttons {
        flex-direction: column;
        gap: 0.25rem;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Logs Page Styles */
.logs-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    width: 100%;
}

.logs-header {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    text-align: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.logs-icon {
    font-size: 1.5rem;
}

.logs-header h2 {
    font-size: 1rem;
    font-weight: 600;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.logs-header .package-count {
    flex: 0 0 auto;
    margin: 0;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.logs-table th,
.logs-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.logs-table th {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logs-table td {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.logs-table tbody tr.log-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.id-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-muted);
}

.sender-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-badge.success {
    background: var(--success-bg);
    color: var(--success);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.status-badge.duplicate {
    background: var(--warning-bg);
    color: var(--warning);
}

.details-btn {
    background: var(--bg-card);
    color: var(--accent-secondary);
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.details-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.details-row td {
    padding: 0 !important;
    border-bottom: 2px solid var(--accent-primary);
}

.details-content {
    background: var(--bg-card);
    padding: 1.25rem;
    margin: 0;
}

.detail-block {
    margin-bottom: 1rem;
}

.detail-block:last-child {
    margin-bottom: 0;
}

.detail-block h4 {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.json-display {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

.error-block .error-text {
    color: #ef4444;
    font-size: 0.875rem;
}

.nav-link {
    color: var(--accent-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--accent-primary);
}

/* Responsive Logs */
@media (max-width: 768px) {
    .logs-table {
        display: block;
    }

    .logs-table th,
    .logs-table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-text {
    visibility: hidden;
    width: 260px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    text-align: left;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    font-size: 0.75rem;
    line-height: 1.4;
    pointer-events: none;
    white-space: normal;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--bg-card) transparent transparent transparent;
}

.tooltip-text::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: var(--border-color) transparent transparent transparent;
    z-index: -1;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* App Footer */
.app-footer {
    margin-top: auto;
    padding: 1.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.app-footer .version {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 400;
}

/* Modal Overlay Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-compact {
    max-width: 500px;
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: #ef4444;
}

/* Settings Page */
.settings-section {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.settings-group {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    overflow: hidden;
}

.settings-group h3 {
    padding: 1rem 1.5rem;
    font-size: 0.9375rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

.settings-row {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-info {
    flex: 1;
    padding-right: 1rem;
}

.settings-label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.settings-value {
    font-weight: 600;
    color: var(--text-primary);
}

.settings-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

.action-row {
    justify-content: center;
    padding: 1.5rem;
}

.btn-danger-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    transform: translateY(-1px);
}

.btn-secondary-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary-outline:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1.25rem;
    font-size: 0.8125rem;
}


.settings-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

.settings-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    transform: rotate(45deg);
}

/* iOS Style Toggle Switch */
.ios-toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 3.25rem;
    height: 1.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.ios-toggle::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.75rem - 6px);
    height: calc(1.75rem - 6px);
    border-radius: 50%;
    background: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ios-toggle.active {
    background: var(--success);
    border-color: var(--success);
}

.ios-toggle.active::after {
    left: calc(100% - 1.75rem + 4px);
    background: white;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    font-size: 1rem;
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    text-align: center;
    min-width: 280px;
    max-width: 90%;
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

.toast.success {
    background: var(--bg-card);
    border-color: #22c55e;
    color: #22c55e;
    box-shadow: 0 10px 40px rgba(34, 197, 94, 0.2);
}

.toast.error {
    background: var(--bg-card);
    border-color: #ef4444;
    color: #ef4444;
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.2);
}

@media (max-width: 640px) {
    .toast {
        width: 85%;
        max-width: 320px;
        padding: 1.25rem;
    }
}

/* Archive Specific Styles */
.picked-up-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: var(--success);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}

.picked-up-time {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--success);
}