/* Live demo dashboards. Colors for machine states are mirrored in wwwroot/js/demo.js. */
.dm-status-chip { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; padding: .3rem .75rem; border: 1px solid var(--re-border); border-radius: 999px; background: var(--re-surface); color: var(--re-muted); }
.dm-status-chip.err { color: #f5c542; border-color: #f5c542; }
.dm-pulse { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 0 0 rgba(46,204,113,.6); animation: dm-pulse 2s infinite; }
@keyframes dm-pulse { 70% { box-shadow: 0 0 0 7px rgba(46,204,113,0); } 100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); } }
@media (prefers-reduced-motion: reduce) { .dm-pulse { animation: none; } }

.dm-tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--re-border); margin-bottom: 1.5rem; }
.dm-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--re-muted); padding: .7rem 1rem; white-space: nowrap; font-weight: 600; }
.dm-tabs button:hover { color: var(--re-text); }
.dm-tabs button.active { color: #fff; border-bottom-color: var(--re-red); }

.dm-good { color: #2ecc71; } .dm-warn { color: #f5c542; } .dm-bad { color: #ff4d5a; }

/* KPI tiles */
.dm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.dm-kpi { background: var(--re-surface); border: 1px solid var(--re-border); border-radius: .6rem; padding: 1rem; display: flex; flex-direction: column; }
.dm-kpi span { color: var(--re-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.dm-kpi b { font-size: 1.9rem; line-height: 1.2; }
.dm-kpi small { color: var(--re-muted); }

.dm-panel { background: var(--re-surface); border: 1px solid var(--re-border); border-radius: .6rem; padding: 1.1rem; height: 100%; }
.dm-panel h3 { font-size: 1.05rem; margin-bottom: .75rem; }
.dm-fac-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .75rem; }
.dm-fac-grid span { display: block; color: var(--re-muted); font-size: .72rem; text-transform: uppercase; }
.dm-fac-grid b { font-size: 1.05rem; }
.dm-stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--re-surface-2); }
.dm-legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .75rem; color: var(--re-muted); margin-top: .5rem; }
.dm-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .3rem; }
.dm-chart-box { position: relative; height: 200px; }

