/*
 * J-Log web UI. Visual language of the jiraia app: tokens in tokens.css,
 * Mulish + JetBrains Mono, 240 px sidebar, 56 px page bar with underlined
 * tabs, rounded-xl cards, shadcn-like buttons, inputs, badges and tables.
 */

@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/mulish-latin-400-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/mulish-latin-500-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/mulish-latin-600-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Mulish";
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(fonts/mulish-latin-700-normal.woff2) format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2");
}

:root {
  --font-sans: "Mulish", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --ring-50: color-mix(in srgb, var(--ring) 50%, transparent);
  --sidebar-width: 240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: var(--border);
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: var(--brand-text);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.mono,
code,
kbd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted-foreground);
}
.xs {
  font-size: 12px;
  line-height: 16px;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.icon-sm {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.spin {
  animation: spin 900ms linear infinite;
}
@keyframes spin {
  to {
    rotate: 360deg;
  }
}

/* ---------- Shell ---------- */

.shell {
  display: flex;
  height: 100dvh;
  overflow: clip;
  /* Installed app on a phone: keep clear of the notch and the gesture bar. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  transition: width var(--dur-base) var(--ease-out);
}
.sidebar-head {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 8px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--foreground);
  border-radius: var(--radius-md);
  outline: none;
}
.brand:hover {
  text-decoration: none;
}
.brand-symbol {
  width: 20px;
  height: 20px;
  /* --brand: #028f78 on the light sidebar (3:1+), #44ceb1 on the dark one. */
  color: var(--brand);
  flex-shrink: 0;
}
.brand-word {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
}
.nav-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 8px 2px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--sidebar-muted);
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  width: 100%;
  padding: 0 8px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-foreground);
  transition: background-color var(--dur-fast), color var(--dur-fast);
  outline: none;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-accent-foreground);
  text-decoration: none;
}
.nav-item:focus-visible {
  box-shadow: 0 0 0 2px var(--sidebar-ring);
}
.nav-item.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 3px;
  border-radius: 999px;
  background: var(--brand);
}
.nav-add {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-muted);
}
.nav-add:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-accent-foreground);
}
.nav-item .count {
  margin-left: auto;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 2px 6px;
  font: 700 12px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.nav-item .trail {
  margin-left: auto;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar.collapsed {
  width: 48px;
}
.sidebar.collapsed .sidebar-head {
  padding: 0 0 0 8px;
}
.sidebar.collapsed .brand,
.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .sidebar-foot .grow,
.sidebar.collapsed .sidebar-foot > :not(.keep) {
  display: none;
}
.sidebar.collapsed .sidebar-foot {
  flex-direction: column;
  padding: 12px 0 12px 8px;
  align-items: flex-start;
  margin-top: auto;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  background: var(--muted-foreground);
}
.dot.on {
  background: var(--success-border);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success-border) 20%, transparent);
}
.dot.off {
  background: var(--disabled-foreground);
}

.main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: clip;
}

/* Page bar: like the jiraia project bar (56 px, card background). */
.pagebar {
  display: flex;
  align-items: stretch;
  gap: 24px;
  height: 56px;
  padding: 0 16px;
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.pagebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.pagebar-title h1 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pagebar-title .key {
  font: 500 14px/20px var(--font-mono);
  color: var(--muted-foreground);
  white-space: nowrap;
}
.pagebar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.tab:hover {
  color: var(--foreground);
  text-decoration: none;
}
.tab.active {
  color: var(--foreground);
  font-weight: 600;
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--brand);
}

.content {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}
.content.flush {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h2 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
}
.page-head p {
  font-size: 14px;
  color: var(--muted-foreground);
}

/* Filter row above a table (Rastreadores) */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-bar .select {
  width: auto;
  max-width: 260px;
}
/* Long tables (Rastreadores, arquivos de um rastreador): own scrollbar,
   header stays on top. */
.table-wrap.scroll {
  max-height: max(320px, calc(100dvh - 250px));
  overflow: auto;
  overscroll-behavior: contain;
}
.more-rows {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
}
/* De [date] até [date] + quick picks */
.date-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.date-range > .icon-sm {
  color: var(--muted-foreground);
}
.date-range .input.date {
  width: auto;
  height: 32px;
  padding: 0 8px;
  color-scheme: light dark;
}
.date-range .chips {
  margin-top: 0;
  margin-left: 4px;
}
.chip.on {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--brand-text);
}
.info-hint {
  display: inline-flex;
  color: var(--muted-foreground);
  cursor: help;
}
a.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
.filter-search {
  position: relative;
  flex: 1 1 320px;
  min-width: 0;
}
.filter-search .icon-sm {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}
.filter-search .input {
  width: 100%;
  padding-left: 32px;
}

