:root {
    --bg-primary: #f5f3f0;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9f8f6;
    --bg-card: #fefdf9;
    --text-primary: #2d2d2d;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent-primary: #6b8062;
    --accent-secondary: #7a9072;
    --accent-hover: #5a6e52;
    --accent-dark: #4a6048;
    --border-color: #e8e5e0;
    --border-light: #f0ede8;
    --shadow-sm: 0 2px 8px rgba(107, 128, 98, 0.06);
    --shadow-md: 0 4px 12px rgba(107, 128, 98, 0.08);
    --shadow-lg: 0 8px 24px rgba(107, 128, 98, 0.10);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

[data-theme="dark"] {
    --bg-primary: #1a1f1a;
    --bg-secondary: #212721;
    --bg-tertiary: #2a312a;
    --bg-card: #252b25;
    --text-primary: #e8f0e5;
    --text-secondary: #b8c5b3;
    --text-muted: #8a9587;
    --accent-primary: #7a9072;
    --accent-secondary: #8fa988;
    --accent-hover: #91a689;
    --accent-dark: #a4b89d;
    --border-color: #3a4238;
    --border-light: #2f352f;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 24px;
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0 24px;
}

/* Company Switcher (in header-actions) */
.company-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.company-switcher select {
    padding: 4px 4px 4px 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    min-width: 120px;
}

.company-manage-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.company-manage-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Company Manager Modal */
.company-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.company-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
}

.company-modal {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.company-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.company-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.company-modal-body {
    padding: 20px 24px 24px;
}

.company-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.company-add-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.company-add-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.company-list {
    max-height: 300px;
    overflow-y: auto;
}

.company-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    transition: all 0.2s ease;
}

.company-list-item.active {
    background: rgba(107, 128, 98, 0.1);
    border-color: var(--accent-primary);
}

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

.company-list-info strong {
    color: var(--text-primary);
    font-size: 14px;
}

