/* ==========================================================================
   EHour Insights — standalone modern theme (no Bootstrap / site.css)
   ========================================================================== */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f1f3f8;
    --surface-3: #e7eaf2;
    --border: #e3e6ee;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #8a94a8;
    --accent: #4f46e5;
    --accent-soft: #eef0ff;
    --accent-text: #ffffff;
    --good: #10b981;
    --good-soft: #d1fae5;
    --warn: #f59e0b;
    --warn-soft: #fef3c7;
    --bad: #e11d48;
    --bad-soft: #ffe4e6;
    --info: #0ea5e9;
    --info-soft: #e0f2fe;
    --heat-none: #eceff5;
    --heat-low: #fbbf24;
    --heat-mid: #fde68a;
    --heat-ok: #34d399;
    --heat-over: #38bdf8;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
    --radius: 16px;
    --radius-sm: 10px;
    --side-w: 76px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b0f19;
        --surface: #131a2a;
        --surface-2: #1a2236;
        --surface-3: #232d45;
        --border: #232c40;
        --text: #e8ecf5;
        --text-2: #a7b0c4;
        --text-3: #6b7690;
        --accent: #818cf8;
        --accent-soft: #252a52;
        --accent-text: #0b0f19;
        --good-soft: #063d2e;
        --warn-soft: #3d2c05;
        --bad: #fb7185;
        --bad-soft: #3f0d1c;
        --info-soft: #06324a;
        --heat-none: #1c2438;
        --heat-low: #d97706;
        --heat-mid: #8a6a1c;
        --heat-ok: #059669;
        --heat-over: #0284c7;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0b0f19;
    --surface: #131a2a;
    --surface-2: #1a2236;
    --surface-3: #232d45;
    --border: #232c40;
    --text: #e8ecf5;
    --text-2: #a7b0c4;
    --text-3: #6b7690;
    --accent: #818cf8;
    --accent-soft: #252a52;
    --accent-text: #0b0f19;
    --good-soft: #063d2e;
    --warn-soft: #3d2c05;
    --bad: #fb7185;
    --bad-soft: #3f0d1c;
    --info-soft: #06324a;
    --heat-none: #1c2438;
    --heat-low: #d97706;
    --heat-mid: #8a6a1c;
    --heat-ok: #059669;
    --heat-over: #0284c7;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body.ins {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.num, .ins-kpi-value, .ins-heat td, .ins-mix-list b { font-variant-numeric: tabular-nums; }
.ins-sr { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }

/* ---------- Shell ---------- */
.ins-side {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--side-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 0;
    gap: 24px;
    z-index: 30;
}

.ins-brand img { width: 40px; height: 40px; object-fit: contain; display: block; }

.ins-nav { display: flex; flex-direction: column; gap: 6px; }
.ins-nav-sep { height: 1px; margin: 6px 10px; background: var(--border); }
.ins-side { overflow-y: auto; scrollbar-width: none; }
.ins-nav-item { position: relative; }

/* "New feature" dot on a nav item — hidden once the feature was opened */
.ins-nav-item .nav-dot {
    position: absolute;
    top: 7px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--surface);
}

    .ins-nav-item .nav-dot::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: inherit;
        animation: ins-dot-pulse 1.8s ease-out infinite;
    }

.seen-insights [data-new="insights"] { display: none; }

@keyframes ins-dot-pulse { to { transform: scale(2.6); opacity: 0; } }

.ins-nav-item {
    width: 56px;
    padding: 10px 0 8px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    transition: background .15s, color .15s;
}

    .ins-nav-item:hover { background: var(--surface-2); color: var(--text); }
    .ins-nav-item.is-active { background: var(--accent-soft); color: var(--accent); }
    .ins-nav-item svg.lucide { width: 20px; height: 20px; }

.ins-main { margin-left: var(--side-w); min-height: 100vh; }

.ins-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 32px 6px;
}

.ins-top h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.ins-top p { color: var(--text-2); margin-top: 2px; }
.ins-top-actions { display: flex; align-items: center; gap: 10px; }

.ins-content { padding: 16px 32px 48px; max-width: 1480px; }