/* ---------- Primitives ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font: 500 14px/20px var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: background-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
}
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px var(--ring-50);
}
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn:has(> svg:first-child) {
  padding-left: 12px;
}
.btn.outline {
  background: var(--outline);
  color: var(--foreground);
  border-color: var(--input);
  box-shadow: var(--shadow-xs);
}
.btn.outline:hover {
  background: var(--outline-hover);
}
.btn.outline:active {
  background: var(--outline-active);
}
.btn.secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn.secondary:hover {
  background: var(--secondary-hover);
}
.btn.ghost {
  background: transparent;
  color: var(--ghost-foreground);
}
.btn.ghost:hover {
  background: var(--ghost-hover);
  color: var(--foreground);
}
.btn.destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}
.btn.sm {
  height: 32px;
  padding: 0 12px;
  gap: 6px;
}
.btn.sm:has(> svg:first-child) {
  padding-left: 10px;
}
.btn.xs {
  height: 24px;
  padding: 0 8px;
  gap: 4px;
  font-size: 12px;
}
.btn.xs .icon {
  width: 12px;
  height: 12px;
}
.btn.icon-btn {
  width: 36px;
  padding: 0;
}
.btn.icon-btn.sm {
  width: 32px;
  height: 32px;
}
.btn.icon-btn.xs {
  width: 24px;
  height: 24px;
}
.btn.mobile-menu {
  display: none;
}
.btn.on {
  background: var(--brand-subtle);
  color: var(--brand-text);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
}

.input,
.select {
  height: 36px;
  width: 100%;
  min-width: 0;
  padding: 4px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  font: 400 14px/20px var(--font-sans);
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: box-shadow var(--dur-fast), border-color var(--dur-fast);
}
.dark .input,
.dark .select {
  background: color-mix(in srgb, var(--input) 30%, transparent);
}
.input::placeholder {
  color: var(--muted-foreground);
}
.input.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}
.input.sm,
.select.sm {
  height: 32px;
}
.select option {
  background: var(--popover);
  color: var(--popover-foreground);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > span {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--muted-foreground);
}
.input-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon > .icon {
  position: absolute;
  left: 10px;
  color: var(--muted-foreground);
  pointer-events: none;
}
.input-icon > .input {
  padding-left: 32px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.badge .icon {
  width: 12px;
  height: 12px;
}
.badge.success {
  border-color: color-mix(in srgb, var(--success-border) 40%, transparent);
  background: var(--success-subtle);
  color: var(--success-text);
}
.badge.warning {
  border-color: color-mix(in srgb, var(--warning-border) 40%, transparent);
  background: var(--warning-subtle);
  color: var(--warning-text);
}
.badge.info {
  border-color: color-mix(in srgb, var(--info-border) 40%, transparent);
  background: var(--info-subtle);
  color: var(--info-text);
}
.badge.danger {
  border-color: color-mix(in srgb, var(--destructive-border) 40%, transparent);
  background: var(--destructive-subtle);
  color: var(--destructive-text);
}
.badge.outline {
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}
.badge.mono {
  font-family: var(--font-mono);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.switch input {
  appearance: none;
  margin: 0;
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--input);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  outline: none;
  transition: background-color var(--dur-fast);
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--background);
  box-shadow: var(--shadow-sm);
  transition: translate var(--dur-fast);
}
.dark .switch input::after {
  background: var(--foreground);
}
.switch input:checked {
  background: var(--primary);
}
.switch input:checked::after {
  translate: 16px 0;
}
.dark .switch input:checked::after {
  background: var(--primary-foreground);
}
.switch input:focus-visible {
  box-shadow: 0 0 0 3px var(--ring-50);
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 16px 16px 12px;
}
.card-head > .icon {
  color: var(--muted-foreground);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}
section > .card-title {
  margin-bottom: 8px;
}
.card-body {
  padding: 0 16px 16px;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}
.tile dt {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted-foreground);
}
.tile dd {
  margin: 0;
  font: 700 24px/32px var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.tile.warn dd {
  color: var(--warning-text);
}
.tile dd small {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  overflow: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  padding: 8px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:first-child td {
  border-top: 0;
}
.table tbody tr:hover td {
  background: color-mix(in srgb, var(--muted) 60%, transparent);
}
.table .right {
  text-align: right;
}
.table .actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}
.table tr.clickable {
  cursor: pointer;
}

.empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}
.empty .empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--muted-foreground);
  box-shadow: var(--shadow-xs);
}
.empty .empty-icon .icon {
  width: 24px;
  height: 24px;
}
.empty h2 {
  font-size: 16px;
  font-weight: 500;
}
.empty p {
  max-width: 24rem;
  color: var(--muted-foreground);
}

.loading {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  color: var(--muted-foreground);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--destructive-border) 40%, transparent);
  border-radius: var(--radius-lg);
  background: var(--destructive-subtle);
  color: var(--destructive-text);
}
.alert.success {
  border-color: color-mix(in srgb, var(--success-border) 40%, transparent);
  background: var(--success-subtle);
  color: var(--success-text);
}
.alert.info {
  border-color: color-mix(in srgb, var(--info-border) 40%, transparent);
  background: var(--info-subtle);
  color: var(--info-text);
}

kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  min-width: 20px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
}

/* Popover menu (theme). */
.menu {
  position: fixed;
  z-index: 50;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-lg);
}
.menu-label {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--muted-foreground);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover,
.menu-item:focus-visible {
  background: var(--accent);
  outline: none;
}
.menu-item .check {
  margin-left: auto;
  color: var(--muted-foreground);
}
.menu-wide {
  width: 340px;
  max-width: calc(100vw - 16px);
}
.menu-sep {
  height: 1px;
  margin: 4px -4px;
  background: var(--border);
}
.menu-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 2px 4px 2px 8px;
}
.menu-scroll {
  max-height: min(360px, 50vh);
  overflow-y: auto;
}
.menu-check {
  cursor: pointer;
}
.menu-check input {
  margin: 0;
  accent-color: var(--primary);
}
.menu-label.shortcuts {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.menu kbd {
  height: 18px;
  font-size: 11px;
}
.seg {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted-foreground);
  font: 500 12px/18px var(--font-sans);
  cursor: pointer;
}
.seg:hover {
  color: var(--foreground);
  border-color: var(--border-strong);
}
.seg.on {
  background: var(--brand-subtle);
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  color: var(--brand-text);
}
.mod-row.hidden-mod > .grow {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Dialog */
.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop {
  background: var(--backdrop);
}
.dialog-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}
.dialog-box h2 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.check input {
  margin: 3px 0 0;
  accent-color: var(--primary);
}
.stack.gap-sm {
  gap: 10px;
}
.row.wrap {
  flex-wrap: wrap;
}
.row.tight {
  gap: 2px;
}

