/* Components: glass surfaces, buttons, segmented tabs, badges, tables, forms, gauges, toasts, modal, command palette. */

/* Glass card */
.card {
  position: relative; background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 20px; backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow-soft);
}
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, var(--glass-highlight), transparent 38%); opacity: .8; }
.card > * { position: relative; }
.card + .card { margin-top: 16px; }
:is(.grid, .bento, .hero, .hero-gauges, .effort-grid, .check-grid, .flow, .ladder, .plan-cols, .dials, .choice-hero) > .card + .card, .map-layout > .card { margin-top: 0; }
.card.glow { border-color: rgba(160, 150, 255, 0.34); box-shadow: var(--glow-violet); }
.card.interactive { transition: transform .25s var(--ease), border-color .25s, box-shadow .25s; cursor: pointer; }
.card.interactive:hover { transform: translateY(-2px); border-color: var(--glass-border-strong); box-shadow: 0 18px 48px -20px rgba(143,124,255,.45); }
.card-title { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 14.5px; font-weight: 600; letter-spacing: 0.005em; margin-bottom: 12px; }
.card-title .hint { font-family: var(--font); font-weight: 400; color: var(--muted); font-size: 12px; }
.card-kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }

/* Layout helpers */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.bento { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span-3, .span-4, .span-5 { grid-column: span 6; } .span-7, .span-8 { grid-column: span 12; } }
@media (max-width: 760px) { .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; } .bento > * { grid-column: span 12 !important; } }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.prose { color: var(--text-2); line-height: 1.7; font-size: 14.5px; }
.prose p + p { margin-top: 12px; }
.prose strong { color: var(--text); font-weight: 600; }
.section-gap { margin-top: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--glass-border-strong); background: rgba(255,255,255,0.04); color: var(--text); cursor: pointer;
  font-weight: 500; font-size: 13.5px; white-space: nowrap; transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(190,195,255,0.36); color: #fff; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn.primary { border: 0; color: #0b0820; font-weight: 600; background: var(--brand); box-shadow: 0 8px 26px -10px rgba(123,139,255,.85), inset 0 1px 0 rgba(255,255,255,.35); }
