:root,
html[data-theme="dark"] {
  --bg: #0c1117;
  --bg-elev: #121a22;
  --bg-row: #0f161e;
  --line: #243041;
  --text: #e8eef5;
  --muted: #8b9bb0;
  --accent: #3dba8c;
  --accent-dim: #2a7d5f;
  --warn: #e2a84a;
  --danger: #e06b6b;
  --ok: #3dba8c;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 6px;
  --bg-glow-1: #163028;
  --bg-glow-2: #1a2433;
  --panel-glass: rgba(12, 17, 23, 0.72);
  --panel-border: rgba(36, 48, 65, 0.9);
  --overlay: rgba(6, 10, 14, 0.72);
  --modal-bg: #141a22;
  --modal-bg-2: #1a1f27;
  --modal-line: #2a3340;
  --input-bg: #0a1016;
  --btn-fg: #062016;
  --shadow: rgba(0, 0, 0, 0.45);
  --dl-check-new: #3dba8c;
  --dl-check-done: #6b7785;
  --metric-bg: linear-gradient(180deg, rgba(18, 26, 34, 0.9), transparent);
  --metric-border: var(--line);
  --map-land: #15202b;
  --map-land-hover-stroke: #7dffc8;
}

html[data-theme="light"] {
  --bg: #e8eef3;
  --bg-elev: #f7fafc;
  --bg-row: #dfe7ee;
  --line: #c5d0db;
  --text: #152033;
  --muted: #5a6b7d;
  --accent: #1f9a6c;
  --accent-dim: #178058;
  --warn: #c4841f;
  --danger: #c94d4d;
  --ok: #1f9a6c;
  --bg-glow-1: #c5e6d6;
  --bg-glow-2: #cdd8e8;
  --panel-glass: rgba(247, 250, 252, 0.88);
  --panel-border: rgba(180, 194, 208, 0.95);
  --overlay: rgba(40, 52, 66, 0.35);
  --modal-bg: #f7fafc;
  --modal-bg-2: #ffffff;
  --modal-line: #c5d0db;
  --input-bg: #ffffff;
  --btn-fg: #062016;
  --shadow: rgba(30, 45, 60, 0.18);
  --dl-check-new: #1f9a6c;
  --dl-check-done: #8a96a3;
  --metric-bg: #ffffff;
  --metric-border: #b8c5d2;
  --map-land: #9aafc2;
  --map-land-hover-stroke: #178058;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, var(--bg-glow-2) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color-scheme: dark;
}

html[data-theme="light"],
html[data-theme="light"] body {
  color-scheme: light;
}

code, .mono { font-family: var(--mono); font-size: 0.92em; }

.hidden { display: none !important; }

.brand {
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--accent);
}

.brand-mark {
  display: inline-block;
  vertical-align: middle;
  border-radius: 5px;
  flex-shrink: 0;
}

.login-panel .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.login-screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: transparent;
  overflow: hidden;
}

.login-bg-glow {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 55% 45% at 50% 48%, rgba(255, 255, 255, 0.07) 0%, transparent 58%),
    radial-gradient(ellipse 40% 30% at 50% 55%, rgba(61, 186, 140, 0.08) 0%, transparent 60%);
  animation: login-glow 8s ease-in-out infinite;
}

.login-bg-art {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(920px, 118vw);
  height: auto;
  max-height: 92vh;
  object-fit: contain;
  transform: translate(-50%, -50%) scale(1, 1);
  transform-origin: 50% 55%;
  opacity: 0.85;
  /* PNG alpha already clears the black plate */
  mix-blend-mode: normal;
  filter: saturate(0.95) contrast(1.08) brightness(1.05);
  animation: latex-breathe 5.5s ease-in-out infinite;
  will-change: transform, filter;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}

