/* Modern Apple-like Tech Aesthetic Variables */
:root {
    --bg-base: #fbfbfd;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent-blue: #0071e3;
    --accent-green: #34c759;
    --accent-red: #ff3b30;

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);

    --transition-smooth: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Dark Mode Query Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-base: #000000;
        --text-primary: #f5f5f7;
        --text-secondary: #86868b;
        --accent-blue: #2997ff;

        --glass-bg: rgba(28, 28, 30, 0.6);
        --glass-border: rgba(255, 255, 255, 0.08);
        --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }

    body {
        background: radial-gradient(circle at top right, #1d1d27, #000000) !important;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Soft mesh gradient background for premium feel */
    background: radial-gradient(circle at top right, #e2eafc, #fbfbfd 60%);
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    margin-bottom: 2.5rem;
    color: var(--text-primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    background: rgba(134, 134, 139, 0.1);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--text-primary);
    color: var(--bg-base);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Page title row: title + cutoff badge inline */
.page-title-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title-row h1 {
    margin: 0;
}

/* Data cutoff date badge */
.data-cutoff-badge {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(0, 113, 227, 0.06);
    border: 1px solid rgba(0, 113, 227, 0.12);
    border-radius: 20px;
    padding: 4px 14px;
    white-space: nowrap;
    line-height: 1.4;
}

/* ============== Info Icon Tooltip ============== */
.info-icon {
    --info-icon-size: 18px;
    --info-icon-glyph-size: 0.68rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: var(--info-icon-size);
    height: var(--info-icon-size);
    font-size: 0;
    line-height: 1;
    font-style: normal;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: rgba(29, 29, 31, 0.54);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(242, 244, 248, 0.84) 100%);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 50%;
    cursor: pointer;
    vertical-align: middle;
    top: -3px;
    margin-left: 5px;
    flex-shrink: 0;
    overflow: hidden;
    isolation: isolate;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.96),
        0 1px 2px rgba(15, 23, 42, 0.08),
        0 6px 16px rgba(15, 23, 42, 0.08);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    transition:
        color 0.2s ease,
        background 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.22s ease,
        transform 0.22s ease;
}

.info-icon::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background:
        radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.28) 42%, transparent 68%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    pointer-events: none;
    z-index: 0;
}

.info-icon::after {
    content: "i";
    position: relative;
    z-index: 1;
    font-size: var(--info-icon-glyph-size);
    line-height: 1;
    transform: translateY(-0.4px);
}

.info-icon:hover,
.info-icon:focus-visible,
.info-icon.is-open {
    color: var(--accent-blue);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(236, 245, 255, 0.92) 100%);
    border-color: rgba(0, 113, 227, 0.2);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.98),
        0 2px 6px rgba(0, 113, 227, 0.08),
        0 10px 24px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.info-icon:focus-visible {
    outline: 2px solid rgba(0, 113, 227, 0.22);
    outline-offset: 2px;
}

.info-icon:active {
    transform: scale(0.96);
}

/* Smaller variant for table headers */
.info-icon-sm {
    --info-icon-size: 16px;
    --info-icon-glyph-size: 0.6rem;
}

/* Shared tooltip popup rendered by JS */
.info-tooltip-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: max-content;
    max-width: min(320px, calc(100vw - 24px));
    background: rgba(255, 255, 255, 0.76);
    color: rgba(29, 29, 31, 0.9);
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1.55;
    letter-spacing: -0.01em;
    padding: 11px 14px;
    border-radius: 16px;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
    z-index: 1000;
    box-shadow:
        0 18px 44px rgba(15, 23, 42, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.76);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.64);
}

.info-tooltip-popup.visible {
    opacity: 1;
    visibility: visible;
}

.info-tooltip-popup::after {
    content: "";
    position: absolute;
    left: var(--tooltip-arrow-left, 50%);
    bottom: -6px;
    transform: translateX(-50%);
    border-style: solid;
    border-width: 6px 6px 0 6px;
    border-color: rgba(255, 255, 255, 0.76) transparent transparent transparent;
}

.info-tooltip-popup.below {
    transform: translateY(4px);
}

.info-tooltip-popup.below::after {
    top: -6px;
    bottom: auto;
    border-width: 0 6px 6px 6px;
    border-color: transparent transparent rgba(255, 255, 255, 0.76) transparent;
}

