/* ── v3 app components (loaded after styles.css) ───────────────────────── */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.placeholder, .empty-line { color: var(--faint); padding: 18px 4px; list-style: none; }
.live.off { color: var(--faint); background: var(--surface-2); }
.live.off i { background: var(--faint); animation: none; }
.cc.sm { min-width: 22px; height: 15px; font-size: 9px; margin: 0 3px 0 0; --c: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: inherit; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.busy::after { content: ""; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06120f; border: 0; font-weight: 600; }
.btn-danger { background: var(--err); color: #fff; border: 0; font-weight: 600; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--err); }
.btn.wide { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.btn.more { margin: 14px auto 0; display: flex; }
@keyframes spin { to { transform: rotate(360deg); } }

/* dropdown menus */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; padding: 6px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-2); box-shadow: 0 12px 40px rgba(0, 0, 0, .35); display: flex; flex-direction: column; }
.menu-pop button, .menu-pop a { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--err); }
.user { cursor: pointer; }

/* alerts, chips, badges */
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.alert.err { background: rgba(248, 113, 113, .1); color: var(--err); border: 1px solid rgba(248, 113, 113, .25); }
.chip.bad { color: var(--err); border-color: rgba(248, 113, 113, .3); }
.chip.bad i { background: var(--err); }
.badge { background: var(--surface-2); color: var(--muted); }
.badge.err { color: var(--err); background: rgba(248, 113, 113, .12); }
.badge.warn { color: var(--warn); background: rgba(251, 191, 36, .12); }
.router.is-off .rings, .router.is-off .nodes { opacity: .5; }

/* hero states */
.hero-ok { background: linear-gradient(120deg, rgba(52, 211, 153, .10), transparent 45%), var(--surface); }
.hero-err { background: linear-gradient(120deg, rgba(248, 113, 113, .14), transparent 50%), var(--surface); }
.hero-err .hero-kicker { color: var(--err); }
.hero-err .pulse { background: var(--err); animation: none; }
.hero-warn .hero-kicker { color: var(--warn); }
.hero-warn .pulse { background: var(--warn); animation: none; }
.route { color: inherit; transition: border-color .15s; }
.route:hover { border-color: var(--border-2); }
.route.off { opacity: .7; }
.route.off .route-line i { display: none; }

/* timeline extras */
.tl-gap { position: absolute; top: 4px; bottom: 4px; border-radius: 6px; background: repeating-linear-gradient(135deg, rgba(248, 113, 113, .35) 0 4px, transparent 4px 8px); }
.legend i.lg-gap { background: repeating-linear-gradient(135deg, rgba(248, 113, 113, .7) 0 2px, transparent 2px 4px); }

/* charts */
.chart { position: relative; width: 100%; min-height: 60px; }
.chart-svg { display: block; width: 100%; }
.chart-svg .gl { stroke: var(--border); stroke-dasharray: 3 4; }
.chart-svg .gt { fill: var(--faint); stroke: none; font: 10.5px var(--mono); }
.chart-svg .ann { stroke: var(--q); stroke-dasharray: 2 3; opacity: .7; }
.chart-svg .cursor { stroke: var(--border-2); }
.tip { position: absolute; top: 6px; z-index: 3; min-width: 150px; padding: 8px 10px; border-radius: 10px; background: var(--surface-solid); border: 1px solid var(--border-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: 12px; pointer-events: none; }
.tip-t { color: var(--faint); margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; }
.tip i { width: 8px; height: 8px; border-radius: 2px; }
.tip b { margin-left: auto; padding-left: 10px; font-family: var(--mono); font-weight: 500; }
.legend.toggles button { display: inline-flex; align-items: center; background: none; border: 1px solid var(--border); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.legend.toggles button.off { opacity: .4; text-decoration: line-through; }
.card > .legend { margin-bottom: 8px; }

/* nodes in router card */
.nrow { grid-template-columns: 14px minmax(0, 1fr) 90px 56px 64px 24px; }
.qbtn { width: 22px; height: 22px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--faint); cursor: pointer; opacity: 0; transition: opacity .15s; }
.nrow:hover .qbtn, .qbtn:focus-visible { opacity: 1; border-color: var(--border); }
.qbtn:hover { color: var(--q); }
@media (hover: none) { .qbtn { opacity: .7; } }

/* controls row */
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.kpis.kpis-3 { grid-template-columns: repeat(3, 1fr); }

/* availability heat strip */
.avail { display: flex; flex-direction: column; gap: 8px; }
.av-row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: center; }
.av-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-cells { display: flex; gap: 1px; height: 22px; }
.av-cells i { flex: 1; border-radius: 2px; background: var(--surface-2); }
.av-cells i.a3 { background: color-mix(in srgb, var(--ok) 70%, transparent); }
.av-cells i.a2 { background: color-mix(in srgb, var(--warn) 70%, transparent); }
.av-cells i.a1 { background: color-mix(in srgb, var(--err) 60%, transparent); }
.av-cells i.a0 { background: var(--err); }
.av-cells i.act { box-shadow: inset 0 -3px 0 var(--text); }