.login-bg-art.is-dragging {
  cursor: grabbing;
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .login-bg-art,
  .login-bg-glow {
    animation: none;
  }
  .login-bg-art {
    pointer-events: none;
    cursor: default;
  }
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 1.5rem 1.4rem 1.35rem;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel-glass);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 24px 60px var(--shadow);
  animation: rise 0.45s ease both;
}

.login-panel h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lede { color: var(--muted); margin: 0 0 1.5rem; }

.login-panel label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.login-panel input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  margin-bottom: 0.85rem;
}

.login-panel input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent-dim);
  outline-offset: 2px;
}

button, .tab {
  font-family: var(--font);
  cursor: pointer;
}

.login-panel button[type="submit"],
button:not(.ghost):not(.tab):not(.linkish) {
  background: var(--accent);
  color: var(--btn-fg);
  border: 0;
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  font-weight: 600;
}

.ghost, .linkish {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.linkish {
  border: 0;
  color: var(--accent);
  padding: 0.25rem 0.4rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.linkish.danger {
  color: var(--danger);
}

.error { color: var(--danger); margin-top: 0.75rem; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-glass);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand { display: flex; align-items: center; gap: 0.5rem; }

.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius);
}

.tab.is-active {
  color: var(--text);
  background: var(--bg-elev);
}

.main {
  padding: 1.5rem 1.5rem 3rem;
  width: min(1480px, 100%);
  margin: 0 auto;
}

.view-overview .geo-map-wrap {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  min-height: min(70vh, 640px);
}

.view-overview .geo-map {
  height: min(70vh, 640px);
}

.view-overview .geo-map-legend {
  width: min(1200px, 100%);
  margin-left: auto;
  margin-right: auto;
  padding: 0 1.25rem;
}

.view { animation: rise 0.35s ease both; }

.view-head {
  margin-bottom: 1.25rem;
}

.view-head h1 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.view-head p { margin: 0; color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.metric {
  padding: 0.9rem 1rem;
  border: 1px solid transparent;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: var(--metric-bg);
  animation: rise 0.4s ease both;
  box-shadow: none;
}

html[data-theme="light"] .metric {
  border: 1px solid var(--metric-border);
  border-bottom: 2px solid var(--accent-dim);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px var(--shadow);
}

.metric.metric-wide {
  grid-column: span 2;
  min-width: 0;
}

@media (max-width: 640px) {
  .metric.metric-wide {
    grid-column: span 1;
  }
}

.metric:nth-child(2) { animation-delay: 0.05s; }
.metric:nth-child(3) { animation-delay: 0.1s; }
.metric:nth-child(4) { animation-delay: 0.15s; }
.metric:nth-child(5) { animation-delay: 0.2s; }

.metric .label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 560;
}

.metric .metric-detail {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--accent);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric .value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 500;
  margin-top: 0.25rem;
  color: var(--text);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .tabs { margin-left: 0; flex-wrap: wrap; }
  .topbar { flex-wrap: wrap; }
}

.geo-map-wrap {
  position: relative;
  width: 100%;
  margin: 0.25rem 0 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  min-height: min(62vh, 560px);
}

.geo-map {
  width: 100%;
  height: min(62vh, 560px);
}

.geo-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.geo-map path.country {
  /* empty countries: CSS fallback; has-data fill set inline by JS (choropleth) */
  fill: var(--map-land);
  stroke: transparent;
  stroke-width: 0;
  transition: fill 0.12s ease, stroke 0.12s ease, filter 0.12s ease;
  cursor: default;
}

.geo-map path.country.has-data {
  cursor: pointer;
  filter: drop-shadow(0 0 3px rgba(61, 186, 140, 0.2));
}

.geo-map path.country.is-hover {
  stroke: var(--map-land-hover-stroke);
  stroke-width: 1.1;
  filter: drop-shadow(0 0 10px rgba(61, 186, 140, 0.9));
}

.geo-map-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  min-width: 72px;
  text-align: center;
}

.geo-map-tip .tip-count {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.1;
}

