/* Stock availability dashboard. Builds on phoenix-design.css. */

/* Sign-in gate */
.gate { min-height: 100vh; min-height: 100dvh; display: flex; }
.gate-inner { display: flex; flex-direction: column; justify-content: space-between; padding-top: 32px; padding-bottom: 64px; width: 100%; }
.gate h1 { font-size: clamp(48px, 8vw, 104px); margin: 0 0 18px; color: #fff; }
.gate .lede { color: #C3C8E6; font-size: 19px; max-width: 40ch; margin: 0 0 28px; }
.btn.big { display: inline-block; padding: 14px 24px; font-size: 16px; text-decoration: none; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 22px; flex-wrap: wrap; }
.top-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.top-right .btn { padding: 7px 13px; font-size: 13px; text-decoration: none; }
.status { color: #C3C8E6; font-size: 13px; margin-right: 6px; display: inline-flex; align-items: center; gap: 7px; }
.status .live { width: 8px; height: 8px; border-radius: 50%; background: var(--p2r-green); box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
.status .stale { background: var(--p2r-amber); box-shadow: 0 0 0 3px rgba(245,158,11,.25); }

.tabs { display: flex; gap: 4px; margin-top: 26px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; color: #C3C8E6; font-weight: 700; font-size: 14.5px; padding: 10px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { background: rgba(255,255,255,.08); color: #fff; }
.tab[aria-selected="true"] { background: #fff; color: var(--p2r-navy); }
.tab .tp { font-family: var(--font-display); font-weight: 900; font-size: 12.5px; opacity: .8; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 40px; align-items: center; padding-top: 34px; padding-bottom: 46px; }
.hero h1 { margin: 0; font-size: clamp(42px, 6vw, 78px); color: #fff; }
.basis { color: #9AD3F7; font-weight: 700; font-size: 14px; margin: 0 0 12px; }
.hero .lede { color: #C3C8E6; font-size: 17px; margin: 16px 0 0; max-width: 48ch; }
.kpi { background: #fff; color: #0B1033; border-radius: var(--radius-card); padding: 24px 26px; box-shadow: 0 24px 60px rgba(5,8,30,.35); }
.kpi .lbl { margin: 0 0 8px; font-weight: 700; font-size: 13px; color: #5A6177; }
.kpi .big { font-size: clamp(60px, 7.5vw, 92px); line-height: .9; color: #0B1033; }
.kpi .big small { font-size: .5em; margin-left: 2px; }
.kpi .sub { font-weight: 700; margin: 12px 0 12px; font-size: 15px; }
.kpi .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.kpi .chip.in, .kpi .chip.out, .kpi .chip.low { color: inherit; }
.kpi .chip.out { background: #FBE4E7; color: #D02F45; } .kpi .chip.low { background: #FEF3C7; color: #C96F00; }
.kpi .demand { border-top: 1px solid #EEF0F6; padding-top: 12px; color: #5A6177; font-size: 13.5px; margin: 0; }
.kpi .demand b { color: #0B1033; }

/* Banners */
.banner { border-radius: 14px; padding: 12px 16px; margin: 16px 0 0; font-size: 14px; }
.banner.err { background: var(--out-bg); color: var(--out-t); }
.banner.warn { background: var(--low-bg); color: var(--low-t); }
.banner.info { background: var(--soft); color: var(--muted); }
.gate .banner.err { background: rgba(240,80,110,.18); color: #FFD3DB; max-width: 60ch; margin: 0 0 22px; }

/* Filters */
.filters { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding: 12px 0; border-bottom: 1px solid var(--line); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.filters select, .filters input[type=search], .filters input[type=number] { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-control); padding: 8px 12px; font-size: 14px; max-width: 230px; }
.filters input[type=search] { width: 230px; }
.filters input[type=number] { width: 72px; }
.thr { color: var(--muted); font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.ms { position: relative; }
.msbtn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-control); padding: 8px 32px 8px 12px; font-size: 14px; cursor: pointer; min-width: 150px; max-width: 230px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.msbtn::after { content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-70%) rotate(45deg); }
.msbtn.on { border-color: var(--ink); font-weight: 700; }
.mspop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); width: 270px; max-height: min(380px, 60vh); overflow: auto; padding: 6px; }
.mshead { display: flex; justify-content: space-between; padding: 4px 6px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.mspop label { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.mspop label:hover { background: var(--soft); }
.mspop label span { margin-left: auto; color: var(--faint); font-size: 12.5px; }
.mspop input { accent-color: var(--ink); }

/* Sections */
section.block { margin-top: 46px; }
section.block > h2.hl { font-size: clamp(26px, 3.2vw, 38px); margin: 18px 0 0; max-width: 34ch; }
.note { color: var(--muted); font-size: 14px; margin: -8px 0 16px; max-width: 70ch; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.panel { padding: 22px 22px 16px; }
.panel h3 { margin: 0 0 12px; font-size: 13px; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; }
.panel h3 span { font-weight: 400; color: var(--faint); }
.empty { color: var(--muted); padding: 26px 4px; }

/* Out-of-stock list: the most actionable block */
.outlist { list-style: none; margin: 0; padding: 6px 0; }
.outlist li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 22px; border-bottom: 1px solid var(--soft); }
.outlist li:last-child { border-bottom: 0; }
.outlist .rk { font-family: var(--font-display); font-weight: 900; color: var(--faint); font-size: 14px; }
.outlist .nm b { display: block; font-weight: 700; }
.outlist .nm small { color: var(--faint); font-size: 12.5px; }
.outlist .u { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.outlist .u b { display: block; color: var(--ink); font-family: var(--font-display); font-size: 16px; }

/* Group comparison rows (Total business) */
.grp { display: grid; grid-template-columns: minmax(140px, 1.2fr) 70px minmax(120px, 2fr) minmax(160px, 1.4fr); gap: 16px; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--soft); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; color: var(--ink); }
.grp:last-child { border-bottom: 0; }
.grp:hover { background: var(--soft); }
.grp .gn { font-weight: 700; }
.grp .gn small { display: block; font-weight: 400; color: var(--faint); font-size: 12.5px; }
.grp .gp { font-family: var(--font-display); font-size: 20px; text-align: right; }
.grp .gd { color: var(--muted); font-size: 13px; }
.bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--soft); }
.bar i { display: block; height: 100%; }
.s-in { background: var(--in); } .s-low { background: var(--low); } .s-out { background: var(--out); } .s-ns, .s-nd { background: var(--ns); }

/* Shelf strips per planogram format */
.shelf { display: grid; grid-template-columns: 110px 64px 1fr; gap: 14px; align-items: center; padding: 10px 22px; }
.shelf .fn { font-weight: 700; } .shelf .fp { font-family: var(--font-display); text-align: right; font-size: 17px; }
.strip { display: flex; flex-wrap: wrap; gap: 3px; }
.strip i { display: block; width: 11px; height: 15px; border-radius: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; color: var(--muted); padding: 12px 22px 16px; border-top: 1px solid var(--soft); }
.legend span { display: inline-flex; gap: 7px; align-items: center; } .legend i { width: 11px; height: 15px; border-radius: 3px; display: inline-block; }

/* Trend */
.trend { padding: 20px 22px 12px; }
.trend svg { width: 100%; height: 190px; display: block; }
.trend .axis { fill: var(--faint); font-size: 11px; }
.trend .grid { stroke: var(--soft); }
.trend .line { fill: none; stroke: var(--p2r-blue); stroke-width: 2.5; }
.trend .area { fill: var(--p2r-blue); opacity: .08; }
.trend .dot { fill: var(--p2r-yellow); stroke: var(--p2r-navy); stroke-width: 2; }

/* Breakdown rows */
.brk { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.brk li { margin: 0; }
.bk { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 6px 12px; padding: 8px 8px; width: 100%; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; color: var(--ink); }
.bk:hover { background: var(--soft); }
.bk.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--ink); }
.brk .bn { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brk .bp { font-family: var(--font-display); text-align: right; }
.brk .bar { grid-column: 1; }
.brk .bc { grid-column: 2; color: var(--faint); font-size: 12px; text-align: right; }

/* Matrix */
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--soft); text-align: left; white-space: nowrap; vertical-align: middle; }
th { font-weight: 700; font-size: 12px; color: var(--faint); background: var(--surface); position: sticky; top: 0; }
th button { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
th button[data-dir]::after { content: attr(data-dir); margin-left: 4px; }
td.prod { white-space: normal; min-width: 280px; max-width: 420px; }
td.prod b { display: block; font-weight: 700; } td.prod small { color: var(--faint); }
td.n, th.n { text-align: right; } td.f, th.f { text-align: center; padding: 10px 5px; }
.fac { display: inline-block; min-width: 26px; padding: 3px 7px; border-radius: 7px; font-weight: 700; font-size: 12.5px; color: #fff; }
.fac.s-ns, .fac.s-nd { color: var(--muted); }
.dash { color: var(--line); }
tbody tr:hover td { background: var(--bg); }
.rank { font-family: var(--font-display); color: var(--faint); }
.cover-short { color: var(--out-t); font-weight: 700; }

.foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; color: var(--faint); font-size: 12.5px; padding-top: 34px; padding-bottom: 34px; }
.foot .p2r-wordmark { width: 150px; height: 24px; flex: none; }

/* Planogram dialog */
dialog { border: 0; border-radius: var(--radius-card); background: var(--surface); color: var(--ink); padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100% - 24px); box-shadow: 0 30px 80px rgba(5,8,30,.4); }
dialog::backdrop { background: rgba(11,16,51,.55); }
.dlg { padding: 26px 28px; }
.dlg h2 { margin: 0 0 8px; font-size: 26px; }
.dlg-note { color: var(--muted); margin: 0 0 16px; }
.pl { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; border-top: 1px solid var(--soft); align-items: center; }
.pl b { font-size: 15px; } .pl p { margin: 0; color: var(--muted); font-size: 13.5px; }
.pl .acts { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 8px; }
.pl input[type=file] { display: none; }
.pl .err { color: var(--out-t); grid-column: 1 / 3; }
.dlg-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #0B1033; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 20; display: none; box-shadow: 0 12px 30px rgba(5,8,30,.35); }
.toast.on { display: block; }

/* Snapshot (read-only) */
.snapshot .admin-only, .snapshot .live-only, .snapshot #snapBtn { display: none !important; }

@media (max-width: 960px) { .hero { grid-template-columns: 1fr; } .cols2, .cols3 { grid-template-columns: 1fr; } .grp { grid-template-columns: 1fr 64px; } .grp .bar, .grp .gd { grid-column: 1 / 3; } }
@media (max-width: 560px) { .top-right .btn { padding: 6px 10px; } .outlist li { grid-template-columns: 26px minmax(0,1fr) auto; } .outlist li .chip { display: none; } .shelf { grid-template-columns: 70px 50px 1fr; padding: 10px 14px; } .filters input[type=search] { width: 100%; max-width: none; } }