/* ---------- Controls ---------- */
.ins-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    color: var(--text-2);
    transition: background .15s, color .15s, border-color .15s;
}

    .ins-icon-btn:hover { background: var(--surface-2); color: var(--text); }
    .ins-icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.ins-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    flex: none;
}

.ins-avatar-lg { width: 48px; height: 48px; font-size: 16px; cursor: default; }

.ins-user { position: relative; }

.ins-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity .15s, transform .15s;
    z-index: 40;
}

    .ins-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
    .ins-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
    .ins-menu-head span { color: var(--text-3); font-size: 12px; }
    .ins-menu a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); }
    .ins-menu a:hover { background: var(--surface-2); color: var(--text); }

/* Filters */
.ins-filters {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px 24px;
    padding: 14px 16px;
    margin: 0 -16px 20px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ins-field { display: flex; flex-direction: column; gap: 6px; }
.ins-field > span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }

.ins-select { position: relative; }

    .ins-select select {
        appearance: none;
        -webkit-appearance: none;
        min-width: 220px;
        height: 40px;
        padding: 0 38px 0 14px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: var(--surface);
        color: var(--text);
        font: inherit;
        font-weight: 500;
        cursor: pointer;
        box-shadow: var(--shadow);
    }

    .ins-select select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .ins-select svg.lucide { position: absolute; right: 12px; top: 11px; color: var(--text-3); pointer-events: none; }

.ins-week { display: flex; align-items: center; gap: 6px; position: relative; }

.ins-week-label {
    height: 40px;
    min-width: 170px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    cursor: pointer;
    line-height: 1.15;
}

    .ins-week-label strong { font-weight: 600; }
    .ins-week-label small { color: var(--text-3); font-size: 11.5px; }
    .ins-week .ins-icon-btn { height: 40px; width: 40px; }

.ins-chip-btn {
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

    .ins-chip-btn:disabled { opacity: .45; cursor: default; }

.ins-seg {
    display: inline-flex;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-3);
    gap: 2px;
}

    .ins-seg button {
        border: 0;
        background: transparent;
        padding: 0 14px;
        height: 32px;
        border-radius: 9px;
        color: var(--text-2);
        font-weight: 500;
        cursor: pointer;
        transition: background .15s, color .15s, box-shadow .15s;
        white-space: nowrap;
    }

    .ins-seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
    .ins-seg-sm button { height: 28px; padding: 0 10px; font-size: 12.5px; }

/* ---------- Empty state ---------- */
.ins-empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-2);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

    .ins-empty svg.lucide { width: 44px; height: 44px; color: var(--accent); margin-bottom: 12px; }
    .ins-empty h2 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
    .ins-empty p { max-width: 420px; margin: 0 auto; }

/* ---------- KPIs ---------- */
.ins-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.ins-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

button.ins-kpi { cursor: pointer; transition: border-color .15s, transform .15s; }
button.ins-kpi:hover { border-color: var(--accent); }
button.ins-kpi[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.ins-kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; font-size: 13px; }

.ins-kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
}

    .ins-kpi-icon svg.lucide { width: 16px; height: 16px; }
    .ins-kpi-icon.is-good { background: var(--good-soft); color: var(--good); }
    .ins-kpi-icon.is-warn { background: var(--warn-soft); color: var(--warn); }
    .ins-kpi-icon.is-bad { background: var(--bad-soft); color: var(--bad); }
    .ins-kpi-icon.is-info { background: var(--info-soft); color: var(--info); }

.ins-kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.ins-kpi-value small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 2px; }
.ins-kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); min-height: 20px; }

.ins-delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
}

    .ins-delta svg.lucide { width: 13px; height: 13px; }
    .ins-delta.is-up { background: var(--good-soft); color: var(--good); }
    .ins-delta.is-down { background: var(--bad-soft); color: var(--bad); }
    .ins-delta.is-flat { background: var(--surface-2); color: var(--text-3); }

.ins-meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 2px; }
.ins-meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Cards / grid ---------- */
.ins-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.ins-span-2 { grid-column: span 2; }