/* Machine cards */
.dm-cell h2 { font-size: 1.1rem; color: var(--re-muted); text-transform: uppercase; letter-spacing: .06em; margin: 1.5rem 0 .75rem; }
.dm-card { background: var(--re-surface); border: 1px solid var(--re-border); border-top: 3px solid var(--re-border); border-radius: .6rem; padding: 1rem; height: 100%; }
.dm-card-running { border-top-color: #2ecc71; } .dm-card-slow { border-top-color: #f5c542; }
.dm-card-down { border-top-color: #ff4d5a; } .dm-card-changeover { border-top-color: #5b8def; }
.dm-card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.dm-card-head h3 { font-size: 1.05rem; margin: 0; flex: 1; }
.dm-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dm-state-text { font-size: .8rem; font-weight: 700; }
.dm-rows { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .75rem; }
.dm-rows dt { font-size: .7rem; color: var(--re-muted); text-transform: uppercase; font-weight: 400; }
.dm-rows dd { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.dm-label { display: flex; justify-content: space-between; font-size: .75rem; color: var(--re-muted); margin: .6rem 0 .25rem; }
.dm-label span { color: var(--re-text); }
.dm-progress { height: 8px; border-radius: 4px; background: var(--re-surface-2); overflow: hidden; }
.dm-progress > div { height: 100%; background: var(--re-red); transition: width .6s; }
.dm-timeline { display: flex; height: 18px; border-radius: 4px; overflow: hidden; background: var(--re-surface-2); }
.dm-seg { display: block; height: 100%; }
.dm-seg-running { background: #2ecc71; } .dm-seg-slow { background: #f5c542; } .dm-seg-down { background: #ff4d5a; }
.dm-seg-idle { background: #4a4a55; } .dm-seg-changeover { background: #5b8def; }
.dm-axis { display: flex; justify-content: space-between; font-size: .68rem; color: var(--re-muted); margin-top: .2rem; }
.dm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--re-border); }
.dm-stats span { display: block; font-size: .68rem; text-transform: uppercase; color: var(--re-muted); }
.dm-stats b { font-size: 1.05rem; }
.dm-alarms, .dm-alarm-list { list-style: none; padding: 0; margin: .8rem 0 0; }
.dm-alarm { font-size: .82rem; padding: .4rem .6rem; border-radius: .35rem; margin-bottom: .3rem; background: var(--re-surface-2); border-left: 3px solid var(--re-border); display: flex; justify-content: space-between; gap: .75rem; }
.dm-alarm small { color: var(--re-muted); white-space: nowrap; }
.dm-alarm-critical { border-left-color: #ff4d5a; } .dm-alarm-warning { border-left-color: #f5c542; }
.dm-alarm-none { color: var(--re-muted); }

/* Details table */
.dm-table-wrap { overflow-x: auto; border: 1px solid var(--re-border); border-radius: .6rem; }
.dm-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: .88rem; }
.dm-table th { background: var(--re-surface); text-align: left; padding: .65rem .75rem; cursor: pointer; white-space: nowrap; color: var(--re-muted); font-weight: 600; user-select: none; }
.dm-table th:hover { color: #fff; }
.dm-table td { padding: .55rem .75rem; border-top: 1px solid var(--re-border); }
.dm-table small { color: var(--re-muted); }
.dm-badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; color: var(--c); border: 1px solid var(--c); }
.dm-row-down td:first-child { box-shadow: inset 3px 0 #ff4d5a; }

/* TV display */
.dm-tv-stage { background: #050506; border: 1px solid var(--re-border); border-radius: .6rem; padding: 1rem; }
.dm-tv-stage:fullscreen { border: 0; border-radius: 0; padding: 1.5rem; overflow: auto; }
.dm-tv-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; align-items: baseline; margin-bottom: 1rem; }
.dm-tv-top h2 { font-size: 1.4rem; margin: 0; }
.dm-tv-top [data-tv-summary] { display: flex; flex-wrap: wrap; gap: 1.25rem; color: var(--re-muted); }
.dm-tv-top [data-tv-summary] b { color: var(--re-text); font-size: 1.2rem; }
.dm-tv-grid { display: grid; grid-template-columns: repeat(var(--tv-cols, 3), 1fr); gap: 1rem; }
.dm-tv-card { border: 2px solid var(--re-border); border-radius: .5rem; overflow: hidden; background: var(--re-surface); }
.dm-tv-head { display: flex; justify-content: space-between; align-items: center; padding: .55rem .9rem; color: #0a0a0b; font-weight: 800; }
.dm-tv-head h3 { margin: 0; font-size: 1.15rem; }
.dm-tv-body { display: flex; align-items: center; gap: 1rem; padding: 1rem; }
.dm-gauge { position: relative; width: 55%; max-width: 230px; aspect-ratio: 2 / 1.1; flex: none; }
.dm-gauge canvas { position: absolute; inset: 0; }
.dm-gauge b { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font-size: 1.7rem; }
.dm-gauge small { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; color: var(--re-muted); font-size: .72rem; }
.dm-tv-stats { margin: 0; flex: 1; display: grid; gap: .4rem; }
.dm-tv-stats dt { font-size: .7rem; color: var(--re-muted); text-transform: uppercase; font-weight: 400; }
.dm-tv-stats dd { margin: 0; font-size: 1.3rem; font-weight: 700; }
.dm-tv-title { padding: 0 1rem; font-size: .75rem; color: var(--re-muted); text-transform: uppercase; }
.dm-tv-trace { position: relative; height: 150px; padding: .25rem .75rem .75rem; }
@media (max-width: 991px) { .dm-tv-grid { grid-template-columns: 1fr; } }
@media (max-width: 575px) { .dm-fac-grid { grid-template-columns: repeat(2, 1fr); } .dm-tv-body { flex-direction: column; } .dm-gauge { width: 80%; } }

/* Process trends */
.dm-trend-box { position: relative; height: 340px; }
.dm-trend-box.tall { height: 640px; }
@media (max-width: 575px) { .dm-trend-box { height: 280px; } .dm-trend-box.tall { height: 520px; } }

/* Operator HMI */
.hm-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1rem; }
.hm-col-7 { grid-column: span 7; } .hm-col-5 { grid-column: span 5; }
@media (max-width: 991px) { .hm-col-7, .hm-col-5 { grid-column: span 12; } }
.hm-screen { background: #0d0d10; border: 1px solid var(--re-border); border-radius: .6rem; overflow: hidden; }
.hm-title { background: linear-gradient(180deg, #2b2b32, #1d1d22); padding: .55rem .9rem; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.hm-title small { color: var(--re-muted); font-weight: 400; }
.hm-body { padding: .9rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; }
.hm-box { border: 1px solid #34343c; border-radius: .35rem; overflow: hidden; background: #08080a; }
.hm-box h4 { margin: 0; padding: .3rem .6rem; font-size: .8rem; text-align: center; background: linear-gradient(180deg, #4a4a53, #2f2f36); letter-spacing: .02em; }
.hm-row { display: flex; justify-content: space-between; gap: .5rem; padding: .22rem .6rem; font-size: .82rem; border-top: 1px solid #1b1b20; }
.hm-row span { color: #b6b6c0; }
.hm-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.hm-on { color: #2ecc71; } .hm-off { color: #8a8a96; } .hm-alert { color: #ff4d5a; } .hm-warn { color: #f5c542; }
/* Cooling tank card: vessel on the left, values and setpoints on the right */
.hm-tankcard { grid-column: span 2; }
.hm-tankcard-body { display: flex; gap: .8rem; padding: .6rem; align-items: stretch; }
.hm-tank-col { width: 120px; flex: none; display: flex; flex-direction: column; }
.hm-tank-rows { flex: 1; min-width: 0; align-self: center; }
.hm-tank-rows .hm-row:first-child { border-top: 0; }
.hm-tank-mark { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed; pointer-events: none; z-index: 1; }
.hm-tank-mark-hi { border-color: #f5c542; } .hm-tank-mark-lo { border-color: #ff4d5a; }
.hm-tank-vessel { position: relative; flex: 1; min-height: 230px; border-radius: .3rem; background: #2c3a48; overflow: hidden; }
.hm-tank-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #5aa7d6, #3f86b4); transition: height 1s; }
.hm-tank-ticks { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 2px 4px; font-size: .62rem; color: #dfe9f2; pointer-events: none; }
.hm-tank-ticks span { border-top: 1px solid rgba(255,255,255,.35); }
.hm-tank-read { text-align: center; margin-top: .4rem; font-size: .85rem; font-weight: 700; }
.hm-phase { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center; padding: .6rem .8rem; border: 1px solid #34343c; border-radius: .35rem; background: #08080a; }
.hm-phase .badge-phase { padding: .15rem .7rem; border-radius: 999px; font-weight: 700; color: #0a0a0b; }

/* Control demo */
.ct-banner { border: 1px solid #ff4d5a; background: rgba(255,77,90,.12); border-radius: .5rem; padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 600; }
.ct-banner.warn { border-color: #f5c542; background: rgba(245,197,66,.1); }
.ct-banner div + div { margin-top: .2rem; }
.ct-group { margin-bottom: 1rem; }
.ct-group label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--re-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem; }
.ct-group label b { color: var(--re-text); }
.ct-seg { display: inline-flex; border: 1px solid var(--re-border); border-radius: .4rem; overflow: hidden; }
.ct-seg button { background: var(--re-surface-2); color: var(--re-muted); border: 0; padding: .45rem 1.1rem; font-weight: 600; }
.ct-seg button + button { border-left: 1px solid var(--re-border); }
.ct-seg button.on { background: var(--re-red); color: #fff; }
.ct-seg button:hover:not(.on) { color: #fff; }
.ct-controls .form-range { accent-color: var(--re-red); }
.ct-controls .form-range:disabled { opacity: .35; }
.ct-controls .form-range::-webkit-slider-thumb { background: var(--re-red); }
.ct-controls .form-range::-moz-range-thumb { background: var(--re-red); }
.ct-controls .form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 .25rem rgba(224,30,43,.3); }

/* ---- Mobile: no scrolling tab strip, no sideways table ---- */
.dm-sortbar { display: none; }
@media (max-width: 767px) {
    .dm-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; overflow: visible; border-bottom: 0; }
    .dm-tabs button { border: 1px solid var(--re-border); border-radius: .5rem; background: var(--re-surface); padding: .65rem .5rem; white-space: normal; text-align: center; font-size: .9rem; }
    .dm-tabs button:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .dm-tabs button.active { background: var(--re-red); border-color: var(--re-red); color: #fff; }

    .dm-sortbar { display: flex; gap: .5rem; align-items: center; margin-bottom: .75rem; }
    .dm-sortbar select { flex: 1; }
    .dm-table-wrap { border: 0; overflow: visible; }
    .dm-table, .dm-table tbody { display: block; min-width: 0; }
    .dm-table thead { display: none; }
    .dm-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .75rem; background: var(--re-surface); border: 1px solid var(--re-border); border-left: 3px solid var(--re-border); border-radius: .6rem; padding: .8rem .9rem; margin-bottom: .75rem; }
    .dm-table td { display: block; border: 0; padding: 0; overflow-wrap: anywhere; }
    .dm-table td::before { content: attr(data-label); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--re-muted); }
    .dm-table td:first-child { grid-column: 1 / -1; font-size: 1.1rem; font-weight: 700; }
    .dm-table td:first-child::before { display: none; }
    .dm-table td:nth-child(2), .dm-table td:nth-child(3) { display: none; } /* plant + cell are repeated in the name line below */
    .dm-table tr.dm-row-running { border-left-color: #2ecc71; } .dm-table tr.dm-row-slow { border-left-color: #f5c542; }
    .dm-table tr.dm-row-down { border-left-color: #ff4d5a; } .dm-table tr.dm-row-changeover { border-left-color: #5b8def; }
    .dm-row-down td:first-child { box-shadow: none; }
}

@media (max-width: 767px) {
    .re-page-header:has(+ #demoRoot) { padding: 1.75rem 0 1.25rem; }
    #demoRoot.re-section { padding-top: 1.25rem; }
    .dm-tabs { gap: .35rem; margin-bottom: 1rem; }
    .dm-tabs button { padding: .5rem .4rem; font-size: .85rem; }
    .dm-kpi b { font-size: 1.5rem; }
}

.ct-live { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
.ct-live div { background: var(--re-surface-2); border-radius: .4rem; padding: .5rem .6rem; }
.ct-live span { display: block; font-size: .68rem; text-transform: uppercase; color: var(--re-muted); }
.ct-live b { font-size: 1.15rem; }
@media (max-width: 575px) {
    .hm-body { grid-template-columns: 1fr 1fr; gap: .6rem; padding: .7rem; }
    .hm-row { font-size: .76rem; padding: .22rem .45rem; gap: .25rem; }
    .hm-box h4 { font-size: .74rem; }
    .hm-phase, .hm-tankcard { grid-column: 1 / -1; }
    .hm-tank-col { width: 96px; }
    .hm-tank-vessel { min-height: 200px; }
    .ct-seg button { padding: .55rem 1.2rem; }
    .ct-controls .form-range { height: 2rem; }
    .dm-panel { padding: .85rem; }
}

/* Alarm flash on the control demo values */
@keyframes ct-flash-red { 0%, 49% { color: #fff; background: #d6212e; } 50%, 100% { color: #ff6b75; background: transparent; } }
@keyframes ct-flash-amber { 0%, 49% { color: #1a1300; background: #f5c542; } 50%, 100% { color: #f5c542; background: transparent; } }
.ct-flash-red, .ct-flash-amber { border-radius: .25rem; padding: 0 .35rem; margin: 0 -.35rem; animation-duration: 1s; animation-iteration-count: infinite; animation-timing-function: steps(1, end); }
.ct-flash-red { animation-name: ct-flash-red; }
.ct-flash-amber { animation-name: ct-flash-amber; }
@media (prefers-reduced-motion: reduce) {
    .ct-flash-red, .ct-flash-amber { animation: none; }
    .ct-flash-red { color: #fff; background: #d6212e; }
    .ct-flash-amber { color: #1a1300; background: #f5c542; }
}

/* Trend zoom toolbar */
.dm-toolbar { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: center; margin-bottom: 1rem; }
.dm-trend-box canvas { touch-action: pan-y; }
.dm-trend-box.zoom-mode canvas { cursor: crosshair; }
.dm-trend-box.pan-mode canvas { cursor: grab; }
.dm-trend-box.pan-mode canvas:active { cursor: grabbing; }

/* Cooling tank level alert: flash the whole card background */
.ct-sub { margin-bottom: .7rem; }
.ct-sub > span { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--re-muted); margin-bottom: .2rem; }
.ct-sub > span b { color: var(--re-text); }
.ct-tankgroup { border: 1px solid var(--re-border); border-radius: .5rem; padding: .7rem .8rem .2rem; }
.ct-tankgroup > label { margin-bottom: .6rem; }
@keyframes ct-bg-red { 0%, 49% { background: #5a1017; } 50%, 100% { background: #08080a; } }
@keyframes ct-bg-amber { 0%, 49% { background: #4a3a06; } 50%, 100% { background: #08080a; } }
.ct-bg-flash-red, .ct-bg-flash-amber { animation-duration: 1s; animation-iteration-count: infinite; animation-timing-function: steps(1, end); }
.ct-bg-flash-red { animation-name: ct-bg-red; border-color: #ff4d5a; }
.ct-bg-flash-amber { animation-name: ct-bg-amber; border-color: #f5c542; }
@media (prefers-reduced-motion: reduce) {
    .ct-bg-flash-red, .ct-bg-flash-amber { animation: none; }
    .ct-bg-flash-red { background: #5a1017; }
    .ct-bg-flash-amber { background: #4a3a06; }
}

.ct-hint { font-size: .75rem; color: var(--re-muted); margin-top: .25rem; }
.ct-approval { border: 1px solid #f5c542; background: rgba(245,197,66,.1); border-radius: .5rem; padding: .7rem .8rem; margin-bottom: 1rem; }
.ct-approval-title { font-weight: 700; color: #f5c542; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.ct-bigtemp { font-size: 1.15rem; }