.geo-map-tip .tip-name {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.geo-map-legend {
  margin: 0.35rem 0 1.25rem;
}

.overview-below {
  margin-top: 0.5rem;
}

h2 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.75rem;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

#view-backups table,
#view-machine table {
  min-width: 1280px;
  table-layout: fixed;
}

#view-backups th,
#view-backups td,
#view-machine th,
#view-machine td {
  white-space: nowrap;
  vertical-align: middle;
  padding: 0.55rem 0.55rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

#view-backups th.col-size,
#view-backups td.col-size,
#view-machine th.col-size,
#view-machine td.col-size {
  width: 5.5rem;
  text-align: right;
}

#view-backups th.col-dl,
#view-backups td.col-dl,
#view-machine th.col-dl,
#view-machine td.col-dl {
  width: 7.5rem;
  text-align: left;
  overflow: visible;
}

#view-backups th,
#view-machine th {
  font-size: 0.72rem;
}

th, td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr {
  background: transparent;
  transition: background 0.15s ease;
  animation: rise 0.3s ease both;
}

tbody tr:hover { background: var(--bg-row); }

.machine-link {
  color: var(--text);
  font-family: var(--mono);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

.machine-link:hover { color: var(--accent); }

.status {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  display: inline-block;
}

.status.done { color: var(--ok); background: rgba(61, 186, 140, 0.12); }
.status.failed,
.status.disabled { color: var(--danger); background: rgba(224, 107, 107, 0.12); }
.status.pending,
.status.uploading,
.status.finalizing { color: var(--warn); background: rgba(226, 168, 74, 0.12); }
.status.partial { color: var(--accent, #5b9fd4); background: rgba(91, 159, 212, 0.12); }
.status.running { color: var(--warn); background: rgba(226, 168, 74, 0.12); }

.whoami {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.35rem;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.5rem;
  max-width: 900px;
}

.account-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.account-form input,
.account-form textarea,
.account-form select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
}

.account-form textarea {
  resize: vertical;
  min-height: 5rem;
  line-height: 1.4;
}

.account-form label.full {
  grid-column: 1 / -1;
}

.relay-ops-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  max-width: 280px;
}

.relay-op-check {
  font-size: 0.8rem;
  margin: 0;
}

.relay-assigned-list {
  margin: 0.5rem 0 0.75rem;
}

.relay-domain-ul {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.relay-domain-ul li {
  color: var(--text);
}

#build-relay {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
}

.account-form button[type="submit"] {
  height: 2.4rem;
}

.build-layout {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  align-items: start;
}

@media (max-width: 960px) {
  .build-layout { grid-template-columns: 1fr; }
}

.build-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.build-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .build-row { grid-template-columns: 1fr; }
}

.build-form label,
.build-form .full {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.build-form input,
.build-form textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.build-form textarea { resize: vertical; min-height: 4.5rem; }

.build-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0;
}

.build-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.build-fieldset .hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.check {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
  color: var(--text) !important;
  font-size: 0.9rem !important;
  cursor: pointer;
}

.check input { width: auto; }

.build-form button[type="submit"] {
  align-self: start;
  background: var(--accent);
  color: var(--btn-fg);
  border: 0;
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.build-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.build-format-block { margin-top: 0.25rem; }

.build-format-table table { font-size: 0.9rem; }
.build-format-table tbody tr { cursor: pointer; }
.build-format-table tbody tr:hover { background: rgba(61, 186, 140, 0.06); }
.build-format-table input[type="radio"] { width: auto; margin: 0; cursor: pointer; }
.build-format-table td:first-child { width: 2.2rem; text-align: center; }

.build-collect-bar {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

.build-collect-bar .hint { margin: 0; }

.collect-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.collect-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(10px);
}

.collect-modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--modal-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 80px var(--shadow);
  animation: rise 0.25s ease both;
}

.collect-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.collect-modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.collect-modal-body {
  overflow: auto;
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.collect-all-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent, #3d8b6e) 12%, var(--panel, #1a1d24));
}

.collect-all-toggle strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
}

