/* ----------- reset / base ----------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
               Ubuntu, Cantarell, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
.center { text-align: center; }
.pad    { padding: 1rem; }
.mono   { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  cursor: pointer; border: 0; border-radius: 6px;
  padding: 0.55rem 1.1rem; font: inherit;
  background: #2563eb; color: white;
  transition: background-color 0.15s;
}
button:hover  { background: #1d4ed8; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.ghost {
  background: transparent; color: #cbd5e1; border: 1px solid #334155;
}
button.ghost:hover { background: #1e293b; }
button.small { padding: 0.25rem 0.55rem; font-size: 13px; }

.btn-link {
  display: inline-block; padding: 0.25rem 0.6rem;
  border-radius: 5px; background: #2563eb; color: white;
  font-size: 13px;
}
.btn-link:hover { background: #1d4ed8; text-decoration: none; }

input, select {
  padding: 0.45rem 0.7rem; border-radius: 6px;
  border: 1px solid #334155; background: #0f172a; color: #e2e8f0; font: inherit;
}
input:focus, select:focus { outline: none; border-color: #2563eb; }

.muted { color: #94a3b8; }
.error { color: #f87171; }
.warn  { color: #facc15; }

/* ----------- login ----------- */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.login-card {
  width: 100%; max-width: 360px;
  background: #1e293b; border: 1px solid #334155;
  border-radius: 12px; padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-card p { margin: 0 0 1.5rem; }
.login-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: #cbd5e1; }
.login-card input { display: block; width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.8rem; }
.login-card button { width: 100%; padding: 0.7rem; }

/* ----------- service picker landing ----------- */
.picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.5rem;
  background: #1e293b; border-bottom: 1px solid #334155;
}
.picker-shell .container h1 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.picker-shell .container > p { margin-bottom: 1.5rem; }