.ins-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px 18px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.ins-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

    .ins-card-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
    .ins-card-head p { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

.ins-chart { position: relative; width: 100%; }
.ins-chart-donut { height: 240px; }
.ins-chart-trend { height: 300px; }

.ins-filter-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
    font-size: 13px;
}

    .ins-filter-note button { margin-left: auto; border: 0; background: none; color: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* Legends */
.ins-legend { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; }

    .ins-legend li {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 10px;
        border-radius: 999px;
        background: var(--surface-2);
        color: var(--text-2);
        font-size: 12.5px;
        cursor: pointer;
        user-select: none;
        transition: opacity .15s, background .15s;
    }

    .ins-legend li.is-off { opacity: .4; }
    .ins-legend li.is-focus { background: var(--accent-soft); color: var(--text); }

.ins-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.is-hatch { background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .7) 0 2px, transparent 2px 4px) !important; }

.ins-mix-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

    .ins-mix-list li {
        display: grid;
        grid-template-columns: 12px 1fr auto auto;
        align-items: center;
        gap: 10px;
        padding: 7px 8px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 13px;
    }

    .ins-mix-list li:hover, .ins-mix-list li.is-focus { background: var(--surface-2); }
    .ins-mix-list li span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
    .ins-mix-list li.is-focus span.name { color: var(--text); font-weight: 600; }
    .ins-mix-list li em { font-style: normal; color: var(--text-3); font-size: 12px; min-width: 40px; text-align: right; }

/* Heatmap */
.ins-heat-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px 4px; }

.ins-heat { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 520px; }

    .ins-heat th {
        font-size: 11.5px;
        font-weight: 500;
        color: var(--text-3);
        padding: 0 2px 4px;
        text-align: center;
        white-space: nowrap;
    }

        .ins-heat th.is-current { color: var(--accent); font-weight: 700; }
        .ins-heat th:first-child, .ins-heat td:first-child { text-align: left; }

    .ins-heat tbody tr { cursor: pointer; }

    .ins-heat td.person {
        white-space: nowrap;
        padding-right: 12px;
        font-weight: 500;
        color: var(--text-2);
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        border-radius: 8px;
        padding-left: 6px;
    }

    .ins-heat tbody tr:hover td.person { color: var(--text); background: var(--surface-2); }

    .ins-heat td.cell {
        height: 34px;
        min-width: 44px;
        border-radius: 8px;
        text-align: center;
        font-size: 12px;
        font-weight: 600;
        color: #1f2937;
        transition: transform .12s, box-shadow .12s;
    }

    .ins-heat tbody tr:hover td.cell { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .06); }
    .ins-heat td.cell.is-current { box-shadow: inset 0 0 0 2px var(--accent); }
    .ins-heat td.cell.h-none { color: var(--text-3); font-weight: 400; }

.h-none { background: var(--heat-none); }
.h-low { background: var(--heat-low); }
.h-mid { background: var(--heat-mid); }
.h-ok { background: var(--heat-ok); }
.h-over { background: var(--heat-over); }
.h-abs { background: repeating-linear-gradient(135deg, var(--surface-3) 0 5px, var(--heat-none) 5px 10px); }
.h-gap { background: transparent; border: 1px dashed var(--border); }

:root[data-theme="dark"] .ins-heat td.cell:not(.h-none):not(.h-abs) { color: #f8fafc; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .ins-heat td.cell:not(.h-none):not(.h-abs) { color: #f8fafc; }
}

.ins-scale { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-3); }
.ins-scale li { display: inline-flex; align-items: center; gap: 6px; }
.ins-scale i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* ---------- Drawer ---------- */
.ins-scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);
    z-index: 50;
    animation: ins-fade .2s ease;
}

.ins-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(440px, 100vw);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 60;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    display: flex;
    flex-direction: column;
}

    .ins-drawer.is-open { transform: none; }

.ins-drawer-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

    .ins-drawer-head h2 { font-size: 17px; font-weight: 600; }
    .ins-drawer-head p { color: var(--text-3); font-size: 12.5px; }

.ins-drawer-body { padding: 20px 22px 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }

.ins-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 10px; }