.collect-all-toggle .hint {
  display: block;
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.collect-modal-body.collect-all-on #build-max-backup-mb {
  opacity: 0.55;
}

.collect-modal-body label.full,
.collect-modal-body .build-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.collect-modal-body input[type="number"],
.collect-modal-body input[type="text"],
.collect-modal-body textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.collect-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--line);
}

.collect-modal-foot #save-collect-modal {
  background: var(--accent);
  color: var(--btn-fg);
  border: 0;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.process-card {
  border-top: 2px solid var(--line);
  padding: 0.5rem 0 0;
  animation: rise 0.35s ease both;
}

.process-card h2 {
  margin-bottom: 0.85rem;
}

.process-steps {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  font-size: 0.92rem;
}

.process-steps li { padding-left: 0.15rem; }

.paths-summary {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 220px;
}

.filters {
  display: flex;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.filters label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  padding-bottom: 0.35rem;
}

.filters input[type="text"] {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  font-family: var(--mono);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.pager-size select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.pager-info {
  flex: 1;
  min-width: 10rem;
}
.pager-nav {
  display: inline-flex;
  gap: 0.45rem;
}
.pager-nav button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tg-form .tg-enable-row {
  margin-bottom: 0.75rem;
}
.tg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 720px) {
  .tg-grid { grid-template-columns: 1fr; }
}
.tg-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem 0.9rem;
  margin: 0 0 0.85rem;
}
.tg-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tg-fieldset .check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0;
  color: var(--text);
  font-size: 0.92rem;
}
.tg-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: 0.45rem;
  max-height: 9rem;
  overflow: auto;
  padding: 0.35rem 0;
}
.tg-tags-list.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}
.tg-mins {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.65rem;
}
.tg-mins input {
  width: 100%;
}
.tg-form textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.4;
  resize: vertical;
}
.tg-form .full { display: block; }
.tg-vars {
  word-break: break-word;
  margin: 0.35rem 0 0.75rem;
}

.dup-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(61, 186, 140, 0.12);
  border-radius: 4px;
  vertical-align: middle;
}