.service-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.service-card {
  background: #1e293b; border: 1px solid #334155;
  border-radius: 10px; padding: 1.25rem;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background-color 0.1s;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.service-card:hover {
  background: #243248; border-color: #475569;
  transform: translateY(-1px);
}
.service-card h3 {
  margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem;
}
.service-card .desc {
  color: #94a3b8; font-size: 13px; min-height: 2em;
}
.service-card .meta {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 12px; color: #94a3b8; flex-wrap: wrap;
}
.service-card .layout-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  background: #334155; color: #cbd5e1;
}
.service-card .layout-badge.tree    { background: #134e4a; color: #99f6e4; }
.service-card .layout-badge.date-hour { background: #1e3a8a; color: #bfdbfe; }
.service-card .ns-badge {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: #94a3b8;
}
.service-card.is-self { border-color: #3b82f6; }

/* ----------- explorer top bar ----------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem 1.5rem;
  background: #1e293b; border-bottom: 1px solid #334155;
  flex-wrap: wrap;
}
.brand {
  font-weight: 600; font-size: 1.05rem;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 0.55rem;
}
.brand-pod {
  font-weight: 500;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  background: #182338;
  border-color: #334155;
  color: #cbd5e1;
}
.brand-pod .dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: #22c55e;
  margin-right: 5px; box-shadow: 0 0 6px rgba(34,197,94,0.7);
}

.service-indicator {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: #182338; border: 1px solid #334155;
  border-radius: 999px;
  font-size: 13px;
  flex-shrink: 0;
}
.service-indicator #current-service { color: #f1f5f9; font-weight: 500; }
.service-indicator button { padding: 0.1rem 0.4rem; }

.search-form {
  flex: 1; display: flex; gap: 0.5rem; align-items: center;
  max-width: 600px; min-width: 0;
}
.search-form input { flex: 1; min-width: 0; }

.info {
  position: relative; cursor: help;
  color: #94a3b8; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid #334155; background: #182338;
}
.info:hover { color: #e2e8f0; border-color: #475569; }
.info-tooltip {
  position: absolute; top: calc(100% + 8px); left: 50%;
  transform: translateX(-60%);
  width: 320px; padding: 0.7rem 0.9rem;
  background: #0b1222; border: 1px solid #334155; border-radius: 8px;
  font-size: 12.5px; color: #cbd5e1; line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5); z-index: 50;
  visibility: hidden; opacity: 0;
  transition: opacity 0.12s; text-align: left;
}
.info-tooltip ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.info-tooltip strong { color: #e2e8f0; }
.info:hover .info-tooltip,
.info:focus .info-tooltip { visibility: visible; opacity: 1; }

.user {
  display: flex; align-items: center; gap: 0.8rem;
  margin-left: auto; flex-shrink: 0;
}
.pod-pick {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px; line-height: 1; text-transform: uppercase; letter-spacing: 0.05em;
}
.pod-pick select { padding: 0.25rem 0.5rem; font-size: 13px; }

/* ----------- container / breadcrumbs ----------- */
.container { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }

.breadcrumb-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; margin-bottom: 1rem;
}
.breadcrumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  font-size: 0.95rem; flex: 1;
}
.breadcrumbs .crumb { color: #cbd5e1; cursor: pointer; }
.breadcrumbs .crumb:hover { color: #60a5fa; }
.breadcrumbs .crumb.current { color: #94a3b8; cursor: default; }
.breadcrumbs .sep { color: #64748b; }

.disk-banner {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #1e293b; border: 1px solid #334155;
  display: flex; align-items: center; gap: 0.75rem;
}

.trace-banner {
  margin-bottom: 1rem; padding: 0.6rem 1rem;
  border-radius: 8px;
  background: #4c1d95; border: 1px solid #7c3aed;
  color: #ddd6fe;
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  font-size: 13px;
}
.trace-banner code {
  background: #2e1065; color: #ede9fe; padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.trace-banner #trace-summary { font-size: 12px; }
.trace-banner #trace-exit { margin-left: auto; }

/* Live + Tail toggles. The dot pulses while streaming. */
.live-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #ef4444; margin-right: 5px;
  vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: live-pulse 1.4s infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70%  { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
button.live-active {
  background: #b91c1c; color: white; border-color: #ef4444;
}
button.live-active:hover { background: #991b1b; }

.entries li.entry-new {
  animation: row-flash 2.2s ease-out;
}
@keyframes row-flash {
  0%   { background: #14532d; }
  100% { background: transparent; }
}

/* Saved views dropdown */
.saved-views-wrap { position: relative; }
.saved-views-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 280px; max-height: 360px; overflow-y: auto;
  background: #0b1222; border: 1px solid #334155; border-radius: 8px;
  z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.saved-views-menu ul { list-style: none; margin: 0; padding: 0.3rem 0; }
.saved-views-menu li {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.7rem; cursor: pointer; font-size: 13px;
}
.saved-views-menu li:hover { background: #1e293b; }
.saved-views-menu li .name { flex: 1; min-width: 0; word-break: break-all; }
.saved-views-menu li .delete {
  color: #94a3b8; cursor: pointer;
  padding: 1px 5px; border-radius: 3px;
}
.saved-views-menu li .delete:hover { color: #f87171; background: #1e293b; }
.saved-views-menu .save-current {
  border-top: 1px solid #334155;
  padding: 0.55rem 0.7rem; cursor: pointer; color: #93c5fd; font-size: 13px;
}
.saved-views-menu .save-current:hover { background: #1e293b; color: #bfdbfe; }
.saved-views-menu .empty { padding: 0.7rem; color: #94a3b8; font-size: 12px; }

/* Trace timeline rendering reuses .entries but with a wider name column. */
.entries li.trace-row {
  grid-template-columns: 130px minmax(0, 1fr) 110px 180px 160px;
}
.entries-head.trace { grid-template-columns: 130px minmax(0, 1fr) 110px 180px 160px; }
.service-tag {
  display: inline-block;
  padding: 1px 8px; border-radius: 4px; font-size: 11px;
  background: #1e3a8a; color: #bfdbfe; border: 1px solid #1d4ed8;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.service-tag.serving { background: #14532d; color: #bbf7d0; border-color: #166534; }
.service-tag.self { background: #312e81; color: #c7d2fe; border-color: #4338ca; }

/* Tail mode in viewer */
.viewer-body.tailing pre.code {
  white-space: pre-wrap;
  word-break: break-all;
}
.disk-bar { flex: 1; height: 8px; background: #0f172a; border-radius: 4px; overflow: hidden; }
.disk-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #22c55e, #facc15 70%, #ef4444);
}
.disk-text { white-space: nowrap; color: #cbd5e1; font-size: 0.85rem; }

/* ----------- panel ----------- */
.panel {
  background: #1e293b; border: 1px solid #334155;
  border-radius: 10px; overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #334155;
}
.panel-header h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.panel-controls {
  display: flex; align-items: center; gap: 0.5rem; margin-left: auto;
}
.panel-controls input[type="text"] { padding: 0.3rem 0.55rem; font-size: 13px; }
.panel-controls #filter-input { width: 200px; }
.panel-controls #ext-input    { width: 140px; }
.back-btn { padding: 0.3rem 0.6rem; }

.loading { padding: 2rem; text-align: center; color: #94a3b8; }

/* ----------- table-like rows + sortable headers ----------- */
.entries-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 180px 160px;
  gap: 1rem;
  padding: 0.55rem 1rem;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: #94a3b8;
  background: #182338; border-bottom: 1px solid #334155;
}
.entries-head .col {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 4px;
}
.entries-head .col:hover { color: #e2e8f0; }
.entries-head .col.active { color: #f1f5f9; }
.entries-head .col .arrow { font-size: 10px; opacity: 0.7; }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 180px 160px;
  gap: 1rem; align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #1e293b;
  cursor: pointer;
  transition: background-color 0.1s;
}
.entries li:last-child { border-bottom: 0; }
.entries li:hover { background: #243248; }
.entries li.file { cursor: default; }
.entries li.file:hover { background: #1e293b; }

.col-name { min-width: 0; word-break: break-all; font-weight: 500; }
.col-meta { color: #cbd5e1; font-size: 13px; white-space: nowrap; }
.col-meta.muted { color: #94a3b8; }
.col-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

.kind-icon {
  display: inline-block; margin-right: 0.4rem; width: 16px;
  text-align: center; opacity: 0.85;
}
.ext-pill {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  padding: 0.05rem 0.35rem;
  background: #182338; border: 1px solid #334155;
  border-radius: 3px;
  color: #cbd5e1;
  margin-right: 0.4rem;
  text-transform: lowercase;
}

.snippet {
  display: block; margin-top: 0.3rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: #cbd5e1;
  background: #0f172a; padding: 0.4rem 0.6rem;
  border-radius: 4px; word-break: break-all; white-space: pre-wrap;
}
.snippet mark { background: #facc15; color: #0f172a; padding: 0 1px; border-radius: 2px; }

.pod-pill {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  font-size: 11px;
  border-radius: 4px;
  background: #1e293b; color: #94a3b8; border: 1px solid #334155;
  margin-right: 0.4rem;
}

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid #334155;
}

@media (max-width: 720px) {
  .entries-head, .entries li { grid-template-columns: 1fr auto; }
  .entries-head .col-count, .entries-head .col-size, .entries-head .col-mtime,
  .entries li > .col-meta:not(.col-name-meta) { display: none; }
}

/* ----------- viewer modal ----------- */
.viewer {
  position: fixed; inset: 0;
  background: rgba(8, 12, 24, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; z-index: 100;
}
.viewer-shell {
  width: 100%; max-width: 1200px; height: 100%;
  background: #1e293b; border: 1px solid #334155;
  border-radius: 10px; display: flex; flex-direction: column; overflow: hidden;
}
.viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 1rem;
  border-bottom: 1px solid #334155; background: #182338;
}
.viewer-title { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.viewer-title #viewer-name {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; word-break: break-all;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: #334155; color: #e2e8f0;
}
.badge.json { background: #14532d; color: #bbf7d0; }
.badge.xml  { background: #4c1d95; color: #ddd6fe; }
.badge.html { background: #7c2d12; color: #fed7aa; }
.badge.text { background: #334155; color: #e2e8f0; }

.viewer-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.viewer-actions input { width: 200px; padding: 0.3rem 0.55rem; font-size: 13px; }
.viewer-meta {
  padding: 0.4rem 1rem;
  border-bottom: 1px solid #1e293b; background: #182338;
  font-size: 12px; display: flex; gap: 1rem; flex-wrap: wrap;
}
.viewer-body { flex: 1; overflow: auto; background: #0f172a; }
pre.code {
  margin: 0; padding: 1rem 1.25rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; color: #e2e8f0;
  white-space: pre; tab-size: 2;
}
pre.code mark {
  background: #facc15; color: #0f172a;
  padding: 0 1px; border-radius: 2px;
}
pre.code mark.active {
  background: #f97316; color: #fff;
  outline: 2px solid #fb923c;
}

/* Syntax highlighting */
.tk-key       { color: #93c5fd; }
.tk-string    { color: #86efac; }
.tk-num       { color: #fcd34d; }
.tk-bool      { color: #f97316; }
.tk-null      { color: #94a3b8; font-style: italic; }
.tk-punct     { color: #cbd5e1; }
.tk-tag       { color: #f472b6; }
.tk-attr      { color: #fcd34d; }
.tk-attr-val  { color: #86efac; }
.tk-comment   { color: #64748b; font-style: italic; }