@media (prefers-color-scheme: dark) {
    .data-cutoff-badge {
        background: rgba(0, 113, 227, 0.1);
        border-color: rgba(0, 113, 227, 0.2);
    }

    .info-icon {
        color: rgba(245, 245, 247, 0.64);
        background: linear-gradient(180deg, rgba(68, 68, 72, 0.8) 0%, rgba(38, 38, 42, 0.84) 100%);
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.12),
            0 1px 2px rgba(0, 0, 0, 0.18),
            0 8px 20px rgba(0, 0, 0, 0.24);
    }

    .info-icon::before {
        background:
            radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08) 40%, transparent 68%),
            linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
    }

    .info-icon:hover,
    .info-icon:focus-visible,
    .info-icon.is-open {
        color: #eaf4ff;
        background: linear-gradient(180deg, rgba(62, 104, 148, 0.88) 0%, rgba(27, 60, 98, 0.84) 100%);
        border-color: rgba(41, 151, 255, 0.4);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.18),
            0 4px 10px rgba(41, 151, 255, 0.16),
            0 12px 28px rgba(0, 0, 0, 0.3);
    }

    .info-tooltip-popup {
        background: rgba(36, 36, 39, 0.82);
        color: rgba(245, 245, 247, 0.94);
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow:
            0 18px 44px rgba(0, 0, 0, 0.34),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }

    .info-tooltip-popup::after {
        border-top-color: rgba(36, 36, 39, 0.82);
    }

    .info-tooltip-popup.below::after {
        border-bottom-color: rgba(36, 36, 39, 0.82);
    }
}


.top-nav h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-refresh {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: var(--transition-smooth);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-refresh:hover {
    background: var(--text-primary);
    color: var(--bg-base);
    transform: scale(1.05);
}

.user-profile img {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    transition: var(--transition-smooth);
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

/* Chart header with optional controls */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1rem;
}

.chart-header h2 {
    margin: 0;
}

/* Apple-style Segmented Control */
.segment-control {
    display: inline-flex;
    background: rgba(134, 134, 139, 0.08);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.segment-btn {
    padding: 5px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

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

.segment-btn.active {
    background: var(--text-primary);
    color: var(--bg-base);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Dashboard Grid */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-card h3 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.metric-card .value {
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -1px;
}

.trend {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend.positive {
    color: var(--accent-green);
}

.trend.negative {
    color: var(--accent-red);
}

.trend.neutral {
    color: var(--text-secondary);
}

/* Chart Area */
.charts-row {
    display: grid;
    grid-template-columns: 1fr;
}

.chart-container {
    padding: 2rem;
}

.chart-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
}

/* Animations loading state */
.loading {
    opacity: 0.5;
    pointer-events: none;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.5;
    }
}

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

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

.metrics-row .metric-card {
    animation: fadeInUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    opacity: 0;
}

.metrics-row .metric-card:nth-child(1) {
    animation-delay: 0.1s;
}

.metrics-row .metric-card:nth-child(2) {
    animation-delay: 0.2s;
}

.metrics-row .metric-card:nth-child(3) {
    animation-delay: 0.3s;
}

.metrics-row .metric-card:nth-child(4) {
    animation-delay: 0.4s;
}

.chart-container {
    animation: fadeInUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    animation-delay: 0.5s;
    opacity: 0;
}

/* Tables for Data Grids */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

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

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: rgba(134, 134, 139, 0.05);
    /* very subtle hover */
}

.text-center {
    text-align: center !important;
}

/* Rank Badge styling for Repurchase / Matrix Tag */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge.primary {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent-blue);
}

.badge.danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--accent-red);
}

.badge.success {
    background: rgba(52, 199, 89, 0.1);
    color: var(--accent-green);
}

.badge.warning {
    background: rgba(255, 149, 0, 0.1);
    color: #ff9500;
}

/* ============== Ops Date Picker ============== */
.ops-date-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(0, 113, 227, 0.04);
    border: 1px solid rgba(0, 113, 227, 0.1);
}

.ops-date-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.ops-date-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ops-date-input {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    padding: 6px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: var(--glass-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.2s, transform 0.2s;
    min-width: 180px;
}

.ops-date-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.ops-date-trigger {
    border: 1px solid var(--glass-border);
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.ops-date-trigger:hover {
    transform: translateY(-1px);
}

.ops-date-trigger-icon {
    font-size: 0.84rem;
    color: var(--accent-blue);
    letter-spacing: -0.02em;
}

.ops-date-display {
    min-width: 92px;
}

.ops-date-display.is-placeholder {
    color: var(--text-secondary);
}

.ops-date-clear {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 2px;
}

.ops-date-clear:hover {
    color: var(--accent-red);
}

.ops-date-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.ops-date-modal[hidden] {
    display: none;
}

.ops-date-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 20px;
}

.ops-date-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ops-date-dialog {
    position: relative;
    width: min(420px, calc(100vw - 24px));
    padding: 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.ops-date-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.ops-date-dialog-header h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.ops-date-dialog-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-secondary);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.ops-date-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.ops-date-picker-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.ops-date-picker-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    font: inherit;
    outline: none;
}

