﻿/* ===============================
   ROOT  — inherits site font
=============================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.ma-root {
    background: #f6f7f9;
    padding: 20px;
    max-width: 100%;
    overflow-x: hidden;
}

/* ===============================
   PAGE HEADER
=============================== */
.ma-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 2px solid #e2e5ef;
    flex-wrap: wrap;
    gap: 10px;
}

.ma-page-title {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    margin: 0;
}

.ma-page-desc {
    font-size: 13px;
    color: #777;
    margin-top: 4px;
}

.ma-last-updated {
    font-size: 12px;
    color: #aaa;
}

/* ===============================
   PERIOD BLOCK
=============================== */
.ma-period-block {
    margin-bottom: 40px;
    animation: fadeSlideUp 0.45s ease both;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ma-period-block:nth-child(2) {
    animation-delay: 0.04s;
}

.ma-period-block:nth-child(3) {
    animation-delay: 0.10s;
}

.ma-period-block:nth-child(4) {
    animation-delay: 0.16s;
}

.ma-period-block:nth-child(5) {
    animation-delay: 0.22s;
}

.ma-period-block + .ma-period-block {
    padding-top: 6px;
    border-top: 1.5px dashed #e2e5ef;
}

/* ===============================
   PERIOD HEADING
=============================== */
.ma-period-heading {
    margin-bottom: 16px;
}

.ma-period-label-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.ma-period-emoji {
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(0,0,0,0.10);
}

.ma-period-tag {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.ma-period-title {
    font-size: 20px;
    font-weight: 700;
    color: #111;
}

.ma-period-line {
    height: 3px;
    border-radius: 99px;
    opacity: 0.22;
    width: 100%;
}

/* Per-period accent colours */
.accent-day .ma-period-emoji {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.accent-day .ma-period-tag {
    color: #764ba2;
}

.accent-day .ma-period-line {
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.accent-week .ma-period-emoji {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

.accent-week .ma-period-tag {
    color: #0a7c6a;
}

.accent-week .ma-period-line {
    background: linear-gradient(90deg, #11998e, #38ef7d);
}

.accent-month .ma-period-emoji {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.accent-month .ma-period-tag {
    color: #c03060;
}

.accent-month .ma-period-line {
    background: linear-gradient(90deg, #f093fb, #f5576c);
}

.accent-year .ma-period-emoji {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.accent-year .ma-period-tag {
    color: #0076c6;
}

.accent-year .ma-period-line {
    background: linear-gradient(90deg, #4facfe, #00f2fe);
}

/* ===============================
   TWO-COLUMN LAYOUT
=============================== */
.ma-two-col {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 14px;
    margin-bottom: 14px;
    align-items: start;
}

/* ===============================
   CARDS
=============================== */
.ma-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

    .ma-card:hover {
        box-shadow: 0 6px 24px rgba(0,0,0,0.09);
        transform: translateY(-2px);
    }

.ma-card-head {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.ma-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.ic-green {
    background: #e6f9f0;
}

.ic-orange {
    background: #fff3e0;
}

.ic-purple {
    background: #f3e8ff;
}

.ma-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111;
}

/* ===============================
   BEST SELLER ROWS
=============================== */
.ma-seller-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8f9fb;
    margin-bottom: 10px;
    transition: background 0.15s ease;
    animation: fadeSlideUp 0.35s ease both;
}

    .ma-seller-row:last-child {
        margin-bottom: 0;
    }

    .ma-seller-row:hover {
        background: #eef0f7;
    }

.ma-rank {
    font-size: 12px;
    font-weight: 700;
    min-width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rk-gold {
    background: #fef9c3;
    color: #92400e;
    border: 1.5px solid #fde68a;
}

.rk-silver {
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
}

.rk-bronze {
    background: #fff7ed;
    color: #9a3412;
    border: 1.5px solid #fed7aa;
}

.rk-plain {
    background: #f4f4f6;
    color: #888;
    border: 1.5px solid #e8e8ec;
}

.ma-seller-body {
    flex: 1;
    min-width: 0;
}

.ma-seller-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.ma-seller-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ma-seller-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ma-seller-rev {
    font-size: 14px;
    font-weight: 700;
    color: #111;
}

.ma-seller-units {
    font-size: 11px;
    color: #999;
    font-weight: 500;
    margin-bottom: 7px;
}

/* ===============================
   NEEDS ATTENTION ROWS
=============================== */
.ma-att-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8f9fb;
    margin-bottom: 10px;
    transition: background 0.15s ease;
    animation: fadeSlideUp 0.35s ease both;
}

    .ma-att-row:last-child {
        margin-bottom: 0;
    }

    .ma-att-row:hover {
        background: #eef0f7;
    }

.ma-att-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.dot-red {
    background: #ef4444;
    box-shadow: 0 0 0 3px #fee2e2;
}

.dot-amber {
    background: #f59e0b;
    box-shadow: 0 0 0 3px #fef3c7;
}

.dot-green {
    background: #10b981;
    box-shadow: 0 0 0 3px #d1fae5;
}

.ma-att-body {
    flex: 1;
    min-width: 0;
}

.ma-att-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 7px;
}

.ma-att-name {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ma-att-label {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}

    .ma-att-label.urgent {
        background: #fdecea;
        color: #d32f2f;
    }

    .ma-att-label.warn {
        background: #fff3cd;
        color: #856404;
    }

    .ma-att-label.ok {
        background: #d4edda;
        color: #155724;
    }

/* ===============================
   PROGRESS BARS
=============================== */
.ma-bar-track {
    height: 5px;
    background: #eee;
    border-radius: 99px;
    overflow: hidden;
}

.ma-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.65s cubic-bezier(0.25, 1, 0.5, 1);
}

.green-fill {
    background: linear-gradient(90deg, #10b981, #059669);
}

.urgent-fill {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

.warn-fill {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.ok-fill {
    background: linear-gradient(90deg, #34d399, #10b981);
}

/* ===============================
   BADGES
=============================== */
.ma-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

.badge-up {
    background: #d4edda;
    color: #155724;
}

.badge-down {
    background: #fdecea;
    color: #d32f2f;
}

/* ===============================
   CATEGORIES CARD
=============================== */
.ma-cat-body {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 28px;
    align-items: center;
}

.ma-donut-wrap {
    position: relative;
    width: 200px;
    height: 200px;
    flex-shrink: 0;
}

    .ma-donut-wrap canvas {
        width: 100% !important;
        height: 100% !important;
    }

.ma-donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.ma-donut-total {
    font-size: 20px;
    font-weight: 700;
    color: #111;
    line-height: 1.1;
}

.ma-donut-lbl {
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 3px;
}

/* Category list rows */
.ma-cat-row {
    padding: 12px 14px;
    background: #f8f9fb;
    border-radius: 10px;
    margin-bottom: 10px;
    transition: background 0.15s;
    animation: fadeSlideUp 0.35s ease both;
}

    .ma-cat-row:last-child {
        margin-bottom: 0;
    }

    .ma-cat-row:hover {
        background: #eef0f7;
    }

.ma-cat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ma-cat-left {
    display: flex;
    align-items: center;
    gap: 9px;
}

.ma-cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ma-cat-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
}

.ma-cat-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ma-cat-val {
    font-size: 14px;
    font-weight: 700;
    color: #111;
}

.ma-cat-pct {
    font-size: 12px;
    color: #999;
    min-width: 36px;
    text-align: right;
}

/* ===============================
   EMPTY STATE
=============================== */
.ma-empty {
    text-align: center;
    color: #aaa;
    font-size: 13px;
    padding: 26px 0;
}

/* ===============================
   SKELETON LOADER
=============================== */
.ma-skel-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ma-skel {
    height: 60px;
    border-radius: 10px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ===============================
   RESPONSIVE
=============================== */
@media (max-width: 1024px) {
    .ma-two-col {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .ma-root {
        padding: 10px;
    }

    .ma-two-col {
        grid-template-columns: 1fr;
    }

    .ma-cat-body {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .ma-cat-list {
        width: 100%;
    }

    .ma-page-title {
        font-size: 18px;
    }

    .ma-period-title {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .ma-card {
        padding: 14px;
    }

    .ma-seller-top, .ma-att-top {
        flex-wrap: wrap;
    }
}


/* ================================================
   ITEM ANALYTICS MODAL
================================================ */

body.ia-modal-open {
    overflow: hidden;
}

.ia-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,15,30,0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ia-modal {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 600px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.18);
    animation: iaModalIn 0.22s cubic-bezier(0.34,1.4,0.64,1) both;
}

@keyframes iaModalIn {
    from {
        opacity: 0;
        transform: scale(0.93) translateY(12px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ---- Header ---- */
.ia-modal-header {
    display: flex;
    align-items: center; /* FIX: was flex-start, caused × to sit at top */
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1.5px solid #f0f0f4;
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: 18px 18px 0 0;
    z-index: 1;
}

.ia-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.ia-modal-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: linear-gradient(135deg,#667eea,#764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(102,126,234,0.28);
}

.ia-modal-cat {
    font-size: 12px;
    color: #888;
    margin-bottom: 3px;
}

.ia-modal-title {
    font-size: 19px;
    font-weight: 700;
    color: #111;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* FIX: close button — flex-shrink:0 keeps it from being squished,
   align-self:center ensures it stays vertically centred */
.ia-modal-close {
    background: #f4f4f6;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    flex-shrink: 0;
    align-self: center;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

    .ia-modal-close:hover {
        background: #e8e8ec;
        color: #111;
    }

/* ---- Stat strip ---- */
.ia-modal-stat-strip {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 12px;
    padding: 20px 24px 0;
}

.ia-modal-stat {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    animation: fadeSlideUp 0.35s ease both;
    transition: transform 0.18s, box-shadow 0.18s;
}

    .ia-modal-stat:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.11);
    }

.ia-modal-stat-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
}

.ia-modal-stat-icon {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

/* FIX: single-line label — smaller font, tighter tracking, no wrap */
.ia-modal-stat-label {
    font-size: 9.5px;
    font-weight: 700;
    color: rgba(255,255,255,0.93);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ia-modal-stat-body {
    padding: 10px 12px 12px;
    background: #fff;
}

.ia-modal-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
}

.ia-modal-stat-sub {
    font-size: 11px;
    color: #999;
    margin-top: 3px;
}

/* ---- Divider ---- */
.ia-modal-divider {
    height: 1.5px;
    background: #f0f0f4;
    margin: 20px 24px 0;
}

/* ---- Snapshot list ---- */
.ia-snap-list {
    padding: 6px 24px 24px;
}

.ia-snap-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 13px 0;
    animation: fadeSlideUp 0.35s ease both;
}

.ia-snap-icon {
    width: 38px;
    height: 38px;
    background: #f6f7f9;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ia-snap-divider {
    height: 1px;
    background: #f4f4f6;
    margin-left: 52px;
}

.ia-snap-info {
    flex: 1;
    min-width: 0;
}

.ia-snap-label {
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}

.ia-snap-value {
    font-size: 15px;
    font-weight: 700;
    color: #111;
}

.ia-snap-hint {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
}

.stat-trend-up {
    color: #059669;
}

.stat-trend-down {
    color: #dc2626;
}

.ia-cat-pill {
    display: inline-block;
    background: #ede9fe;
    color: #5b21b6;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 20px;
}

.ma-item-link {
    cursor: pointer;
}

.ma-seller-row.ma-item-link:hover,
.ma-att-row.ma-item-link:hover {
    background: #eef0f7;
}

@media (max-width: 600px) {
    .ia-modal-stat-strip {
        grid-template-columns: 1fr 1fr;
    }

    .ia-modal-title {
        font-size: 17px;
    }
}

@media (max-width: 400px) {
    .ia-modal-header {
        padding: 14px 16px;
    }

    .ia-snap-list {
        padding: 6px 16px 20px;
    }
}