.company-active-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-primary);
    background: rgba(107, 128, 98, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.company-list-actions {
    display: flex;
    gap: 6px;
}

.company-delete-btn {
    font-size: 12px;
    padding: 4px 10px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.company-delete-btn:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

/* Header Styles */
.app-header {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 24px 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.app-header .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

/* Settings/Dashboard link styled as pill (matches company-switcher) */
.header-settings-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.header-settings-link:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.header-settings-link svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.tab.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Toolbar Icon Buttons */
.toolbar-icons {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.toolbar-icon-btn:hover {
    color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.toolbar-icon-btn.active {
    color: var(--accent-primary);
}

/* Filter Dropdown */
.filter-wrapper {
    position: relative;
}

.filter-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 220px;
}

.filter-dropdown.open {
    display: block;
}

.filter-dropdown-row {
    margin-bottom: 12px;
}

.filter-dropdown-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.filter-dropdown-row input[type="date"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
}

.filter-dropdown-row input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.filter-dropdown-actions {
    display: flex;
    gap: 8px;
}

.filter-dropdown-actions .btn-small {
    flex: 1;
    text-align: center;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

/* Stats Grid */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    padding: 16px 24px;
    border-radius: var(--radius-md);
    color: white;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 1;
    min-width: 180px;
    text-align: center;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.stat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-row .stat-value {
    margin-top: 0;
}

.stat-desc {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(107, 128, 98, 0.1);
}

.btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

/* Table */
.table-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin: 0;
    width: 100%;
}

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

td, th {
    word-wrap: break-word;
    max-width: 150px;
}

td:first-child, th:first-child {
    max-width: 120px;
}

td:last-child, th:last-child {
    max-width: none;
    white-space: nowrap;
}

thead {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-bottom: 2px solid var(--border-color);
}

thead th {
    color: white !important;
}

th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Specific column widths */
th:nth-child(1), td:nth-child(1) { width: 10%; } /* Gift Card ID */
th:nth-child(2), td:nth-child(2) { width: 11%; } /* Purchaser */
th:nth-child(3), td:nth-child(3) { width: 13%; } /* Email */
th:nth-child(4), td:nth-child(4) { width: 9%; } /* Phone */
th:nth-child(5), td:nth-child(5) { width: 11%; } /* Recipient */
th:nth-child(6), td:nth-child(6) { width: 7%; } /* Balance */
th:nth-child(7), td:nth-child(7) { width: 7%; } /* Status */
th:nth-child(8), td:nth-child(8) { width: 9%; } /* Purchase Date */
th:nth-child(9), td:nth-child(9) { width: 8%; } /* Location */
th:nth-child(10), td:nth-child(10) { width: 8%; } /* Email Status */
th:nth-child(11), td:nth-child(11) { width: 7%; text-align: center; } /* Actions - icon only */

/* Better text wrapping for specific columns */
td:nth-child(3), td:nth-child(4) {
    word-break: break-all;
    font-size: 12px;
}

td:nth-child(5) {
    word-wrap: break-word;
}

tbody tr {
    transition: background 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

[data-theme="dark"] .status-active {
    background: #1e3a23;
    color: #a4d4ae;
}

.status-redeemed {
    background: #fff3cd;
    color: #856404;
}

[data-theme="dark"] .status-redeemed {
    background: #3a3420;
    color: #d4c896;
}

.status-pending {
    background: #e2e3e5;
    color: #383d41;
}

[data-theme="dark"] .status-pending {
    background: #2d2d2d;
    color: #adb5bd;
}

/* Buttons */
.btn-resync {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 4px;
}

.btn-resync:hover {
    background: #e7f5ff;
    color: #0077cc;
    border-color: #0077cc;
    transform: scale(1.1);
}

.btn-resync:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

[data-theme="dark"] .btn-resync:hover {
    background: rgba(0, 119, 204, 0.1);
}

.btn-delete {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: #fee;
    color: #dc3545;
    border-color: #dc3545;
    transform: scale(1.1);
}

[data-theme="dark"] .btn-delete:hover {
    background: rgba(220, 53, 69, 0.1);
}

.actions-cell {
    white-space: nowrap;
    text-align: center;
}

.btn-edit {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 4px;
}

.btn-edit:hover {
    background: #fff3cd;
    color: #856404;
    border-color: #856404;
    transform: scale(1.1);
}

[data-theme="dark"] .btn-edit:hover {
    background: rgba(133, 100, 4, 0.1);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--accent-primary);
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Settings sections */
.settings-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.settings-section h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-light);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(107, 128, 98, 0.1);
}

.help-text {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 5px;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.status-message {
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: none;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

[data-theme="dark"] .status-message.success {
    background: #1e3a23;
    color: #a4d4ae;
    border: 1px solid #2d5a35;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

[data-theme="dark"] .status-message.error {
    background: #3a2023;
    color: #d4a4ae;
    border: 1px solid #5a2d35;
}

/* Section (for emails page) */
.section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.section h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-light);
}

/* Sync Popup */
.sync-popup {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 320px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    display: none;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    border: 1px solid var(--border-color);
}

@keyframes slideIn {
    from {
        transform: translateX(450px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sync-popup.active {
    display: block;
}

/* Email Processor Popup - position to the left and up from sync popup */
#emailPopup {
    right: 360px;
    bottom: 80px;
}

.email-popup.active {
    display: block;
}

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

.sync-popup-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.sync-popup-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sync-stop-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #dc3545;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sync-stop-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #c82333;
}

.sync-popup-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.sync-popup-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sync-trigger {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent-primary);
}

.sync-status {
    display: none;
}

.sync-status.active {
    display: block;
}

.sync-log {
    max-height: 150px;
    overflow-y: auto;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-top: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    font-size: 12px;
    line-height: 1.4;
}

.log-entry {
    margin-bottom: 4px;
    color: var(--text-primary);
}

.log-error {
    color: #dc3545;
}

[data-theme="dark"] .log-error {
    color: #ff6b6b;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal-overlay .modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.modal-body {
    margin-bottom: 20px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Activity Logs */
.logs-container {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.log-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    transition: background 0.2s ease;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item:hover {
    background: var(--bg-tertiary);
}

.log-timestamp {
    color: var(--text-muted);
    font-size: 13px;
    margin-right: 10px;
}

.log-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    margin-right: 10px;
}

.log-type-action {
    background: #d1ecf1;
    color: #0c5460;
}

[data-theme="dark"] .log-type-action {
    background: #1e2a3a;
    color: #a4c4d4;
}

.log-type-sync {
    background: #d4edda;
    color: #155724;
}

[data-theme="dark"] .log-type-sync {
    background: #1e3a23;
    color: #a4d4ae;
}

.log-type-delete {
    background: #f8d7da;
    color: #721c24;
}

[data-theme="dark"] .log-type-delete {
    background: #3a2023;
    color: #d4a4ae;
}

.log-type-error {
    background: #f8d7da;
    color: #721c24;
}

[data-theme="dark"] .log-type-error {
    background: #3a2023;
    color: #d4a4ae;
}

.log-message {
    color: var(--text-primary);
}

.clear-logs-btn {
    margin-bottom: 15px;
}

/* Buttons for modals */
.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn.syncing {
    background: #ffc107;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .tabs {
        flex-direction: column;
    }

    .controls {
        flex-direction: column;
    }

    .search-box {
        min-width: 100%;
    }
}

/* Pulse animation for sync indicator */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Auto-Sync Countdown Widget */
.sync-countdown-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transition: all 0.3s ease;
}

.sync-countdown-widget:hover {
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent-primary);
}

.sync-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

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

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal[style*="display: none"] {
    display: none !important;
}

.modal[style*="display: flex"] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Specific override for Add Gift Card Modal */
#addGiftCardModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10000 !important;
    padding: 20px !important;
}

#addGiftCardModal[style*="display: none"] {
    display: none !important;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 1200px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    margin: 0 auto;
    position: relative;
}

#addGiftCardModal .modal-content {
    max-width: 1200px !important;
    width: 90% !important;
    margin: 0 auto !important;
}

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

.modal-header h2 {
    color: var(--text-primary);
    font-size: 20px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

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

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 30px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(107, 128, 98, 0.1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px;
}

th.sortable:hover {
    background: var(--bg-tertiary);
}

th.sortable .sort-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
}

th.sortable .sort-icon::after {
    content: '\25B4\25BE';
    letter-spacing: -3px;
}

th.sortable.sort-asc .sort-icon::after {
    content: '\25B2';
    color: var(--accent-primary);
}

th.sortable.sort-desc .sort-icon::after {
    content: '\25BC';
    color: var(--accent-primary);
}

/* Toggle Switch for Reviewed */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border-radius: 20px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* Needs Review Button - filled when inactive, outline when active */
#needsReviewBtn.active {
    background: transparent !important;
    color: var(--accent-primary) !important;
    border: 2px solid var(--accent-primary) !important;
}

#needsReviewBtn.active:hover {
    background: rgba(107, 128, 98, 0.1) !important;
}
