:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1e2d4a;
    --text-primary: #e8e8f0;
    --text-secondary: #9a9ab0;
    --text-muted: #6a6a80;
    --border: #2a2a45;
    --accent: #E31837;
    /* MiniCubez Red */
    --accent-glow: rgba(227, 24, 55, 0.3);

    /* Status colors */
    --status-received: #636e72;
    --status-received-bg: rgba(99, 110, 114, 0.15);
    --status-design: #E31837;
    /* Red for Design phase focus */
    --status-design-bg: rgba(227, 24, 55, 0.15);
    --status-production: #e17055;
    --status-production-bg: rgba(225, 112, 85, 0.15);
    --status-waiting: #fdcb6e;
    --status-waiting-bg: rgba(253, 203, 110, 0.15);
    --status-ontheway: #0984e3;
    /* Blue/Teal */
    --status-ontheway-bg: rgba(9, 132, 227, 0.15);
    --status-delivered: #00b894;
    /* Green (Keep same as old shipped) */
    --status-delivered-bg: rgba(0, 184, 148, 0.15);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 48px;
}

/* ==================== Header ==================== */

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

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    height: 48px;
    width: auto;
    filter: drop-shadow(0 0 12px rgba(227, 24, 55, 0.4));
}

.logo h1 {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    padding-left: 12px;
    border-left: 2px solid var(--border);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sync-info {
    font-size: 12px;
    color: var(--text-muted);
}

.sync-info strong {
    color: var(--text-secondary);
}

.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-sync {
    background: var(--accent);
    color: white;
    padding: 8px 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-sync:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-sync.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

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

    to {
        transform: rotate(360deg);
    }
}

/* ==================== Install Banner ==================== */

.install-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(225, 112, 85, 0.12);
    border: 1px solid rgba(225, 112, 85, 0.3);
    border-radius: var(--radius);
    margin-bottom: 24px;
    color: #e17055;
    font-weight: 500;
    font-size: 14px;
}

.install-icon {
    font-size: 20px;
}

.btn-install {
    margin-left: auto;
    background: #e17055;
    color: white;
    padding: 8px 20px;
    font-size: 13px;
    text-decoration: none;
    display: inline-block;
}

.btn-install:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(225, 112, 85, 0.3);
}

/* ==================== Status Cards ==================== */

.status-cards {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.status-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.status-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0;
    transition: var(--transition);
}

.status-card:hover,
.status-card.active {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.status-card.active::before {
    opacity: 1;
}

.card-all::before {
    background: var(--accent);
}

.card-received::before {
    background: var(--status-received);
}

.card-design::before {
    background: var(--status-design);
}

.card-production::before {
    background: var(--status-production);
}

.card-waiting::before {
    background: var(--status-waiting);
}

.card-ontheway::before {
    background: var(--status-ontheway);
}

.card-delivered::before {
    background: var(--status-delivered);
}

.card-all.active {
    border-color: var(--accent);
}

.card-received.active {
    border-color: var(--status-received);
}

.card-design.active {
    border-color: var(--status-design);
}

.card-production.active {
    border-color: var(--status-production);
}

.card-waiting.active {
    border-color: var(--status-waiting);
}

.card-ontheway.active {
    border-color: var(--status-ontheway);
}

.card-delivered.active {
    border-color: var(--status-delivered);
}

.card-count {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
}

.card-all .card-count {
    color: var(--accent);
}

.card-received .card-count {
    color: var(--status-received);
}

.card-design .card-count {
    color: var(--status-design);
}

.card-production .card-count {
    color: var(--status-production);
}

.card-waiting .card-count {
    color: var(--status-waiting);
}

.card-ontheway .card-count {
    color: var(--status-ontheway);
}

.card-delivered .card-count {
    color: var(--status-delivered);
}

.card-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* ==================== Search ==================== */

.search-bar {
    margin-bottom: 24px;
}

.search-bar input {
    width: 100%;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ==================== Orders Table ==================== */

.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead {
    background: var(--bg-card);
}

.orders-table th {
    padding: 14px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.orders-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.order-row {
    transition: var(--transition);
}

.order-row:hover {
    background: var(--bg-hover);
}

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

.order-number {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent);
}

.order-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.customer-name {
    font-weight: 600;
    font-size: 14px;
}

.customer-email {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==================== Status Badges ==================== */

.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

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

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

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

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

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

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

/* ==================== Design Preview ==================== */

.design-preview {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.design-preview:hover {
    opacity: 0.85;
}

.design-preview img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 2px solid var(--border);
    transition: var(--transition);
}

.design-preview:hover img {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.preview-label {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.no-design,
.no-tracking {
    color: var(--text-muted);
    font-size: 14px;
}

/* ==================== Tracking ==================== */

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

.tracking-status {
    font-weight: 600;
    font-size: 13px;
}

.tracking-status.tracking-2 {
    color: var(--status-production);
}

/* In Transit */
.tracking-status.tracking-3 {
    color: var(--status-design);
}

/* Out for delivery */
.tracking-status.tracking-4 {
    color: var(--status-shipped);
}

/* Delivered */
.tracking-status.tracking-5 {
    color: var(--status-waiting);
}

/* New String-based Statuses (Shopify Native) */
.tracking-status.tracking-in_transit {
    color: var(--status-ontheway);
}

.tracking-status.tracking-out_for_delivery {
    color: var(--status-ontheway);
}

.tracking-status.tracking-delivered {
    color: var(--status-delivered);
}

.tracking-status.tracking-failure,
.tracking-status.tracking-attempted_delivery {
    color: var(--status-waiting);
}

/* Exception */

.tracking-last-event {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracking-number {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.order-total {
    font-weight: 600;
    font-size: 14px;
}

/* ==================== Empty State ==================== */

.empty-state {
    text-align: center;
    padding: 60px 20px !important;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ==================== Image Modal ==================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 600px;
    max-height: 80vh;
    overflow: auto;
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 16px;
    color: var(--accent);
}

.modal-content img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

/* ==================== Responsive ==================== */

@media (max-width: 1024px) {
    .status-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .status-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .orders-table {
        font-size: 13px;
    }

    .orders-table th:nth-child(5),
    .orders-table td:nth-child(5),
    .orders-table th:nth-child(6),
    .orders-table td:nth-child(6) {
        display: none;
    }
}

@media (max-width: 480px) {
    .status-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .status-card {
        padding: 14px 10px;
    }

    .card-count {
        font-size: 22px;
    }
}

.est-date {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
    letter-spacing: 0.2px;
    white-space: nowrap;
}