.wallet-mark {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.wallet-mark .dup-badge {
  margin-left: 0;
}

.login-mark {
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  background: none !important;
  border: 0 !important;
  padding: 0 !important;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.login-mark:hover {
  text-decoration: underline;
  color: var(--accent);
}

.count-num {
  font-variant-numeric: tabular-nums;
}

.log-id {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.th-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: -0.15em;
  color: #fff;
}

.th-id { background: #f0a04b; }
.th-date { background: #8b7cf6; }
.th-date::before { content: ""; width: 0.55rem; height: 0.55rem; border: 1.5px solid #fff; border-radius: 50%; box-sizing: border-box; }
.th-build { background: #e879a9; }
.th-ip { background: #ef6b6b; }
.th-ip::before { content: ""; width: 0; height: 0; border-left: 0.28rem solid transparent; border-right: 0.28rem solid transparent; border-top: 0.4rem solid #fff; margin-top: 0.15rem; }
.th-country { background: #4db8d9; }
.th-country::before { content: ""; width: 0.55rem; height: 0.55rem; border: 1.5px solid #fff; border-radius: 50%; box-sizing: border-box; }
.th-pass { background: #4f8cff; }
.th-pass::before { content: ""; width: 0.45rem; height: 0.28rem; border: 1.5px solid #fff; border-radius: 2px; box-sizing: border-box; }
.th-cookie { background: #f0a04b; }
.th-cookie::before { content: ""; width: 0.5rem; height: 0.5rem; background: #fff; border-radius: 50%; opacity: 0.95; }
.th-wallet { background: #c9a227; }
.th-wallet::before { content: ""; width: 0.4rem; height: 0.4rem; border: 1.5px solid #fff; border-radius: 1px; box-sizing: border-box; transform: rotate(45deg); }
.th-extwal { background: #d47b3a; }
.th-extwal::before { content: ""; width: 0.42rem; height: 0.42rem; border: 1.5px solid #fff; border-radius: 50%; box-sizing: border-box; }
.th-apps { background: #6b8cae; }
.th-apps::before { content: ""; width: 0.5rem; height: 0.35rem; border: 1.5px solid #fff; border-radius: 1px; box-sizing: border-box; }
.th-files { background: #8a7a5c; }
.th-files::before { content: ""; width: 0.38rem; height: 0.48rem; border: 1.5px solid #fff; border-radius: 1px; box-sizing: border-box; }
.th-status { background: #3dba8c; }
.th-status::before { content: ""; width: 0.45rem; height: 0.45rem; border: 1.5px solid #fff; border-radius: 2px; box-sizing: border-box; }
.th-size { background: #7a8a9a; }
.th-size::before { content: ""; width: 0.5rem; height: 0.38rem; border: 1.5px solid #fff; border-radius: 1px; box-sizing: border-box; }

code.build-zip-pass {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.85em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ok, #3dba8c);
  user-select: all;
  cursor: text;
}

.country-cell {
  gap: 0.35rem;
}

tr.job-downloaded {
  opacity: 0.55;
}
tr.job-downloaded:hover {
  opacity: 0.85;
}
.dl-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  min-width: 6.5rem;
  vertical-align: middle;
}

td.col-dl,
td.col-actions {
  width: 8.5rem;
  white-space: nowrap;
  vertical-align: middle !important;
  overflow: visible;
}

#view-exports table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}

#view-exports th,
#view-exports td {
  white-space: nowrap;
  vertical-align: middle;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

#view-exports td.col-actions {
  width: 9rem;
}

#view-exports .hint {
  white-space: normal;
  max-width: 18rem;
}
.dl-check {
  display: inline-flex;
  align-items: center;
  cursor: default;
  user-select: none;
  line-height: 0;
}
.dl-check-svg {
  display: block;
}
.dl-check-new {
  color: var(--dl-check-new);
  opacity: 1;
}
.dl-check-done {
  color: var(--dl-check-done);
  opacity: 0.85;
}

.theme-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
  cursor: pointer;
  user-select: none;
}
.theme-switch-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.theme-switch-copy strong {
  font-weight: 560;
  color: var(--text);
}
.theme-switch-copy .hint {
  margin: 0;
}
.theme-switch {
  position: relative;
  flex-shrink: 0;
}
.theme-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.theme-switch-track {
  display: block;
  width: 2.6rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--line);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.theme-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.4rem - 6px);
  height: calc(1.4rem - 6px);
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform 0.18s ease, background 0.18s ease;
}
.theme-switch input:checked + .theme-switch-track {
  background: var(--accent);
  border-color: var(--accent-dim);
}
.theme-switch input:checked + .theme-switch-track .theme-switch-knob {
  transform: translateX(1.2rem);
  background: #fff;
}
.theme-switch input:focus-visible + .theme-switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.secrets-panel {
  max-width: min(960px, 96vw);
  width: 960px;
}

.secrets-table-wrap {
  max-height: min(50vh, 420px);
  overflow: auto;
}

.secrets-table td.secrets-url {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secrets-table td.secrets-pw {
  max-width: 200px;
  word-break: break-all;
}

.secrets-autofill {
  margin-top: 1rem;
}

.wallet-float {
  position: fixed;
  z-index: 1000;
  min-width: 150px;
  max-width: 260px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-elev);
  box-shadow: 0 10px 28px var(--shadow);
  pointer-events: none;
}

.wallet-float.hidden {
  display: none !important;
}

.wallet-pop-title {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.wallet-float ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wallet-float li {
  font-size: 0.88rem;
  color: var(--text);
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(36, 48, 65, 0.65);
}

.wallet-float li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.geo-cell {
  display: inline-block;
  line-height: 1.35;
}

.geo-flag-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.geo-flag-img {
  width: 16px;
  height: 12px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: var(--input-bg);
}

.geo-flag {
  font-size: 1.15rem;
  line-height: 1;
}

.geo-code {
  font-weight: 500;
  letter-spacing: 0.04em;
}

.geo-ip {
  color: var(--muted);
  font-size: 0.8em;
  margin-top: 0.1rem;
}

.dup-panel {
  margin-top: 1.5rem;
}

.dup-panel h2 {
  margin-bottom: 0.25rem;
}

.dup-set {
  margin: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

.dup-set summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  list-style: none;
}

.dup-set summary::-webkit-details-marker {
  display: none;
}

.dup-set .table-wrap {
  margin-top: 0.5rem;
}

select {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  font-family: var(--mono);
}


.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  max-width: min(360px, calc(100vw - 2rem));
  z-index: 50;
  animation: rise 0.25s ease both;
}

.toast.is-error { border-color: var(--danger); }

/* —— PIN lock —— */
body.is-pin-locked #shell {
  filter: blur(28px) brightness(0.35) saturate(0.4);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

body.is-pin-locked #shell .main,
body.is-pin-locked #shell .topbar {
  visibility: hidden;
}

.pin-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--overlay);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.pin-lock-modal {
  width: min(400px, 100%);
  background: var(--modal-bg-2);
  border: 1px solid var(--modal-line);
  border-radius: 18px;
  padding: 1.35rem 1.5rem 1.75rem;
  box-shadow: 0 24px 80px var(--shadow);
  animation: rise 0.3s ease both;
}

.pin-lock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.pin-lock-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.pin-lock-lede {
  margin: 0 0 1.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pin-digits {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.pin-digit {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--input-bg);
  color: var(--text);
  font-size: 1.4rem;
  text-align: center;
  font-family: var(--mono);
  outline: none;
  caret-color: transparent;
}

.pin-digit:focus,
.pin-digit.is-active {
  border-color: var(--warn);
}

.pin-lock-modal .error {
  text-align: center;
  margin: 1rem 0 0;
}

.settings-card {
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
}

.settings-card-wide {
  max-width: 960px;
}

.settings-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.settings-card .hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.1rem;
}

.cred-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cred-list > div {
  display: grid;
  gap: 0.25rem;
}

.cred-list dt {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cred-list dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cred-list code {
  font-family: var(--mono);
  font-size: 0.95rem;
  word-break: break-all;
}

.cred-copy {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
}

.cred-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-settings-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.pin-settings-form input {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: 0.2em;
}

.pin-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.pin-settings-actions button[type="submit"] {
  background: var(--accent);
  color: var(--btn-fg);
  border: 0;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.pin-lock-btn { margin-right: 0.35rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Organic latex stretch — slightly uneven X/Y for rubber feel, seamless loop */
@keyframes latex-breathe {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1, 1) rotate(0deg);
    filter: saturate(0.9) contrast(1.12) brightness(1.05);
  }
  35% {
    transform: translate(-50%, -50.4%) scale(1.045, 0.965) rotate(0.3deg);
    filter: saturate(0.95) contrast(1.14) brightness(1.12);
  }
  70% {
    transform: translate(-50%, -49.6%) scale(0.97, 1.03) rotate(-0.25deg);
    filter: saturate(0.88) contrast(1.1) brightness(0.98);
  }
}

@keyframes login-glow {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

html[data-theme="light"] .metric .label {
  color: #3d4f63;
}

html[data-theme="light"] .geo-map path.country.has-data {
  filter: none;
}

html[data-theme="light"] .geo-map path.country.is-hover {
  filter: none;
}

html[data-theme="light"] .login-bg-art {
  opacity: 0.55;
  filter: saturate(0.85) contrast(1.02) brightness(1.15);
}

html[data-theme="light"] .login-bg-glow {
  opacity: 0.55;
}

html[data-theme="light"] body.is-pin-locked #shell {
  filter: blur(22px) brightness(0.85) saturate(0.7);
}