.ops-date-picker-field select:focus {
    border-color: rgba(0, 113, 227, 0.4);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.ops-date-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.ops-date-dialog-btn {
    border: none;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.ops-date-dialog-btn.secondary {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
}

.ops-date-dialog-btn.primary {
    background: var(--accent-blue);
    color: #fff;
}

@media (prefers-color-scheme: dark) {
    .ops-date-row {
        background: rgba(0, 113, 227, 0.06);
        border-color: rgba(0, 113, 227, 0.15);
    }

    .ops-date-input {
        background: rgba(28, 28, 30, 0.6);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .ops-date-dialog {
        background: rgba(28, 28, 30, 0.86);
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: 0 24px 56px rgba(0, 0, 0, 0.4);
    }

    .ops-date-dialog-close,
    .ops-date-dialog-btn.secondary {
        background: rgba(255, 255, 255, 0.08);
        color: var(--text-primary);
    }

    .ops-date-picker-field select {
        background: rgba(44, 44, 46, 0.92);
        border-color: rgba(255, 255, 255, 0.12);
    }
}

/* ============== Ops Management Page ============== */
.ops-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

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

@media (max-width: 800px) {
    .ops-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ops-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 2rem 1.25rem;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(240, 240, 245, 0.7) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    color: var(--text-primary);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 8px 24px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.ops-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.ops-btn:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.08),
        0 20px 40px rgba(0, 113, 227, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ops-btn:active {
    transform: translateY(-2px) scale(0.98);
    transition-duration: 0.1s;
}

.ops-btn-accent {
    background: linear-gradient(135deg, rgba(0, 113, 227, 0.08) 0%, rgba(88, 86, 214, 0.06) 100%);
    box-shadow:
        0 2px 8px rgba(0, 113, 227, 0.08),
        0 8px 24px rgba(0, 113, 227, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.ops-btn-accent:hover {
    box-shadow:
        0 8px 20px rgba(0, 113, 227, 0.15),
        0 20px 40px rgba(88, 86, 214, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

@media (prefers-color-scheme: dark) {
    .ops-btn {
        background: linear-gradient(135deg, rgba(44, 44, 46, 0.8) 0%, rgba(28, 28, 30, 0.7) 100%);
        box-shadow:
            0 2px 8px rgba(0, 0, 0, 0.2),
            0 8px 24px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }

    .ops-btn::before {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
    }

    .ops-btn:hover {
        box-shadow:
            0 8px 20px rgba(0, 0, 0, 0.3),
            0 20px 40px rgba(0, 113, 227, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }

    .ops-btn-accent {
        background: linear-gradient(135deg, rgba(0, 113, 227, 0.15) 0%, rgba(88, 86, 214, 0.1) 100%);
    }
}

.ops-icon {
    font-size: 2.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.ops-label {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.ops-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Running state - pulsing glow */
.ops-running {
    pointer-events: none;
    animation: opsPulse 1.5s ease-in-out infinite;
}

@keyframes opsPulse {

    0%,
    100% {
        opacity: 0.6;
        box-shadow: 0 0 0 0 rgba(0, 113, 227, 0);
    }

    50% {
        opacity: 1;
        box-shadow: 0 0 30px rgba(0, 113, 227, 0.2);
    }
}

/* Success state - green glow */
.ops-done {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.1) 0%, rgba(48, 209, 88, 0.06) 100%) !important;
    box-shadow: 0 0 0 2px rgba(52, 199, 89, 0.4), 0 8px 24px rgba(52, 199, 89, 0.15) !important;
}

/* Error state - red glow */
.ops-error {
    background: linear-gradient(135deg, rgba(255, 59, 48, 0.1) 0%, rgba(255, 69, 58, 0.06) 100%) !important;
    box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.4), 0 8px 24px rgba(255, 59, 48, 0.15) !important;
}

/* Log panel — terminal aesthetic */
.ops-log-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.ops-log-container h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.ops-log {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Menlo', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 2;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    min-height: 80px;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

@media (prefers-color-scheme: dark) {
    .ops-log {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.06);
    }
}

.ops-log .log-entry {
    display: block;
    padding: 4px 0;
    border-bottom: 1px solid rgba(134, 134, 139, 0.08);
    animation: logFadeIn 0.3s ease;
}

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

.ops-log .log-entry .log-time {
    color: var(--text-secondary);
    opacity: 0.6;
    margin-right: 8px;
}

.ops-log .log-entry.log-success {
    color: var(--accent-green);
}

.ops-log .log-entry.log-error {
    color: var(--accent-red);
}

.ops-log .log-entry.log-pending {
    color: var(--accent-blue);
}

@keyframes logFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

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

/* ============================================
   Hamburger Menu Button (hidden on desktop)
   ============================================ */
.hamburger {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    padding: 8px;
    border: none;
    border-radius: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

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

    /* Show hamburger */
    .hamburger {
        display: flex;
    }

    /* Sidebar: off-screen by default, slide in */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        width: 240px;
        height: 100vh;
        z-index: 100;
        transition: left 0.35s cubic-bezier(0.25, 1, 0.5, 1);
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    /* Main content takes full width */
    .main-content {
        padding: 1rem;
        padding-top: 64px;
        /* space for hamburger */
    }

    /* Page title row */
    .top-nav {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 8px 12px;
    }

    .top-nav h1 {
        font-size: 1.5rem;
    }

    .page-title-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px;
        min-width: 0;
    }

    .data-cutoff-badge {
        font-size: 0.7rem;
    }

    .header-actions {
        justify-self: end;
        align-self: start;
        gap: 8px;
    }

    .btn-refresh {
        padding: 7px 12px;
        font-size: 0.78rem;
    }

    .user-profile img {
        width: 32px;
        height: 32px;
    }

    /* Metrics: 2 columns on phone */
    .metrics-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .metric-card .value {
        font-size: 1.5rem;
    }

    /* Charts: smaller height */
    .chart-container {
        padding: 1rem;
    }

    #trend-chart {
        height: 260px !important;
    }

    #tag-chart {
        height: 260px !important;
    }

    /* Chart header: stack on mobile */
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-header h2 {
        font-size: 1rem;
        margin-bottom: 0;
    }

    /* Glass card: less padding, less border-radius */
    .glass-card {
        border-radius: 16px;
        padding: 1rem;
    }

    .glass-card:hover {
        transform: none;
        /* disable lift on mobile */
    }

    /* Tables: fit in 430px (iPhone 15 Pro Max) */
    .data-table th,
    .data-table td {
        padding: 8px 5px;
        font-size: 0.72rem;
        white-space: normal;
        /* allow wrapping */
        word-break: break-all;
    }

    .data-table th {
        font-size: 0.68rem;
        letter-spacing: 0;
    }

    /* Keep table header info icons visible on mobile, but compact */
    .data-table .info-icon-sm {
        display: inline-flex;
        --info-icon-size: 14px;
        --info-icon-glyph-size: 0.54rem;
        margin-left: 3px;
        top: -1px;
    }

    /* Product name: truncate with ellipsis */
    .data-table td:first-child {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Numeric columns: right-align, no-wrap */
    .data-table td:nth-child(n+2) {
        white-space: nowrap;
        text-align: right;
    }

    .data-table th:nth-child(n+2) {
        text-align: right;
    }

    /* Badge: smaller on mobile */
    .badge {
        padding: 2px 6px;
        font-size: 0.65rem;
        white-space: nowrap;
    }

    /* RFM cards: 2 columns on mobile */
    #rfm-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    #rfm-cards .metric-card {
        min-width: unset !important;
    }

    #rfm-cards .metric-card .value {
        font-size: 1.3rem;
    }

    #rfm-cards .metric-card h3 {
        font-size: 0.78rem;
    }

    /* Ops grid: 2 columns on iPhone-sized screens */
    .ops-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .ops-date-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .ops-date-field {
        width: 100%;
    }

    .ops-date-input {
        width: 100%;
        min-width: 0;
    }

    .ops-date-dialog {
        width: min(420px, calc(100vw - 20px));
        padding: 16px;
        border-radius: 18px;
    }

    .ops-date-picker-grid {
        grid-template-columns: 1fr;
    }

    .ops-date-dialog-actions {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .ops-date-dialog-btn {
        flex: 1 1 calc(50% - 5px);
    }

    .ops-log {
        font-size: 0.75rem;
        line-height: 1.8;
        padding: 1rem;
    }

    /* Segment control */
    .segment-btn {
        padding: 4px 12px;
        font-size: 0.75rem;
    }

    /* Info icon: keep compact sizing on mobile */
    .info-icon {
        --info-icon-size: 18px;
        --info-icon-glyph-size: 0.68rem;
        margin-left: 5px;
    }

    .info-tooltip-popup {
        max-width: calc(100vw - 24px);
        font-size: 0.8rem;
        line-height: 1.55;
    }
}

/* Tablet (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

    .main-content {
        padding: 1.5rem 2rem;
    }

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

    .ops-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
