/* Inventory Sync — StockSync. All styles namespaced under .iv */
.iv {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #0d9488;
    --brand-ink: #0f766e;
    --ok: #16a34a;
    --low: #d97706;
    --out: #dc2626;
    --accent: #2563eb;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
}
.iv * { box-sizing: border-box; }
.iv h2, .iv h3, .iv h4 { margin: 0; }

/* topbar */
.iv-topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .7rem 1.25rem; background: var(--panel);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
    flex-wrap: wrap;
}
.iv-brand { display: flex; align-items: center; gap: .6rem; }
.iv-logo {
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), #0369a1); font-size: 1.1rem;
}
.iv-brand b { display: block; font-size: .95rem; line-height: 1.1; }
.iv-brand small { color: var(--muted); font-size: .72rem; }
.iv-nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.iv-navbtn {
    border: 0; background: transparent; color: var(--muted); font: inherit;
    padding: .45rem .7rem; border-radius: 8px; cursor: pointer; font-size: .85rem;
    display: flex; align-items: center; gap: .35rem;
}
.iv-navbtn:hover { background: var(--bg); color: var(--ink); }
.iv-navbtn.active { background: var(--brand); color: #fff; }
.iv-badge {
    background: var(--out); color: #fff; border-radius: 999px; font-size: .68rem;
    padding: .05rem .38rem; font-weight: 700;
}
.iv-navbtn.active .iv-badge { background: rgba(255,255,255,.28); }
.iv-top-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.iv-live-dot { font-size: .7rem; font-weight: 700; color: var(--ok); display: flex; align-items: center; gap: .3rem; }
.iv-live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: iv-pulse 1.8s infinite; }
@keyframes iv-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.iv-btn {
    border: 0; background: var(--brand); color: #fff; font: inherit; font-size: .82rem;
    padding: .5rem .85rem; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.iv-btn:hover { background: var(--brand-ink); }
.iv-btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.iv-btn.ghost:hover { color: var(--ink); background: var(--bg); }
.iv-btn.sm { padding: .32rem .6rem; font-size: .76rem; }
.iv-btn:disabled { opacity: .45; cursor: not-allowed; }

/* views */
.iv-view { padding: 1.25rem; max-width: 1180px; margin: 0 auto; }
.iv-view[hidden] { display: none !important; }
.iv-h2 { font-size: 1.15rem; margin-bottom: .1rem; }
.iv-sub { color: var(--muted); font-size: .82rem; margin: 0 0 1rem; }

.iv-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.iv-card h3 { font-size: .9rem; margin-bottom: .7rem; }

/* KPI row */
.iv-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; margin-bottom: 1rem; }
.iv-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .8rem .9rem; }
.iv-kpi b { font-size: 1.3rem; display: block; }
.iv-kpi small { color: var(--muted); font-size: .74rem; }
.iv-kpi .delta { font-size: .72rem; font-weight: 700; margin-top: .2rem; }
.iv-kpi .delta.up { color: var(--ok); }
.iv-kpi .delta.down { color: var(--out); }

/* overview grid */
.iv-ov-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1rem; }