/* Add J-Log */
.stack.narrow {
  max-width: 1100px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.form-grid .field:first-child {
  grid-column: 1 / -1;
}
.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}
.form-grid.two .field:first-child {
  grid-column: auto;
}
.setup-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step.ok > .icon {
  color: var(--success-text);
}
.step.fail {
  color: var(--destructive-text);
}
.console-box summary {
  cursor: pointer;
  color: var(--muted-foreground);
  font-size: 12px;
}
.console-out {
  margin: 8px 0 0;
  padding: 10px 12px;
  height: 220px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: var(--muted);
  font: 400 12px/18px var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--foreground);
  color: var(--background);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast.error {
  background: var(--destructive);
  color: var(--destructive-foreground);
}
@keyframes toast-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

/* ---------- Dashboard: J-Log cards ---------- */

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
  gap: 16px;
  align-items: start;
}
/* "Adicionar J-Log": last card of the J-Logs grid */
.add-card {
  align-self: stretch;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  padding: 24px;
  border-style: dashed;
  background: transparent;
  color: var(--foreground);
  text-align: center;
  text-decoration: none;
  transition: border-color var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out);
}
.add-card:hover {
  border-color: var(--brand);
  background: var(--brand-subtle);
  text-decoration: none;
}
.add-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--brand-subtle);
  color: var(--brand);
}
.device-card .card-head {
  align-items: flex-start;
  min-height: 0;
}
.device-card.offline .ports,
.device-card.offline .metrics {
  opacity: 0.7;
}
.device-card .names {
  min-width: 0;
  flex: 1;
}
.device-card .title-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  height: 20px;
}
.device-card .title-row .btn {
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.device-card:hover .title-row .btn,
.device-card .title-row .btn:focus-visible {
  opacity: 1;
}
@media (hover: none) {
  .device-card .title-row .btn {
    opacity: 1;
  }
}
.device-card .names a {
  color: var(--foreground);
  font-weight: 600;
}
.device-card .head-side {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 20px;
  flex-shrink: 0;
}
.device-card .card-foot {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 6px 8px;
}
.device-card .card-foot .btn {
  min-width: 0;
  padding: 0 6px;
  justify-content: center;
}
.device-card .names .id {
  font: 400 12px/16px var(--font-mono);
  color: var(--muted-foreground);
}
.device-card .dot {
  margin-top: 6px;
}
.nowrap {
  white-space: nowrap;
}
.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 0 16px 12px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted-foreground);
}
.metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.metric b {
  color: var(--foreground);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.metric.warn b,
.metric.warn {
  color: var(--warning-text);
}
.metric.bad b,
.metric.bad {
  color: var(--destructive-text);
}
.ports {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 8px;
  padding: 0 16px 16px;
}
.port {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 60px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--background);
  color: var(--foreground);
  transition: border-color var(--dur-fast), background-color var(--dur-fast);
}
a.port:hover {
  text-decoration: none;
  border-color: var(--brand);
  background: var(--brand-subtle);
}
.port.free {
  border-style: dashed;
  background: transparent;
  color: var(--muted-foreground);
}
.port.free .port-name {
  font-weight: 500;
}
.port.free .port-sub {
  opacity: 0.7;
}
.port-last {
  display: flex;
  gap: 6px;
  min-width: 0;
  font: 400 11.5px/16px var(--font-mono);
  color: var(--foreground-alt);
}
.port-last .ts {
  flex-shrink: 0;
  color: var(--muted-foreground);
}
.port-last.lv-e {
  color: var(--destructive-text);
}
.port-last.lv-w {
  color: var(--warning-text);
}
.port.bump {
  animation: bump 900ms var(--ease-out);
}
@keyframes bump {
  from {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
  }
}
.port-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.port-num {
  font: 600 12px/16px var(--font-sans);
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--muted-foreground);
  flex-shrink: 0;
}
.port-name {
  font-weight: 600;
  min-width: 0;
}
.port-sub .serial {
  min-width: 0;
  flex: 0 1 auto;
}
.port-sub {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted-foreground);
  min-width: 0;
}
.age {
  margin-left: auto;
  font: 600 12px/16px var(--font-sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.age.fresh {
  color: var(--success-text);
}
.age.stale {
  color: var(--warning-text);
}
.age.dead {
  color: var(--destructive-text);
}

/* ---------- Device page ---------- */

.split {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.day-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
}
.day {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  color: var(--foreground);
  font-size: 14px;
}
.day:hover {
  background: var(--accent);
  text-decoration: none;
}
.day.active {
  background: var(--brand-subtle);
  color: var(--brand-text);
  font-weight: 600;
}
.day small {
  margin-left: auto;
  font: 400 12px/16px var(--font-mono);
  color: var(--muted-foreground);
}

.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}
.kv dt {
  color: var(--muted-foreground);
}
.kv dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.grid-2.stretch {
  align-items: stretch;
}
.grid-2 {
  align-items: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.code-block {
  margin: 0;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: var(--muted);
  font: 400 12px/18px var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* J-Log page (no tabs: "Voltar" + title) */
.pagebar-sub {
  color: var(--muted-foreground);
  font-size: 14px;
  white-space: nowrap;
}
.pagebar-sub::before {
  content: "/ ";
  opacity: 0.6;
}
.back-btn {
  margin-right: 4px;
}
.tiles.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
}
.tiles.five .tile dd {
  font-size: 20px;
  line-height: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tech-details > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.tech-details > summary::-webkit-details-marker {
  display: none;
}
.tech-details:not([open]) > summary {
  padding-bottom: 16px;
}
.tech-details .chevron {
  transition: transform 0.15s;
}
.tech-details[open] .chevron {
  transform: rotate(90deg);
}
.subtle-details > summary {
  cursor: pointer;
  color: var(--muted-foreground);
  font-size: 12px;
  margin-bottom: 8px;
}

/* Commands */
.cmd-form {
  display: flex;
  gap: 8px;
}
.dest-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.dest-row .seg {
  padding: 3px 12px;
  font-size: 13px;
  line-height: 20px;
}
.dest-label {
  margin-right: 2px;
}
.cmd-hint {
  margin: 0;
}
.cmd-dest {
  flex-shrink: 0;
  padding: 0 6px;
  border-radius: var(--radius-sm, 4px);
  background: var(--muted);
  color: var(--muted-foreground);
  font: 600 11px/18px var(--font-mono);
}
.cmd-dest.tracker {
  background: var(--brand-subtle);
  color: var(--brand-text);
}
.cmd-head code.truncate {
  min-width: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground-alt);
  font: 400 12px/18px var(--font-mono);
  cursor: pointer;
}
.chip:hover {
  border-color: var(--brand);
  color: var(--brand-text);
}
.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.cmd {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}
.cmd-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.cmd-head code {
  font-weight: 500;
}
.cmd-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.cmd pre {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font: 400 12px/18px var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
}

/* ---------- Log viewer ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}
.toolbar .sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.search-box {
  display: flex;
  align-items: center;
  gap: 4px;
}
.search-box .input-icon {
  width: 260px;
}
.search-box .input {
  padding-right: 34px;
}
.regex-toggle {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  margin-left: -32px;
  margin-right: 6px;
  z-index: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.regex-toggle .icon {
  width: 14px;
  height: 14px;
}
.regex-toggle:hover {
  color: var(--foreground);
}
.regex-toggle.on {
  background: var(--brand-subtle);
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  color: var(--brand-text);
}
.match-count {
  min-width: 44px;
  text-align: center;
}
.match-count.error {
  color: var(--destructive-text);
}
.viewer-toolbar .btn.on {
  background: var(--brand-subtle);
  color: var(--brand-text);
}
.lv-chip {
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 600 12px/22px var(--font-sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.lv-chip.lv-e {
  border-color: color-mix(in srgb, var(--destructive-border) 40%, transparent);
  background: var(--destructive-subtle);
  color: var(--destructive-text);
}
.lv-chip.lv-w {
  border-color: color-mix(in srgb, var(--warning-border) 40%, transparent);
  background: var(--warning-subtle);
  color: var(--warning-text);
}
.chips-row {
  gap: 6px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.watch-chip,
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 280px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--background);
  color: var(--foreground);
  font: 500 12px/1 var(--font-sans);
  cursor: pointer;
}
.watch-chip {
  border-color: color-mix(in srgb, var(--wc) 55%, transparent);
  background: color-mix(in srgb, var(--wc) 12%, transparent);
}
.watch-chip.off {
  opacity: 0.5;
}
.watch-chip b {
  font-variant-numeric: tabular-nums;
}
.filter-chip {
  border-style: dashed;
  color: var(--muted-foreground);
}
.filter-chip:hover {
  color: var(--foreground);
  border-color: var(--border-strong);
}
.swatch {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--wc);
}
.swatches {
  display: flex;
  gap: 6px;
}
.swatch-btn {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--wc);
  cursor: pointer;
}
.swatch-btn.on {
  border-color: var(--foreground);
}
.watch-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 8px 8px;
}
.watch-form .btn {
  align-self: flex-start;
}
.lv-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lv-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--lv, var(--muted-foreground));
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.live .dot.on {
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* Colours per level, like Jnal (dark theme values from its palette). */
:root {
  --lv-e: #cf222e;
  --lv-w: #9a6700;
  --lv-i: #1a7f37;
  --lv-d: #6e7781;
  --lv-c: #bc4c00;
  --lv-m: #8250df;
  --log-tag: #0550ae;
  --log-ts: #8c959f;
  --log-slow: #bf8700;
}
.dark {
  --lv-e: #ff7b72;
  --lv-w: #e3b341;
  --lv-i: #3fb950;
  --lv-d: #7d8590;
  --lv-c: #ffa657;
  --lv-m: #d2a8ff;
  --log-tag: #79c0ff;
  --log-ts: #5c6b78;
  --log-slow: #eba53b;
}
.lv-e { --lv: var(--lv-e); }
.lv-w { --lv: var(--lv-w); }
.lv-i { --lv: var(--lv-i); }
.lv-d { --lv: var(--lv-d); }
.lv-c { --lv: var(--lv-c); }
.lv-m { --lv: var(--lv-m); }

.log-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.log {
  --log-font: 12.5px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 0 24px;
  background: var(--background);
  font: 400 var(--log-font) / 1.5 var(--font-mono);
  font-variant-numeric: tabular-nums;
  tab-size: 8;
  outline: none;
}
.log .ln {
  position: relative;
  padding: 0 22px 0 16px;
  white-space: pre;
  min-height: 1.5em;
  width: max-content;
  min-width: 100%;
}
.log.wrap .ln {
  width: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: calc(16px + 2ch);
  text-indent: -2ch;
}
.log .ln:hover {
  background: color-mix(in srgb, var(--muted) 70%, transparent);
}
.log .ts,
.log .dt {
  color: var(--log-ts);
  user-select: none;
}
.log .ts {
  margin-right: 1.5ch;
}
.log.no-ts .ts {
  display: none;
}
.log .dt {
  display: inline-block;
  min-width: 8ch;
  margin-right: 1ch;
  text-align: right;
  text-indent: 0;
}
.log .dt.slow {
  color: var(--log-slow);
}
.log .ln[class*="lv-"]:not(.lv-o):not(.cont) .tx {
  color: var(--lv);
}
.log .lvl {
  font-weight: 700;
}
.log .tick {
  color: var(--log-ts);
}
.log .tag {
  font-weight: 600;
  color: var(--log-tag);
}
.log .ln.lv-e:not(.cont):not(:has(.lvl)) .tx {
  font-weight: 600;
}
.log .ln.lv-m .tx {
  font-weight: 600;
}

/* "Destacar níveis": bands and a 3 px bar on the left, as in Jnal. */
.log.hl .ln.lv-e:not(.cont) {
  background: color-mix(in srgb, var(--lv-e) 17%, transparent);
}
.log.hl .ln.lv-w:not(.cont) {
  background: color-mix(in srgb, var(--lv-w) 12%, transparent);
}
.log.hl .ln.cont.lv-e {
  background: color-mix(in srgb, var(--lv-e) 7%, transparent);
}
.log.hl .ln.cont.lv-w {
  background: color-mix(in srgb, var(--lv-w) 5%, transparent);
}
.log.hl .ln::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--bar, transparent);
}
.log.hl .ln.lv-e { --bar: var(--lv-e); }
.log.hl .ln.lv-w { --bar: var(--lv-w); }
.log.hl .ln.lv-i { --bar: color-mix(in srgb, var(--lv-i) 45%, transparent); }
.log.hl .ln.lv-d { --bar: color-mix(in srgb, var(--lv-d) 30%, transparent); }
.log.hl .ln.lv-c { --bar: color-mix(in srgb, var(--lv-c) 55%, transparent); }
.log.hl .ln.lv-m { --bar: color-mix(in srgb, var(--lv-m) 90%, transparent); }
.log.hl .ln.cont.lv-i,
.log.hl .ln.cont.lv-d { --bar: color-mix(in srgb, var(--lv) 18%, transparent); }
.log.hl .ln.cont.lv-e,
.log.hl .ln.cont.lv-w { --bar: color-mix(in srgb, var(--lv) 50%, transparent); }
.log.hl .ln .lvl,
.log.hl .ln .tick {
  background: color-mix(in srgb, var(--lv) var(--hd, 0%), transparent);
}
.log.hl .ln .lvl {
  border-radius: 3px 0 0 3px;
}
.log.hl .ln .tick {
  border-radius: 0 3px 3px 0;
}
.log.hl .ln.lv-e { --hd: 30%; }
.log.hl .ln.lv-w { --hd: 26%; }
.log.hl .ln.lv-i { --hd: 16%; }
.log.hl .ln.lv-d { --hd: 12%; }