.btn.primary:hover { filter: brightness(1.08); color: #05030f; box-shadow: 0 12px 34px -10px rgba(123,139,255,.95), inset 0 1px 0 rgba(255,255,255,.4); }
.btn.danger { border-color: rgba(255,107,74,.45); color: #ffb3a1; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(255,255,255,0.06); color: #fff; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.icon-btn { width: 38px; padding: 0; }

/* Segmented tabs */
.tabs { position: sticky; top: calc(var(--nav-h) + 22px); z-index: 20; display: flex; gap: 4px; padding: 5px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none;
  background: rgba(10, 13, 26, 0.7); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--glass-border); border-radius: 16px; width: fit-content; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; padding: 8px 14px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500; font-size: 13px; transition: color .2s, background .2s; }
.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active { color: #fff; background: var(--brand-soft); box-shadow: inset 0 0 0 1px rgba(160,150,255,0.3); }
.tab .dot-warn { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-left: 6px; vertical-align: middle; box-shadow: 0 0 8px var(--warn); }
.tab .new { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; padding: 1px 5px; margin-left: 6px; border-radius: 6px; background: var(--brand); color: #0b0820; vertical-align: 1px; }
@media (max-width: 920px) { .tabs { top: calc(56px + 18px); } }
.tab-panel { animation: view-in .45s var(--ease) both; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.03); color: var(--text-2); font-size: 12.5px; cursor: pointer; transition: all .2s; }
.pill:hover { border-color: var(--glass-border-strong); color: #fff; }
.pill.active { color: #fff; background: var(--brand-soft); border-color: rgba(160,150,255,0.45); }

/* Badges & status */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  border: 1px solid var(--glass-border-strong); color: var(--text-2); background: rgba(255,255,255,0.03); white-space: nowrap; }
.badge.good { color: #8ff5d8; border-color: rgba(46,230,182,.38); background: var(--good-soft); }
.badge.bad { color: #ffb09c; border-color: rgba(255,107,74,.38); background: var(--bad-soft); }
.badge.warn { color: #ffd892; border-color: rgba(255,193,94,.38); background: var(--warn-soft); }
.badge.accent { color: #d6ceff; border-color: rgba(160,150,255,.42); background: rgba(143,124,255,.14); }
.badge.info { color: #b3dcff; border-color: rgba(108,184,255,.38); background: rgba(108,184,255,.12); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--mixed); }
.status-dot.running { background: var(--cyan); box-shadow: 0 0 0 0 rgba(92,225,255,.6); animation: pulse 1.8s infinite; }
.status-dot.completed, .status-dot.ok { background: var(--good); box-shadow: 0 0 10px rgba(46,230,182,.5); }
.status-dot.partial, .status-dot.interrupted, .status-dot.skipped { background: var(--warn); }
.status-dot.failed, .status-dot.refused, .status-dot.cancelled { background: var(--bad); }
.status-dot.queued, .status-dot.pending { background: var(--faint); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(92,225,255,.55); } 70% { box-shadow: 0 0 0 9px rgba(92,225,255,0); } 100% { box-shadow: 0 0 0 0 rgba(92,225,255,0); } }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--glass-border); background: rgba(8, 10, 20, 0.45); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-family: var(--mono); font-weight: 500; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  padding: 12px 14px; border-bottom: 1px solid var(--glass-border); white-space: nowrap; background: rgba(255,255,255,0.02); }
table.data td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: top; color: var(--text-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; transition: background .15s; }
table.data tr.clickable:hover td { background: rgba(143,124,255,0.07); }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, .select { height: 42px; padding: 0 12px; width: 100%; min-width: 0; border-radius: 12px; border: 1px solid var(--glass-border-strong); background: rgba(6, 8, 18, 0.6); color: var(--text); transition: border-color .2s, box-shadow .2s; }
.select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: #0c1022; }
.input:focus, .select:focus { outline: none; border-color: rgba(160,150,255,.7); box-shadow: 0 0 0 4px rgba(143,124,255,.18); }
textarea.input { height: auto; padding: 10px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.55; resize: vertical; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 999px; background: rgba(255,255,255,.12); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255,255,255,.02); cursor: pointer; transition: border-color .2s; }
.check:hover { border-color: var(--glass-border-strong); }
.check input { margin-top: 3px; accent-color: var(--violet); }

/* Folds, traces, callouts */
details.fold { border: 1px solid var(--glass-border); border-radius: var(--radius-sm); background: rgba(255,255,255,.025); }
details.fold + details.fold { margin-top: 10px; }
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 600; font-size: 13.5px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; }
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > .fold-body { padding: 0 16px 16px; }
pre.trace { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--text-2); background: rgba(4, 6, 14, .7); border: 1px solid var(--glass-border); border-radius: 12px; padding: 14px; max-height: 440px; overflow: auto; }
.callout { border-radius: 14px; padding: 14px 16px; color: var(--text-2); background: linear-gradient(90deg, rgba(143,124,255,.14), rgba(143,124,255,.04)); border: 1px solid rgba(160,150,255,.22); }
.callout.warn { background: linear-gradient(90deg, rgba(255,193,94,.14), rgba(255,193,94,.03)); border-color: rgba(255,193,94,.28); }
.callout.bad { background: linear-gradient(90deg, rgba(255,107,74,.15), rgba(255,107,74,.03)); border-color: rgba(255,107,74,.3); }
.callout.good { background: linear-gradient(90deg, rgba(46,230,182,.13), rgba(46,230,182,.03)); border-color: rgba(46,230,182,.28); }

/* Empty / loading */
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty h3 { font-family: var(--display); color: var(--text); font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.empty p { max-width: 580px; margin: 0 auto 20px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.12); border-top-color: var(--cyan); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { border-radius: var(--radius); background: linear-gradient(100deg, rgba(255,255,255,.03) 20%, rgba(255,255,255,.08) 40%, rgba(255,255,255,.03) 60%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Mini visuals */
.meter-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.meter-value { font-family: var(--display); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.minibar { position: relative; height: 6px; min-width: 60px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.minibar > span { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; background: var(--brand); }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 6px; height: 6px; border-radius: 2px; background: rgba(255,255,255,.12); }
.pips i.on { background: var(--cyan); box-shadow: 0 0 6px rgba(92,225,255,.5); }
.progress { height: 6px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .6s var(--ease); box-shadow: 0 0 12px rgba(123,139,255,.6); }
.eid { display: inline-block; margin-left: 3px; padding: 0 6px; border-radius: 6px; font-family: var(--mono); font-size: 10.5px; line-height: 18px; color: var(--text-2); background: rgba(255,255,255,.05); border: 1px solid var(--glass-border); cursor: help; }
.eid:hover { color: #fff; border-color: rgba(160,150,255,.5); }
.dir { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.dir::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mixed); }
.dir.positive::before, .dir.improving::before { background: var(--good); box-shadow: 0 0 8px rgba(46,230,182,.6); }
.dir.negative::before, .dir.worsening::before { background: var(--bad); box-shadow: 0 0 8px rgba(255,107,74,.6); }

/* Radial gauge */
.gauge { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
.gauge svg { overflow: visible; }
.gauge .g-track { stroke: rgba(255,255,255,.08); }
.gauge .g-value { transition: stroke-dashoffset 1.3s var(--ease); }
.gauge .g-center { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; }
.gauge .g-num { font-family: var(--display); font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.gauge .g-reading { font-size: 12px; color: var(--text-2); margin-top: 6px; font-weight: 500; }
.gauge .g-label { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 12px 16px; border-radius: 14px; font-size: 13px; background: rgba(16, 20, 40, .9); backdrop-filter: var(--blur); border: 1px solid var(--glass-border-strong); box-shadow: var(--shadow); animation: toast-in .35s var(--ease); border-left: 3px solid var(--violet); }
.toast.success { border-left-color: var(--good); } .toast.error { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 920px) { #toasts { bottom: 86px; } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 3, 8, .66); backdrop-filter: blur(6px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(580px, 100%); max-height: 90vh; overflow: auto; border-radius: var(--radius-lg); background: rgba(14, 18, 36, .94); border: 1px solid var(--glass-border-strong); box-shadow: 0 40px 120px -30px rgba(0,0,0,.9), var(--glow-violet); animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { padding: 22px 24px 0; font-family: var(--display); font-size: 20px; font-weight: 600; }
.modal-body { padding: 12px 24px; color: var(--text-2); }
.modal-foot { padding: 16px 24px 22px; display: flex; justify-content: flex-end; gap: 10px; }

/* Command palette */
.cmdk-backdrop { position: fixed; inset: 0; z-index: 130; background: rgba(2, 3, 8, .6); backdrop-filter: blur(8px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; animation: fade .15s ease; }
.cmdk { width: min(640px, 100%); border-radius: 22px; overflow: hidden; background: rgba(14, 18, 36, .96); border: 1px solid var(--glass-border-strong); box-shadow: 0 40px 120px -30px rgba(0,0,0,.9), var(--glow-violet); animation: pop .25s var(--ease); }
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--glass-border); }
.cmdk-input svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }
.cmdk-input input { flex: 1; height: 58px; border: 0; outline: none; background: transparent; font-size: 16px; }
.cmdk-list { max-height: 52vh; overflow: auto; padding: 8px; }
.cmdk-group { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); padding: 10px 12px 6px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; color: var(--text-2); }
.cmdk-item .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.05); color: var(--text); font-size: 13px; flex: none; }
.cmdk-item .meta { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.cmdk-item.active { background: var(--brand-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(160,150,255,.28); }
.cmdk-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--glass-border); font-size: 11.5px; color: var(--faint); }

/* Scroll reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } .view, .tab-panel { animation: none; } }
@media print { .reveal { opacity: 1 !important; transform: none !important; } .sky, .topnav, .tabbar, .job-dock { display: none !important; } }