.ins-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ins-stat { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.ins-stat b { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ins-stat span { font-size: 12px; color: var(--text-3); }

.ins-bars { display: flex; flex-direction: column; gap: 10px; }
.ins-bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.ins-bar-row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-bar-row b { font-variant-numeric: tabular-nums; }
.ins-bar-track { grid-column: span 2; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.ins-bar-track i { display: block; height: 100%; border-radius: inherit; }

.ins-note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13px; }
.ins-note.is-warn { background: var(--warn-soft); }
.ins-note.is-bad { background: var(--bad-soft); }
.ins-note.is-good { background: var(--good-soft); }
.ins-note svg.lucide { margin-top: 1px; }

.ins-spark { height: 150px; position: relative; }

/* ---------- Tooltip ---------- */
.ins-tip {
    position: absolute;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 10px 12px;
    min-width: 170px;
    font-size: 12.5px;
    z-index: 5;
    opacity: 0;
    transition: opacity .12s;
}

    .ins-tip h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
    .ins-tip ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
    .ins-tip li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; color: var(--text-2); }
    .ins-tip li b { color: var(--text); font-variant-numeric: tabular-nums; }
    .ins-tip footer { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-weight: 600; }

/* ---------- Skeletons & toast ---------- */
.is-loading .ins-kpi, .is-loading .ins-card { position: relative; }

.is-loading .ins-kpi > *, .is-loading .ins-card > *:not(.ins-card-head) { visibility: hidden; }

.is-loading .ins-kpi::after, .is-loading .ins-card::after {
    content: "";
    position: absolute;
    inset: 16px;
    top: 16px;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: ins-shimmer 1.2s linear infinite;
}

.is-loading .ins-card::after { top: 64px; }

.ins-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    z-index: 70;
    animation: ins-fade .2s ease;
}

/* ---------- Card share button (card-share.js) ---------- */
.card-share {
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-3);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}

    .card-share:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
    .card-share:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .card-share.is-done { color: var(--good); border-color: var(--good); background: var(--good-soft); }
    .card-share.is-busy { cursor: progress; }
    .card-share svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .card-share .cs-spin { animation: cs-spin .8s linear infinite; }

/* Header rows: title left, controls + share button right */
.ins-card-head > :first-child,
.page-card-head > :first-child { margin-right: auto; }
.ins-card-head, .page-card-head { justify-content: flex-start; }

/* Cards without a header row: float the button top-right */
.cs-float { position: relative; }

    .cs-float > .card-share {
        position: absolute;
        top: 14px;
        right: 14px;
        z-index: 2;
    }

.cs-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1100;
    transform: translate(-50%, 12px);
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    font: 500 13.5px 'Inter', system-ui, sans-serif;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}

    .cs-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 767px) {
    .cs-toast { bottom: 84px; } /* above the bottom tab bar */
}

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

@keyframes ins-shimmer { to { background-position: -200% 0; } }
@keyframes ins-fade { from { opacity: 0; } }

.ins-dash { animation: ins-fade .3s ease; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-height: 640px) {
    .ins-filters { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

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

@media (max-width: 960px) {
    .ins-grid { grid-template-columns: minmax(0, 1fr); }
    .ins-span-2 { grid-column: auto; }
}

@media (max-width: 767px) {
    :root { --side-w: 0px; }

    .ins-side {
        inset: auto 0 0 0;
        width: auto;
        height: 64px;
        flex-direction: row;
        justify-content: center;
        padding: 0 8px env(safe-area-inset-bottom);
        border-right: 0;
        border-top: 1px solid var(--border);
    }

    .ins-brand { display: none; }
    .ins-side { justify-content: flex-start; overflow-x: auto; overflow-y: hidden; }
    .ins-nav { flex-direction: row; gap: 4px; margin: 0 auto; }
    .ins-nav-sep { display: none; }
    .ins-nav-item { width: 68px; flex: none; }

    .ins-main { padding-bottom: 72px; }
    .ins-top { padding: 16px 16px 4px; }
    .ins-top h1 { font-size: 20px; }
    .ins-top p { display: none; }
    .ins-content { padding: 8px 16px 32px; }
    .ins-filters { margin: 0 -16px 16px; padding: 10px 16px; gap: 10px 12px; }
    .ins-field:first-child, .ins-select select { width: 100%; min-width: 0; }
    .ins-week-label { min-width: 0; flex: 1; }
    .ins-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .ins-kpi { padding: 14px; }
    .ins-kpi-value { font-size: 22px; }
    .ins-card { padding: 16px; }
}
