/* ============================================================
   VRS — v4 components (themeable)
   iPhone-17 animated app flow · richer dashboard · role selector · stories
   Loads after theme.css + ui.css
   ============================================================ */

/* ───── pipeline rail (fixes token overlap) ───── */
.pipe-rail { position: absolute; top: 17px; left: 20px; right: 20px; height: 2px; background: var(--hairline); border-radius: 2px; z-index: 1; }
.pipe-rail > i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 2px; box-shadow: 0 0 8px var(--glow); transition: width .7s ease; }

/* ───── company switcher (multi-tenant) ───── */
.co-switch { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 8px; padding: 5px 10px 5px 6px; font-size: 12px; font-weight: 600; }
.co-switch .badge { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg,#E8722C,#C2410C); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.co-switch .cv { display: flex; flex-direction: column; line-height: 1.05; }
.co-switch .cv .t { font-size: 12px; }
.co-switch .cv .s { font-size: 9px; color: var(--text-3); font-family: var(--mono); font-weight: 400; }
.co-switch svg { width: 12px; height: 12px; color: var(--text-3); }

/* ───── dashboard overview tiles ───── */
.ov-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.ov-tile { border: 1px solid var(--hairline); border-radius: 12px; padding: 15px; background: var(--surface); }
.ov-tile .lbl { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.ov-tile .lbl .ic { width: 22px; height: 22px; border-radius: 6px; background: var(--green-wash); color: var(--accent-text); display: grid; place-items: center; }
.ov-tile .lbl .ic svg { width: 12px; height: 12px; }
.ov-tile .v { font-family: var(--disp); font-weight: 600; font-size: 38px; line-height: 1; margin-top: 10px; display: flex; align-items: baseline; gap: 8px; }
.ov-tile .v .delta { font-family: var(--font); font-size: 12px; font-weight: 700; color: var(--accent-text); }
.ov-tile .v .delta.warn { color: var(--pill-amber-tx); }
.ov-tile.alert .v { color: var(--pill-amber-tx); }

.dash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.comp-bar { padding: 11px 0; }
.comp-bar:not(:last-child) { border-bottom: 1px solid var(--hairline); }
.comp-bar .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.comp-bar .top .nm { font-weight: 600; }
.comp-bar .top .pct { font-family: var(--mono); color: var(--accent-text); font-weight: 600; }
.comp-bar .top .pct.done { color: var(--accent-text); }
.comp-bar .track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.comp-bar .track > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--green), var(--green-l)); }

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 11px; align-items: flex-start; padding: 10px 0; }
.feed-item:not(:last-child) { border-bottom: 1px solid var(--hairline); }
.feed-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; }
.feed-item .tx { flex: 1; font-size: 12.5px; }
.feed-item .tx b { font-weight: 700; }
.feed-item .tm { font-family: var(--mono); font-size: 10px; color: var(--text-3); white-space: nowrap; }
.spark { display: flex; align-items: flex-end; gap: 5px; height: 46px; margin-top: 10px; }
.spark i { flex: 1; border-radius: 4px 4px 0 0; background: var(--green-wash); }
.spark i.hi { background: var(--green); }

