/* Portal shell, navigation, and shared data views. */

:root { --sidebar-width: 13.6rem; }

[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* -- Shell ---------------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; gap: 1.15rem;
  padding: 1.15rem .8rem .85rem; border-right: 1px solid var(--border);
  background: #111b31e6; color: var(--text); backdrop-filter: var(--frost);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0 .45rem; }
.sidebar :focus-visible { outline-color: #a6bdff; }
.sidebar-foot { margin-top: auto; padding: .8rem .45rem 0; border-top: 1px solid var(--border); }

.nav { display: flex; flex-direction: column; gap: .12rem; }
.nav-group {
  margin: .75rem 0 .25rem; padding: 0 .57rem;
  color: #a3b4d2; font-size: .62rem; font-weight: 760;
  letter-spacing: .13em; text-transform: uppercase;
}
.nav-group:first-child { margin-top: 0; }
.nav-link {
  display: flex; align-items: center; gap: .62rem;
  padding: .43rem .56rem; border: 1px solid transparent; border-radius: .47rem;
  color: #c9d5ec; font-size: .83rem; font-weight: 620; text-decoration: none;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.nav-link .icon { width: .98rem; height: .98rem; color: #a7b9dc; }
.nav-link:hover { background: #263757bf; color: #fff; }
.nav-link.is-active { border-color: #97b0ff54; background: #8b9fff2b; color: #fff; box-shadow: inset 2px 0 var(--accent); }
.nav-link.is-active .icon { color: #c2d3ff; }

.content { display: flex; flex-direction: column; min-width: 0; }
.content .topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem;
  min-height: 4rem; padding: .6rem clamp(1rem, 3vw, 2.25rem);
  border-bottom: 1px solid var(--border);
  background: #10192ce0; backdrop-filter: var(--frost);
}
.page-title { margin: 0; font-size: .95rem; font-weight: 700; letter-spacing: -.01em; }
.breadcrumb { margin-right: .32rem; color: var(--text-muted); font-weight: 560; }
.breadcrumb span { margin-left: .25rem; color: #7587a5; }
.session-state {
  display: inline-flex; align-items: center; gap: .38rem; flex: 0 0 auto;
  margin-left: auto; padding: .32rem .62rem; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted); font-size: .72rem; font-weight: 650;
}
.session-state::before { content: ''; width: .38rem; height: .38rem; border-radius: 50%; background: currentColor; }
.session-state.is-signed-in { border-color: #8ce2bb32; background: #6ad0a419; color: var(--ok); }
.nav-scrim { display: none; }

.nav-toggle {
  display: none; width: 2.5rem; height: 2.5rem; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: .5rem; background: var(--surface); color: var(--text);
}

#view { flex: 1; width: 100%; max-width: 96rem; align-self: center; padding: clamp(1rem, 3vw, 2.25rem); }
.page:not([hidden]) { animation: surface-in .25s var(--ease-out) backwards; }
.content footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: 1rem clamp(1rem, 3vw, 2.25rem);
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: .73rem;
}

.page-header { margin-bottom: 1.4rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.page-header h2 { margin-bottom: .4rem; font-size: clamp(1.65rem, 3.1vw, 2.2rem); letter-spacing: -.05em; }
.page-subtitle { margin: 0; max-width: 68ch; color: var(--text-muted); font-size: .9rem; line-height: 1.6; }
.page-intro {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .9rem;
  margin-bottom: 1.25rem; padding: 1.15rem 1.3rem; border: 1px solid var(--border); border-radius: .85rem;
  background: linear-gradient(115deg, #526bc54d, transparent 75%), var(--glass);
  backdrop-filter: var(--frost); box-shadow: var(--shadow);
}
.page-intro .page-header { margin: 0; padding: 0; border: 0; }

/* -- Cards and panels ----------------------------------------------------- */
.card-grid {
  display: grid; gap: .9rem; margin-bottom: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}
.stat-card {
  display: flex; flex-direction: column; gap: .42rem;
  padding: .9rem 1rem; border: 1px solid var(--border); border-radius: .8rem;
  background: var(--glass); backdrop-filter: var(--frost); box-shadow: var(--shadow);
}
.stat-label { color: var(--text-muted); font-size: .76rem; font-weight: 670; }
.stat-value { font-size: clamp(1.55rem, 3vw, 2.1rem); font-weight: 765; letter-spacing: -.045em; line-height: 1.08; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-detail { color: var(--text-muted); font-size: .78rem; }

.panel {
  min-width: 0; margin-bottom: 1.1rem; border: 1px solid var(--border); border-radius: .8rem;
  background: var(--glass); backdrop-filter: var(--frost); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border);
}
.panel-head h3 { margin: 0; font-size: .95rem; letter-spacing: -.02em; }
.panel-actions { margin-left: auto; display: flex; gap: .5rem; }
.panel-body { padding: 1.1rem; }
.panel-body > :last-child { margin-bottom: 0; }

/* -- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th, .data-table td { padding: .6rem .75rem; text-align: left; white-space: nowrap; }
.data-table th {
  border-bottom: 1px solid var(--border); color: var(--text-muted);
  background: var(--surface-raised); font-size: .69rem; font-weight: 750; letter-spacing: .045em; text-transform: uppercase;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table tbody tr:hover { background: #8199ff12; }
.align-right { text-align: right; }

/* -- Badges and states ---------------------------------------------------- */
.badge {
  display: inline-block; padding: .16rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 750;
}
.badge.is-ok { background: #6ad0a422; color: var(--ok); }
.badge.is-warn { background: #f4cd8e22; color: var(--warn); }
.badge.is-bad { background: #ffadc222; color: var(--bad); }
.badge.is-idle { background: #a9c1ff1a; color: var(--text-muted); }

.state-block {
  display: grid; place-items: center; gap: .7rem;
  padding: 2.25rem 1.3rem; border: 1px dashed #a9c1ff44; border-radius: .8rem; background: var(--glass);
  text-align: center;
}
.state-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .65rem; background: var(--accent-soft); color: var(--accent); font-size: 1.28rem; }
.state-message { margin: 0; max-width: 46ch; color: var(--text-muted); font-size: .88rem; line-height: 1.6; }
.state-block.is-error { border-color: rgba(255, 127, 146, .4); }
.state-block.is-error .state-message { color: var(--bad); }
.state-block.is-loading .state-icon { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -- Upload timeline ------------------------------------------------------ */
.timeline {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem;
  margin: 0; padding: .85rem clamp(1rem, 2.2vw, 1.4rem); list-style: none;
}
.timeline-step {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .1rem .45rem;
  padding: .55rem; border: 1px solid var(--border); border-radius: .55rem; background: var(--surface-raised);
  transition: background .2s ease, border-color .2s ease;
}
.timeline-dot {
  grid-row: span 2; display: grid; place-items: center; width: 1.35rem; height: 1.35rem;
  border-radius: .36rem; background: #263555; color: var(--text-muted); font: 700 .65rem ui-monospace, Consolas, monospace;
}
.timeline-label { font-size: .76rem; font-weight: 720; }
.timeline-note { font-size: .66rem; color: var(--text-muted); }
.timeline-step.is-active { border-color: #a9baff70; background: var(--accent-soft); }
.timeline-step.is-active .timeline-dot { background: var(--accent); color: #101a34; }
.timeline-step.is-done .timeline-dot { background: #6ad0a431; color: var(--ok); }
.timeline-step.is-failed { border-color: #ff7f9273; }
.timeline-step.is-failed .timeline-dot { background: #ffadc228; color: var(--bad); }
.timeline-step.is-paused .timeline-dot { background: #f4cd8e24; color: var(--warn); }

/* -- Quick actions and CSV guide ------------------------------------------ */
.quick-trigger { min-height: 2.35rem; white-space: nowrap; }
.quick-trigger .icon:first-child { color: var(--accent); }
.quick-trigger .icon:last-child { width: .8rem; height: .8rem; transition: transform .18s var(--ease-out); }
.topbar:has(.quick-menu:popover-open) .quick-trigger .icon:last-child { transform: rotate(180deg); }
.flyout {
  margin: 0; border: 1px solid #a9c1ff47; border-radius: .85rem;
  background: var(--glass-overlay); backdrop-filter: blur(20px) saturate(145%);
  color: var(--text); box-shadow: 0 18px 65px #030713b8, inset 0 1px #c8d6ff13;
}
.quick-menu { position: fixed; inset: 4.5rem clamp(1rem, 3vw, 2.25rem) auto auto; width: min(17.5rem, calc(100% - 2rem)); padding: .45rem; }
.quick-menu:popover-open { animation: surface-in .19s var(--ease-out); }
.quick-menu .eyebrow { padding: .55rem .65rem .3rem; margin: 0; }
.quick-menu a { display: flex; align-items: center; gap: .7rem; padding: .62rem .65rem; border-radius: .42rem; color: var(--text); font-size: .83rem; text-decoration: none; }
.quick-menu a:hover, .quick-menu a:focus-visible { background: var(--accent-soft); }
.quick-menu a:focus-visible { outline-offset: -2px; }
.quick-menu .icon { color: var(--accent); }
.guide-flyout { position: fixed; inset: .75rem .75rem .75rem auto; width: min(26rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 1.25rem; overflow: auto; }
.guide-flyout:popover-open { animation: drawer-in .25s var(--ease-out); }
.guide-flyout::backdrop { background: #050b1873; backdrop-filter: blur(3px); }
.flyout-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.icon-button { width: 2.35rem; min-height: 2.35rem; flex: 0 0 auto; padding: .45rem; }
.flyout-copy { color: var(--text-muted); font-size: .88rem; line-height: 1.55; }
.guide-flyout h3 { margin: 1.25rem 0 .65rem; font-size: .92rem; }
.guide-flyout .note-list { margin-bottom: 1.25rem; }
@keyframes drawer-in { from { opacity: 0; transform: translateX(22px); } }
@supports not selector(:popover-open) {
  [popover], [popovertarget] { display: none; }
}

/* -- Definition lists used by Architecture / Infrastructure --------------- */
.detail-list { display: grid; gap: .55rem; margin: 0; grid-template-columns: 11rem minmax(0, 1fr); }
.detail-list dt { color: var(--text-muted); font-size: .8rem; font-weight: 700; }
.detail-list dd { margin: 0; font-size: .86rem; line-height: 1.55; }

/* -- Responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 20; top: 0; left: 0; width: var(--sidebar-width);
    height: 100dvh; visibility: hidden; transform: translateX(-100%); transition: transform .24s var(--ease-out), visibility .24s;
  }
  .sidebar.is-open { visibility: visible; transform: translateX(0); }
  .nav-scrim { display: block; position: fixed; z-index: 15; inset: 0; border: 0; background: #060b13a8; backdrop-filter: blur(3px); animation: scrim-in .2s ease; }
  .detail-list { grid-template-columns: minmax(0, 1fr); gap: .15rem; }
  .detail-list dd { margin-bottom: .6rem; }
}
@keyframes scrim-in { from { opacity: 0; } }
@media (max-width: 540px) {
  .quick-trigger { width: 2.4rem; padding: .45rem; }
  .quick-trigger span, .quick-trigger .icon:last-child { display: none; }
}
@media (max-width: 420px) {
  .breadcrumb { display: none; }
  .timeline-step { grid-template-columns: 1fr; justify-items: start; }
  .timeline-dot { grid-row: auto; margin-bottom: .12rem; }
}

/* -- Flow diagrams -------------------------------------------------------- */
.panel-blurb { margin: 0 0 1.1rem; max-width: 72ch; color: var(--text-muted); font-size: .85rem; line-height: 1.6; }

.flow { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .25rem; }
.flow-layer { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.flow-group { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.flow-group-label {
  margin: 0; color: var(--text-muted); font-size: .66rem; font-weight: 800;
  letter-spacing: .13em; text-transform: uppercase;
}
.flow-arrow { color: #91a5d2; font-size: 1rem; line-height: 1; }

.flow-node {
  display: flex; flex-direction: column; gap: .15rem; min-width: 9.5rem;
  padding: .6rem .85rem; border: 1px solid var(--border); border-radius: .65rem;
  background: var(--surface);
  color: var(--text); text-align: left; font: inherit;
}
button.flow-node { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
button.flow-node:hover { border-color: var(--accent); transform: translateY(-1px); }
button.flow-node.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.flow-node-label { font-size: .85rem; font-weight: 700; letter-spacing: -.01em; }
.flow-node-sub { color: var(--text-muted); font-size: .73rem; line-height: 1.4; }

.flow-node.tone-accent { border-color: #a9baff60; }
.flow-node.tone-ok { border-color: #8ce2bb60; }
.flow-node.tone-bad { border-color: #ffadc260; }
.flow-node.tone-warn { border-color: #f4cd8e60; }

/* -- Zoom frame ----------------------------------------------------------- */
.zoom-frame { border: 1px solid var(--border); border-radius: .75rem; background: var(--surface-raised); }
.zoom-controls {
  display: flex; justify-content: flex-end; gap: .3rem;
  padding: .45rem .5rem; border-bottom: 1px solid var(--border);
}
.zoom-button {
  min-width: 2rem; padding: .2rem .55rem; border: 1px solid var(--border);
  border-radius: .4rem; background: transparent; color: var(--text-muted);
  font-size: .78rem; font-weight: 700;
}
.zoom-button:hover { border-color: var(--accent); color: var(--accent); }
.zoom-viewport { overflow: auto; padding: 1.1rem; }
.zoom-stage { transform-origin: top center; transition: transform .15s ease; }

/* -- Code, lists ---------------------------------------------------------- */
.inline-code {
  padding: .1rem .4rem; border: 1px solid var(--border); border-radius: .35rem;
  background: var(--surface-raised); color: #cedaff; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem;
}
.code-block {
  margin: 0; padding: .9rem 1rem; overflow-x: auto;
  border: 1px solid var(--border); border-radius: .6rem; background: var(--surface-raised);
  color: #dce5ff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.6;
}
.note-list { margin: 0; padding-left: 1.1rem; display: grid; gap: .7rem; }
.note-list li { color: var(--text-muted); font-size: .86rem; line-height: 1.6; }
.note-list strong { color: var(--text); }

/* -- Charts --------------------------------------------------------------- */
.chart-figure { position: relative; margin: 0 0 1rem; }
.chart-figure:last-child { margin-bottom: 0; }
.chart-title { margin-bottom: .6rem; color: var(--text); font-size: .85rem; font-weight: 700; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-bar { transition: opacity .15s ease; }
.chart-bar:hover { opacity: .82; }
.chart-overlay { cursor: crosshair; }

.chart-tooltip {
  position: absolute; z-index: 4; pointer-events: none;
  display: grid; gap: .1rem; padding: .45rem .6rem;
  border: 1px solid var(--border); border-radius: .45rem;
  background: var(--glass-overlay); backdrop-filter: blur(10px); box-shadow: 0 6px 18px #02061583;
  font-size: .76rem; transform: translate(.6rem, -120%); white-space: nowrap;
}
.chart-tooltip strong { color: var(--text); font-size: .78rem; }
.chart-tooltip span { color: var(--text-muted); }

.chart-legend { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: .6rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-muted); font-size: .78rem; font-weight: 600; }
.legend-swatch { width: .7rem; height: .7rem; border-radius: .2rem; flex: 0 0 auto; }

.chart-table { margin-top: .7rem; }
.chart-table summary { color: var(--text-muted); font-size: .76rem; cursor: pointer; }
.chart-table summary:hover { color: var(--accent); }
.chart-table .table-wrap { margin-top: .5rem; }

.chart-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.dashboard-activity { display: grid; align-items: start; gap: 1rem; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.dashboard-activity .panel { margin: 0; }
.dashboard-activity + .panel { margin-top: 1rem; }
.dashboard-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.storage-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; padding-top: .8rem; margin: .85rem 0 0; border-top: 1px solid var(--border); }
.storage-totals dt { color: var(--text-muted); font-size: .7rem; overflow-wrap: anywhere; }
.storage-totals dd { margin: .25rem 0 0; font-size: 1rem; font-weight: 730; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .dashboard-activity { grid-template-columns: 1fr; }
}

/* -- Pipeline components -------------------------------------------------- */
.component-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.component { padding: .85rem 1rem; border: 1px solid var(--border); border-radius: .7rem; background: var(--surface-raised); }
.component-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .4rem; }
.component-head strong { font-size: .88rem; }
.component-role { margin: 0 0 .35rem; color: var(--text-muted); font-size: .8rem; line-height: 1.5; }
.component-detail { margin: 0; color: var(--text-muted); font-size: .74rem; }
.component-service { color: var(--accent); font-weight: 650; }

/* -- Filters, chips, pager ------------------------------------------------ */
.filter-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.control {
  padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .5rem;
  background: var(--surface); color: var(--text); font-size: .85rem; min-width: min(100%, 12rem);
}
.control:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chip-row { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.chip {
  padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text-muted); font-size: .78rem; font-weight: 650;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .9rem; flex-wrap: wrap; }
.pager-status { color: var(--text-muted); font-size: .78rem; }
.pager-actions { display: flex; gap: .5rem; }

/* -- Lake browser --------------------------------------------------------- */
.browser-path { display: flex; align-items: center; gap: .6rem; margin: 0 0 .8rem; flex-wrap: wrap; }
.browser-note { margin: .6rem 0 0; color: var(--text-muted); font-size: .76rem; }
.partition-row { display: flex; align-items: center; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.partition-label { color: var(--text-muted); font-size: .72rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }

/* -- Lineage stage detail ------------------------------------------------- */
.stage-title { margin: 0 0 .3rem; font-size: 1rem; }
.stage-purpose { margin: 0 0 1rem; max-width: 72ch; color: var(--text-muted); font-size: .86rem; line-height: 1.6; }
.stage-rules { margin: 0; padding-left: 1.1rem; display: grid; gap: .25rem; }
.stage-rules li { font-size: .84rem; line-height: 1.5; }

/* -- Alarms --------------------------------------------------------------- */
.alarm-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .6rem; border: 1px solid var(--border); border-radius: .5rem; }
.alarm-name { color: var(--text-muted); font-size: .76rem; }

/* Prose columns wrap; numeric columns stay on one line for alignment. */
.data-table td.wrap, .data-table th.wrap { white-space: normal; min-width: 16rem; line-height: 1.5; }