/* alerts */
.iv-alert {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem;
    border: 1px solid var(--line); border-radius: 9px; margin-bottom: .5rem;
}
.iv-alert .ae { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--bg); font-size: .95rem; }
.iv-alert .ai { flex: 1; }
.iv-alert .ai b { font-size: .84rem; }
.iv-alert .ai small { display: block; color: var(--muted); font-size: .73rem; }
.iv-pill { font-size: .68rem; font-weight: 700; padding: .12rem .45rem; border-radius: 999px; }
.iv-pill.low { background: #fef3c7; color: var(--low); }
.iv-pill.out { background: #fee2e2; color: var(--out); }
.iv-pill.ok { background: #dcfce7; color: var(--ok); }

/* channel strip */
.iv-chan-strip { display: flex; flex-direction: column; gap: .45rem; }
.iv-chan-row { display: flex; align-items: center; gap: .6rem; font-size: .82rem; }
.iv-chan-row .ce { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: .8rem; }
.iv-chan-row .cn { flex: 1; }
.iv-chan-row .cn small { color: var(--muted); display: block; font-size: .71rem; }
.iv-dot { width: 8px; height: 8px; border-radius: 50%; }
.iv-dot.g { background: var(--ok); }
.iv-dot.y { background: var(--low); }
.iv-dot.r { background: var(--out); }

/* movements / log feed */
.iv-feed { display: flex; flex-direction: column; gap: .1rem; }
.iv-feed-row {
    display: grid; grid-template-columns: 14px 1fr auto; gap: .6rem; align-items: start;
    padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .82rem;
}
.iv-feed-row:last-child { border-bottom: 0; }
.iv-feed-row .fdot { width: 9px; height: 9px; border-radius: 50%; margin-top: .35rem; }
.iv-feed-row small { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.iv-feed-row .fch { font-weight: 600; }

/* table */
.iv-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.iv-table th {
    text-align: left; color: var(--muted); font-weight: 600; font-size: .74rem;
    text-transform: uppercase; letter-spacing: .03em; padding: .5rem .6rem; border-bottom: 1px solid var(--line);
}
.iv-table td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.iv-table tr:hover td { background: #f8fafc; }
.iv-prod { display: flex; align-items: center; gap: .6rem; }
.iv-prod .pe { width: 32px; height: 32px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: 1rem; }
.iv-prod b { font-size: .84rem; }
.iv-prod small { color: var(--muted); font-size: .71rem; }
.iv-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.iv-listings { display: flex; gap: .2rem; }
.iv-listings span { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; font-size: .62rem; color: #fff; }
.iv-listings span.off { background: var(--line) !important; opacity: .5; }

/* stepper */
.iv-stepper { display: inline-flex; align-items: center; gap: .3rem; }
.iv-stepper button {
    width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
    background: var(--panel); cursor: pointer; font-size: 1rem; line-height: 1; color: var(--ink);
}
.iv-stepper input {
    width: 52px; text-align: center; border: 1px solid var(--line); border-radius: 7px;
    padding: .3rem; font: inherit; font-size: .82rem;
}

/* filters */
.iv-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.iv-chip {
    border: 1px solid var(--line); background: var(--panel); color: var(--muted);
    padding: .3rem .7rem; border-radius: 999px; cursor: pointer; font-size: .78rem;
}
.iv-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* channels view */
.iv-chan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.iv-chan-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.iv-chan-card .top { padding: .9rem 1rem; color: #fff; display: flex; align-items: center; gap: .6rem; }
.iv-chan-card .top .cce { font-size: 1.3rem; }
.iv-chan-card .top b { font-size: .95rem; }
.iv-chan-card .top small { opacity: .85; font-size: .72rem; display: block; }
.iv-chan-card .body { padding: .9rem 1rem; }
.iv-chan-card .kv { display: flex; justify-content: space-between; font-size: .8rem; padding: .25rem 0; }
.iv-chan-card .kv span:first-child { color: var(--muted); }
.iv-chan-card .actions { display: flex; gap: .5rem; margin-top: .7rem; }

/* toggle */
.iv-toggle { position: relative; width: 38px; height: 22px; }
.iv-toggle input { opacity: 0; width: 0; height: 0; }
.iv-toggle .tk { position: absolute; inset: 0; background: var(--line); border-radius: 999px; cursor: pointer; transition: .18s; }
.iv-toggle .tk::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--panel); border-radius: 50%; transition: .18s; }
.iv-toggle input:checked + .tk { background: var(--ok); }
.iv-toggle input:checked + .tk::before { transform: translateX(16px); }

/* orders */
.iv-order { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: .8rem .95rem; margin-bottom: .6rem; }
.iv-order .oh { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.iv-order .oh b { font-size: .88rem; }
.iv-order .och { font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; color: #fff; }
.iv-order .oi { font-size: .8rem; color: var(--muted); }
.iv-order .of { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }
.iv-status { font-size: .68rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; }
.iv-status.New { background: #dbeafe; color: #1d4ed8; }
.iv-status.Packed { background: #fef9c3; color: #a16207; }
.iv-status.Shipped { background: #dcfce7; color: #15803d; }

.iv-analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.iv-bar-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: .5rem; align-items: center; font-size: .8rem; margin-bottom: .4rem; }
.iv-bar-row .bar { background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; }
.iv-bar-row .bar i { display: block; height: 100%; background: var(--brand); }
.iv-bar-row .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.iv-toast {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
    background: var(--ink); color: #fff; padding: .65rem 1.1rem; border-radius: 10px;
    font-size: .84rem; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.iv-toast[hidden] { display: none; }

@media (max-width: 860px) {
    .iv-kpis { grid-template-columns: repeat(2, 1fr); }
    .iv-ov-grid, .iv-analytics-grid { grid-template-columns: 1fr; }
    .iv-top-actions { width: 100%; margin-left: 0; }
    .iv-table thead { display: none; }
    .iv-table td { display: flex; justify-content: space-between; border: 0; padding: .3rem .2rem; }
    .iv-table tr { display: block; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; margin-bottom: .6rem; }
}