/* ───── iPhone 17 frame + animated flow ───── */
.iphone { width: 326px; aspect-ratio: 326/684; position: relative; border-radius: 58px; padding: 7px;
  background: linear-gradient(150deg, #3a3f3b, #15191600 40%), linear-gradient(320deg, #2b302c, #50554f);
  box-shadow: var(--shadow-pop), inset 0 0 0 1.5px rgba(255,255,255,0.12), inset 0 0 0 6px #0c0f0d;
}
[data-theme="light"] .iphone { background: linear-gradient(150deg, #c9cdc6, #eceee9 45%), linear-gradient(320deg, #b9bdb6, #d7dad3); box-shadow: var(--shadow-pop), inset 0 0 0 1.5px rgba(255,255,255,0.6), inset 0 0 0 6px #b6bab3; }
.iphone .ip-screen { width: 100%; height: 100%; border-radius: 51px; overflow: hidden; background: var(--bg); position: relative; }
.ip-island { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 98px; height: 28px; background: #050705; border-radius: 99px; z-index: 30; display: flex; align-items: center; justify-content: flex-end; padding-right: 12px; }
.ip-island::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #2a3b46, #060a0d); }
.ip-btn { position: absolute; width: 3px; border-radius: 2px; background: rgba(120,128,120,0.5); }
.ip-btn.r { right: -2px; top: 150px; height: 64px; }
.ip-btn.l1 { left: -2px; top: 130px; height: 30px; }
.ip-btn.l2 { left: -2px; top: 172px; height: 50px; }

.ip-app { display: flex; flex-direction: column; height: 100%; }
.ip-status { display: flex; justify-content: space-between; align-items: center; padding: 16px 26px 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.ip-status .r { display: flex; gap: 6px; align-items: center; }
.ip-status .r svg { width: 16px; height: 12px; }

.flow { position: relative; flex: 1; overflow: hidden; }
.flow-track { display: flex; height: 100%; width: 400%; transition: transform .6s cubic-bezier(.5,.05,.2,1); }
.flow-screen { width: 25%; height: 100%; overflow: hidden; padding: 4px 16px 0; }

.flow-cap { padding: 6px 14px 0; }
.flow-cap .date { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.flow-cap .h { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; display: flex; justify-content: space-between; align-items: center; }
.flow-cap .h .spor { font-family: var(--mono); font-size: 9px; font-weight: 600; color: var(--pill-blue-tx); background: var(--pill-blue-bg); border-radius: 99px; padding: 4px 9px; }

.fseg { display: flex; gap: 4px; margin: 12px 0 0; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.fseg .s { flex: 1; text-align: center; padding: 7px 2px; border-radius: 9px; font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.fseg .s.on { background: var(--green); color: var(--on-green); box-shadow: 0 4px 10px -4px var(--glow); }

.fcard { border: 1px solid var(--hairline); border-radius: 16px; padding: 14px; background: var(--surface); box-shadow: var(--shadow-card); margin-top: 12px; }
.fcard .chip { font-family: var(--mono); font-size: 9px; font-weight: 600; color: var(--pill-blue-tx); background: var(--pill-blue-bg); border-radius: 99px; padding: 4px 9px; display: inline-block; }
.fcard .fcard-t { font-size: 16px; font-weight: 700; margin: 10px 0 3px; }
.fcard .meta { font-size: 11.5px; color: var(--text-3); }
.fbtn { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--green); color: var(--on-green); font-size: 14px; font-weight: 700; padding: 13px; border-radius: 13px; box-shadow: 0 8px 20px -8px var(--glow); margin-top: 13px; position: relative; }
.fbtn svg { width: 14px; height: 14px; }
.flow-screen.tapping .fbtn { animation: tapPulse .5s ease; }
@keyframes tapPulse { 50% { transform: scale(.95); filter: brightness(.92); } }
.fbtn .ripple { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,0.6); opacity: 0; pointer-events: none; }
.flow-screen.tapping .fbtn .ripple { animation: ripple .55s ease-out; }
@keyframes ripple { 0% { opacity: .7; transform: scale(1); } 100% { opacity: 0; transform: scale(9); } }

/* active timer screen */
.ftimer { background: linear-gradient(160deg, var(--green), var(--green-d)); border-radius: 18px; padding: 16px; color: var(--on-green); box-shadow: 0 14px 28px -14px var(--glow); margin-top: 12px; }
.ftimer .st { font-family: var(--mono); font-size: 10px; opacity: .9; display: flex; align-items: center; gap: 7px; }
.ftimer .st .d { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.4s infinite; }
.ftimer .big { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 8px 0 2px; }
.ftimer .sub { font-size: 12px; opacity: .92; }
.ftl { margin-top: 14px; }
.ftl-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; }
.ftl-row:not(:last-child) { border-bottom: 1px solid var(--hairline); }
.ftl-row .ic { width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center; }
.ftl-row .ic svg { width: 13px; height: 13px; }
.ftl-row .tx { flex: 1; }
.ftl-row .tx .a { font-size: 12.5px; font-weight: 600; }
.ftl-row .tx .b { font-size: 10.5px; color: var(--text-3); }
.ftl-row .vv { font-family: var(--mono); font-size: 12px; }

/* calc screen */
.fcalc-top { display: flex; align-items: baseline; gap: 8px; padding: 6px 2px 4px; }
.fcalc-top .l { font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.fcalc-top .amt { font-family: var(--disp); font-weight: 600; font-size: 34px; color: var(--accent-text); line-height: 1; }
.fcalc-top .u { font-size: 12px; color: var(--text-2); }
.fline { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.fline:not(:last-child) { border-bottom: 1px solid var(--hairline); }
.fline .lic { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.fline .tx { flex: 1; }
.fline .tx .a { font-size: 12.5px; font-weight: 600; }
.fline .tx .b { font-size: 10.5px; color: var(--text-3); }
.fline .vv { font-family: var(--mono); font-size: 12px; }
.fline .vv.g { color: var(--accent-text); }

/* edit screen */
.fedit-field { margin-top: 12px; }
.fedit-field .l { font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.fedit-times { display: flex; gap: 8px; }
.fedit-times .t { flex: 1; border: 1px solid var(--line); border-radius: 11px; padding: 11px; text-align: center; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fedit-times .t.act { border-color: var(--green); box-shadow: 0 0 0 3px var(--glow); }
.fedit-sel { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.fedit-sel .pill { font-size: 10px; }

/* persistent app tab bar */
.ip-tabbar { display: flex; justify-content: space-around; padding: 9px 8px 16px; background: var(--nav-bg); backdrop-filter: blur(10px); border-top: 1px solid var(--hairline); }
.ip-tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 9.5px; color: var(--text-3); }
.ip-tab svg { width: 19px; height: 19px; }
.ip-tab.on { color: var(--accent-text); }

/* flow controls (outside phone) */
.flow-dots { display: flex; gap: 10px; justify-content: center; margin-top: 26px; }
/* Inactive steps dim via color (kept ≥ WCAG AA contrast), not opacity. */
.flow-dot { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; width: 130px; text-align: center; }
.flow-dot .bar { width: 100%; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.flow-dot .bar > i { display: block; height: 100%; width: 100%; background: var(--green); border-radius: 3px; transform: scaleX(0); transform-origin: left; }
.flow-dot.on .bar > i { animation: fillbar 3.6s linear forwards; }
@keyframes fillbar { to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .flow-dot.on .bar > i { animation: none; transform: scaleX(1); }
}
.flow-dot .lab { font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: color .2s; }
.flow-dot:hover .lab { color: var(--text); }
.flow-dot.on .lab { color: var(--text); }
.flow-dot .num { font-family: var(--mono); font-size: 10px; color: var(--text-2); }
.flow-dot.on .num { color: var(--accent-text); }

/* ───── role selector ───── */
.roles { margin-top: 44px; }
.role-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.role-tab { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; cursor: pointer; transition: all .2s; }
.role-tab.on { background: var(--green); border-color: var(--green); color: var(--on-green); box-shadow: 0 10px 24px -10px var(--glow); }
.role-stage { margin-top: 26px; }
.role-panel { display: none; }
.role-panel.on { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; animation: panelIn .5s cubic-bezier(.2,.7,.2,1); }
.role-panel .rp-copy h3 { font-size: clamp(24px,2.6vw,32px); letter-spacing: -0.02em; }
.role-panel .rp-copy p { font-size: 16px; color: var(--text-2); margin-top: 14px; line-height: 1.55; }
.role-panel .rp-copy .rp-stat { margin-top: 18px; display: inline-flex; align-items: baseline; gap: 8px; }
.role-panel .rp-copy .rp-stat .n { font-family: var(--disp); font-weight: 600; font-size: 40px; color: var(--accent-text); line-height: 1; }
.role-panel .rp-copy .rp-stat .k { font-size: 13px; color: var(--text-2); }
@media (max-width: 1000px){ .role-panel.on { grid-template-columns: 1fr; gap: 26px; } }

/* ───── stories ───── */
.story-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 48px; }
.story { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-card); display: flex; flex-direction: column; transition: transform .25s, border-color .25s; }
.story:hover { transform: translateY(-4px); border-color: color-mix(in oklab, var(--green) 35%, var(--line)); }
.story .thumb { aspect-ratio: 16/10; background-color: var(--surface-2); background-size: cover; background-position: center; position: relative; display: grid; place-items: center; border-bottom: 1px solid var(--hairline); overflow: hidden; cursor: pointer; }
.story .thumb::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.18); transition: background .2s; }
.story .thumb:hover::after { background: rgba(0,0,0,.08); }
.story .thumb .play { position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 50%; background: var(--green); display: grid; place-items: center; box-shadow: 0 12px 30px -8px var(--glow); transition: transform .2s, box-shadow .2s; text-decoration: none; }
.story .thumb:hover .play { transform: scale(1.08); box-shadow: 0 16px 40px -8px var(--glow); }
.story .thumb .play svg { width: 20px; height: 20px; color: #fff; margin-left: 3px; }
.story .thumb .tlabel { position: absolute; top: 12px; left: 12px; z-index: 1; font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: var(--accent-text); background: var(--green-wash); padding: 4px 9px; border-radius: 99px; }
.story .thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: none; }
.story .thumb.playing { cursor: default; background-image: none !important; }
.story .thumb.playing::after { display: none; }
.story .thumb.playing .play, .story .thumb.playing .tlabel { display: none; }
.story .thumb.playing iframe { display: block; }
.story .body { padding: 22px; display: flex; flex-direction: column; flex: 1; }
.story blockquote { font-size: 15px; line-height: 1.5; letter-spacing: -0.01em; }
.story .by { display: flex; align-items: center; gap: 11px; margin-top: 20px; }
.story .av { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--on-green); background: linear-gradient(135deg, var(--green-l), var(--green-d)); }
.story .by .nm { font-size: 13.5px; font-weight: 700; }
.story .by .ro { font-size: 11.5px; color: var(--text-3); }
.story .stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.story .stats .st { font-family: var(--mono); font-size: 10px; color: var(--text-2); background: var(--surface-2); padding: 4px 9px; border-radius: 6px; }
.story .stats .st b { color: var(--accent-text); }

@media (max-width: 1000px){
  .ov-row { grid-template-columns: 1fr 1fr; }
  .dash-split { grid-template-columns: 1fr; }
  .story-grid { grid-template-columns: 1fr; }
  .flow-dots { flex-wrap: wrap; }
  .flow-dot { width: 120px; }
}
@media (max-width: 760px){ .ov-row { grid-template-columns: 1fr 1fr; } }