/* Watchers win over the level highlight. */
.log .ln.watched {
  --bar: var(--wc);
  background: color-mix(in srgb, var(--wc) 18%, transparent);
}
.log .ln.watched::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--wc);
}
.log .ln.target {
  background: var(--info-subtle);
  box-shadow: inset 3px 0 0 var(--info);
}
.log .ln.flash {
  animation: flash 1.4s var(--ease-out);
}
@keyframes flash {
  from {
    background: color-mix(in srgb, var(--info) 40%, transparent);
  }
}
.log mark {
  background: color-mix(in srgb, #e3b341 40%, transparent);
  color: inherit;
  border-radius: 2px;
}
.log mark.current {
  background: color-mix(in srgb, #eb8034 80%, transparent);
  color: #0a0a0a;
}
.log-more {
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
}
.log-ticks {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 12px;
  cursor: pointer;
  z-index: 2;
}
/* Ticks column, left of the scrollbar: keep text from running under it. */
.log-lines {
  padding-right: 12px;
}
/* Wide scrollbar with a thumb that never gets too small to grab (a long
   log has tens of thousands of lines). Chrome/Edge/Safari; Firefox keeps
   its own (thin) bar with these colours. */
.log::-webkit-scrollbar {
  width: 14px;
  height: 12px;
}
.log::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--muted-foreground) 8%, transparent);
}
.log::-webkit-scrollbar-thumb {
  min-height: 56px;
  border: 3px solid transparent;
  border-radius: 8px;
  background: color-mix(in srgb, var(--muted-foreground) 55%, transparent) padding-box;
}
.log::-webkit-scrollbar-thumb:hover,
.log::-webkit-scrollbar-thumb:active {
  background: color-mix(in srgb, var(--foreground) 70%, transparent) padding-box;
}
.log::-webkit-scrollbar-corner {
  background: transparent;
}
@supports not selector(::-webkit-scrollbar) {
  .log {
    scrollbar-color: color-mix(in srgb, var(--muted-foreground) 55%, transparent) transparent;
  }
}
.log-ticks .tick {
  position: absolute;
  right: 2px;
  width: 8px;
  height: 2px;
  border-radius: 1px;
  translate: 0 -1px;
  background: var(--muted-foreground);
}
.log-ticks .t-hit {
  background: #eb8034;
  height: 3px;
}
.log-ticks .t-err {
  background: var(--lv-e);
}
.log-ticks .t-warn {
  background: var(--lv-w);
  width: 5px;
}
.log-ticks .t-cmd {
  background: var(--lv-c);
  width: 5px;
}
.log-ticks .t-watch {
  background: var(--wc);
}
.log-notice {
  position: absolute;
  top: 40%;
  left: 50%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}