/* nodes matrix */
.node-cell { display: flex; align-items: center; }
.node-cell small { display: block; margin-left: 0; font-family: var(--mono); font-size: 11px; }
.mx-sub { font-size: 11px; color: var(--faint); margin-top: 3px; font-family: var(--mono); }
.mx.gone { background: var(--surface-2); color: var(--faint); font-family: var(--font); font-size: 12px; }
td.mono small { display: inline; margin-left: 0; }
.t-warn { color: var(--warn); }
.insights { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.insight { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.insight.ok { box-shadow: inset 3px 0 0 var(--ok); }
.insight.warn { box-shadow: inset 3px 0 0 var(--warn); }

/* events page */
.feed-full .ev { grid-template-columns: 44px 28px 1fr; }
.ev-time { color: var(--faint); font-size: 12px; padding-top: 6px; }
.ev-day { list-style: none; padding: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.ev-day:first-child { padding-top: 0; }
.ev-day + .ev { border-top: 0; }

/* access */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* palette */
.palette { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px); display: grid; place-items: start center; padding-top: 12vh; }
.palette-box { width: min(560px, calc(100vw - 32px)); background: var(--surface-solid); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: 0 24px 80px rgba(0, 0, 0, .5); overflow: hidden; }
.palette-box input { width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: 15px var(--font); outline: none; }
.palette-box ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette-box li { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.palette-box li small { color: var(--faint); }
.palette-box li.on, .palette-box li:hover { background: var(--surface-2); }

/* dialog & forms */
.dialog { border: 1px solid var(--border-2); border-radius: 16px; padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--surface-solid); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .5); }
.dialog::backdrop { background: rgba(0, 0, 0, .5); backdrop-filter: blur(3px); }
.dialog h2 { margin: 0 0 6px; font-size: 17px; }
.dialog p:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.field input, .field select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); font: 14px var(--font); outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-error { margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: rgba(248, 113, 113, .12); color: var(--err); font-size: 13px; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { padding: 11px 14px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-2); font-size: 13px; font-weight: 500; box-shadow: inset 3px 0 0 var(--ok), 0 12px 30px rgba(0, 0, 0, .35); animation: toast-in .2s ease-out; transition: opacity .4s, transform .4s; }
.toast-err { box-shadow: inset 3px 0 0 var(--err), 0 12px 30px rgba(0, 0, 0, .35); }
.toast-warn { box-shadow: inset 3px 0 0 var(--warn), 0 12px 30px rgba(0, 0, 0, .35); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.login-card .logo { padding: 0; font-size: 18px; }
.login-card .btn { margin-top: 20px; }

@media (max-width: 900px) {
    .kpis.kpis-3 { grid-template-columns: 1fr; }
    .kpis.kpis-3 .kpi:last-child { grid-column: auto; }
    .tabbar { grid-template-columns: repeat(5, 1fr); }
    .av-row { grid-template-columns: 1fr; gap: 4px; }
    .insights { grid-template-columns: 1fr; }
    .nrow { grid-template-columns: 10px minmax(0, 1fr) 52px 58px 22px; }
    .feed-full .ev { grid-template-columns: 38px 28px 1fr; }
    .toasts { left: 16px; right: 16px; bottom: 84px; max-width: none; }
    .row-actions { justify-content: flex-start; }
}

.rings, .rings[class] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