.jump {
  position: absolute;
  right: 24px;
  bottom: 20px;
  z-index: 3;
  box-shadow: var(--shadow-lg);
}
.viewer-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}
.viewer-foot .input {
  flex: 0 1 420px;
}
.tx-label {
  white-space: nowrap;
}
.tx-state {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  gap: 4px;
}

/* ---------- Search ---------- */

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 160px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.hit-file {
  margin-bottom: 12px;
}
.hit-file .card-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.hit {
  display: flex;
  gap: 12px;
  padding: 3px 12px;
  color: var(--foreground);
  font: 400 12.5px/19px var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hit:hover {
  background: var(--accent);
  text-decoration: none;
}
.hit .lno {
  flex-shrink: 0;
  min-width: 48px;
  text-align: right;
  color: var(--muted-foreground);
}
.hit mark {
  background: var(--warning-subtle);
  color: inherit;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning-border) 60%, transparent);
  border-radius: 2px;
}
.dark .hit mark {
  background: color-mix(in srgb, var(--warning) 30%, transparent);
}

/* ---------- Login ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login .card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  gap: 16px;
}
.login .brand {
  margin-bottom: 4px;
}
.login h1 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .tiles,
  .tiles.five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .search-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    translate: -100% 0;
    transition: translate var(--dur-base) var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    translate: 0 0;
  }
  .sidebar .collapse-btn {
    display: none;
  }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--backdrop);
  }
  .btn.mobile-menu {
    display: inline-flex;
  }
  .pagebar {
    gap: 8px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 0 8px;
  }
  .tabs {
    order: 3;
    width: 100%;
    height: 40px;
    overflow-x: auto;
  }
  .content {
    padding: 16px;
  }
  .device-grid,
  .ports {
    grid-template-columns: minmax(0, 1fr);
  }
  .card-foot {
    flex-wrap: wrap;
  }
  .split,
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .day-list {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
  }
  .search-form,
  .form-grid,
  .form-grid.two {
    grid-template-columns: minmax(0, 1fr);
  }
  .content {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .pagebar-title .key {
    display: none;
  }
  .pagebar-title .key + .muted {
    display: none;
  }
  .collapse-label {
    width: 32px;
    padding: 0 !important;
    font-size: 0;
    gap: 0;
  }
  .hide-mobile {
    display: none;
  }
  .tiles {
    gap: 8px;
    margin-bottom: 16px;
  }
  .tile {
    padding: 12px;
  }
  .tile dd {
    font-size: 20px;
    line-height: 28px;
  }
  .ports {
    grid-auto-rows: auto;
  }
  .port {
    min-height: 0;
  }
  .port.free {
    min-height: 0;
    padding: 6px 10px;
  }
  .port.free .port-sub {
    display: none;
  }
  .device-card .card-foot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .device-card .title-row .btn {
    opacity: 1;
  }
  .cmd-form {
    flex-wrap: wrap;
  }
  .cmd-form .select {
    flex: 1 1 100%;
  }
  .cmd-form .input {
    flex: 1;
  }
  .cmd-head {
    flex-wrap: wrap;
  }

  /* Viewer on a phone: search on its own row, icon-only tool buttons. */
  .viewer-toolbar {
    gap: 6px 8px;
    padding: 6px 8px;
  }
  .search-box {
    flex: 1 1 100%;
  }
  .search-box .input-icon {
    flex: 1;
    width: auto;
  }
  .viewer-toolbar .lbl,
  .viewer-toolbar .live-text {
    display: none;
  }
  .viewer-toolbar .sep {
    display: none;
  }
  .viewer-toolbar .switch {
    font-size: 13px;
  }
  .log {
    --log-font: 11.5px;
  }
  .log .ln {
    padding-left: 10px;
  }
  .log.wrap .ln {
    padding-left: calc(10px + 2ch);
  }
  .log .dt {
    min-width: 7ch;
  }
  .viewer-foot {
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .viewer-foot .tx-label,
  .viewer-foot > a {
    display: none;
  }
  .viewer-foot .input {
    flex: 1 1 0;
  }
  .viewer-foot .tx-state:empty {
    display: none;
  }
  .viewer-foot .tx-state {
    flex: 1 1 100%;
    order: 5;
  }
  .jump {
    right: 16px;
    bottom: 16px;
  }
  .log-ticks {
    width: 8px;
  }
  .log-ticks .tick {
    width: 6px;
    right: 1px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

.login .card > div:empty {
  display: none;
}

/* Firmware updates (firmware.js) */
.wrap-row {
  flex-wrap: wrap;
  gap: 6px;
}
.danger-text {
  color: var(--destructive-text);
}
.fw-prod {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.fw-version {
  font: 700 28px/36px var(--font-mono);
}
.fw-prod-side {
  align-items: flex-end;
}
.table th.sel,
.table td.sel {
  width: 1%;
  padding-right: 0;
}
.table td.sel input,
.table th.sel input {
  accent-color: var(--primary);
}
.table tr.selected td {
  background: var(--brand-subtle);
}
.job-link {
  color: inherit;
  text-decoration: none;
}
.job-link:hover .xs {
  color: var(--foreground);
}
.mode-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  cursor: pointer;
}
.mode-opt.on {
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
  background: var(--brand-subtle);
}
.mode-opt input {
  margin: 3px 0 0;
  accent-color: var(--primary);
}
.mode-opt .stack {
  gap: 2px;
}
.send-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  list-style: none;
}
.send-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 3px 0;
}
.send-list li.skip {
  color: var(--muted-foreground);
}
.send-list li.skip .grow {
  text-decoration: line-through;
}
.card .table-wrap.flat {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  background: transparent;
}
.fw-update {
  scroll-margin-top: 16px;
}
.fw-update > .card-body.row {
  padding-bottom: 12px;
}
.fw-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted-foreground);
}
.fw-hint > .icon {
  flex: none;
  width: 16px;
  height: 16px;
}
.fw-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.fw-drop:hover,
.fw-drop.over {
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
  background: var(--brand-subtle);
}
.fw-drop:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring-50);
}
.fw-drop:disabled {
  opacity: 0.6;
  cursor: default;
}
.fw-drop > .icon {
  flex: none;
  color: var(--muted-foreground);
}
.fw-drop .stack,
.fw-files li .stack {
  gap: 2px;
}
.fw-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.fw-files li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.fw-files li > .icon {
  flex: none;
  color: var(--muted-foreground);
}
.content.drop-over {
  outline: 2px dashed color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: -8px;
}
@media (max-width: 560px) {
  .mode-pick {
    grid-template-columns: 1fr;
  }
}
.card-foot > .btn:last-child {
  margin-left: auto;
}
