/* mylodb dashboard: colour tokens first, dark set under prefers-color-scheme */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e4ea;
  --border-strong: #c9ced8;
  --text: #15181e;
  --text-muted: #5b6270;
  --accent: #2b59c3;
  --accent-hover: #234ba8;
  --accent-soft: #e8eefb;
  --accent-contrast: #ffffff;
  --danger: #c22f3b;
  --danger-soft: #fdecee;
  --warning: #8a5a00;
  --warning-soft: #fff5e0;
  --success: #1d7348;
  --success-soft: #e6f5ec;
  --muted: #e6e9ee;
  --destructive: var(--danger);
  --focus: #2b59c3;
  --shadow: 0 1px 2px rgb(15 20 30 / 0.06), 0 8px 24px rgb(15 20 30 / 0.08);
  --radius: 10px;
  --radius-sm: 7px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --skeleton-band: 280px;
  --skeleton-highlight: rgb(255 255 255 / 0.7);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1d2129;
    --border: #2a2f39;
    --border-strong: #3a404c;
    --text: #e6e8ed;
    --text-muted: #9aa1af;
    --accent: #7ea3ff;
    --accent-hover: #9ab7ff;
    --accent-soft: #1c2740;
    --accent-contrast: #0b1020;
    --danger: #ff6f7a;
    --danger-soft: #3a1a1e;
    --warning: #f2c46b;
    --warning-soft: #33280f;
    --success: #5fd39a;
    --success-soft: #11291d;
    --muted: #242933;
    --focus: #7ea3ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
    --skeleton-highlight: rgb(255 255 255 / 0.06);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --border: #2a2f39;
  --border-strong: #3a404c;
  --text: #e6e8ed;
  --text-muted: #9aa1af;
  --accent: #7ea3ff;
  --accent-hover: #9ab7ff;
  --accent-soft: #1c2740;
  --accent-contrast: #0b1020;
  --danger: #ff6f7a;
  --danger-soft: #3a1a1e;
  --warning: #f2c46b;
  --warning-soft: #33280f;
  --success: #5fd39a;
  --success-soft: #11291d;
  --muted: #242933;
  --focus: #7ea3ff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
  --skeleton-highlight: rgb(255 255 255 / 0.06);
}

:root[data-theme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
}

h1 {
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  font-weight: 620;
}

h3 {
  font-size: 0.95rem;
  font-weight: 620;
}

h4 {
  font-size: 0.875rem;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

code {
  padding: 0.05em 0.35em;
  border-radius: 5px;
  corner-shape: squircle;
  background: var(--surface-2);
}

.num,
.pager-range,
td,
th {
  font-variant-numeric: tabular-nums;
}

.num {
  text-align: right;
}

.muted {
  color: var(--text-muted);
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.crumbs {
  flex: 1 1 auto;
  min-width: 0;
}

.crumbs ol {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.crumbs li {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumbs li + li::before {
  content: "/";
  margin-right: 6px;
  color: var(--border-strong);
}

.crumbs [aria-current] {
  color: var(--text);
}

.page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.view-head {
  margin-bottom: 16px;
}

.app-title {
  overflow-wrap: anywhere;
}

/* buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  corner-shape: squircle;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

.button:hover {
  text-decoration: none;
}

.button:not([aria-disabled="true"], [data-busy]):hover {
  background: var(--surface-2);
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.button-primary:not([aria-disabled="true"], [data-busy]):hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.button-danger:not([aria-disabled="true"], [data-busy]):hover {
  background: color-mix(in srgb, var(--danger) 88%, black);
}

.button-quiet {
  border-color: transparent;
  background: transparent;
}

.button-wide {
  width: 100%;
}

.button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.button[data-busy] {
  opacity: 0.75;
  cursor: progress;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  corner-shape: squircle;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* forms */

label,
.field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.field-help {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  corner-shape: squircle;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

textarea {
  resize: vertical;
}

/* tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-weight: 550;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

/* tables */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  corner-shape: squircle;
  background: var(--surface);
}

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

.table th,
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.table thead th.num,
.table td.num {
  text-align: right;
}

.table tbody tr:last-child > * {
  border-bottom: 0;
}

.table tbody th {
  font-weight: 550;
}

.row-link {
  cursor: pointer;
}

.row-link:hover > * {
  background: var(--surface-2);
}

.row-selected > * {
  background: var(--accent-soft);
}

.row-selected:hover > * {
  background: var(--accent-soft);
}

.row-new > * {
  animation: row-new 2.4s ease-out;
}

@keyframes row-new {
  from {
    background: var(--success-soft);
  }
}

.table-data td,
.table-data th {
  white-space: nowrap;
}

.cell-text {
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-id a {
  font-family: var(--mono);
  font-size: 0.85em;
}

.cell-null {
  color: var(--text-muted);
  font-style: italic;
}

.cell-json {
  font-family: var(--mono);
  font-size: 0.85em;
}

.cell-key {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.cell-error {
  color: var(--danger);
}

/* data tab */

.data-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 860px) {
  .data-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
  }

  .entity-pane {
    position: sticky;
    top: 72px;
  }
}

.entity-pane h2 {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.entity-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 859px) {
  .entity-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .entity-list a {
    white-space: nowrap;
  }
}

.entity-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  corner-shape: squircle;
  color: var(--text);
  font-size: 0.9rem;
}

.entity-list a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.entity-list a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.entity-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entity-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.rows-head {
  margin-bottom: 12px;
}

.rows-title {
  font-family: var(--mono);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.rows-title:empty {
  display: none;
}

.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
  margin-bottom: 12px;
}

.filter .field {
  min-width: 0;
}

.filter .field select {
  min-width: 140px;
  max-width: 220px;
}

.filter .field-grow {
  flex: 1 1 180px;
}

.filter-actions {
  display: flex;
  gap: 6px;
}

.filter .blocked-submit-hint {
  flex-basis: 100%;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.pager-range {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.pager-buttons {
  display: flex;
  gap: 6px;
}

/* detail drawer */

.drawer {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: drawer-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes drawer-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.drawer-titles {
  min-width: 0;
}

.drawer-titles h2 {
  font-family: var(--mono);
}

.drawer-id {
  margin-top: 2px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.drawer-body {
  padding: 4px 16px 32px;
}

.panel-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: 0;
}

.panel-section > h3 {
  margin-bottom: 10px;
}

.defs {
  display: grid;
  gap: 10px;
  margin: 0;
}

.def dt {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.def dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.value-null {
  color: var(--text-muted);
  font-style: italic;
}

.json {
  margin: 0;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  corner-shape: squircle;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre;
}

.file-block {
  display: grid;
  gap: 12px;
}

.file-swatch {
  width: 100%;
  max-height: 260px;
  border-radius: var(--radius);
  corner-shape: squircle;
}

.file-block .button {
  justify-self: start;
}

.link-group + .link-group {
  margin-top: 14px;
}

.link-group h4 {
  margin-bottom: 6px;
  font-family: var(--mono);
}

.linked-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.linked-row {
  display: flex;
  flex-direction: column;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  corner-shape: squircle;
  color: var(--text);
}

.linked-row:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.linked-label {
  font-weight: 550;
  overflow-wrap: anywhere;
}

.linked-id {
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* rules tab */

.rules-form {
  max-width: 920px;
}

.rules-text {
  min-height: 360px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  tab-size: 2;
}

.rules-problems ul {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.rules-problems li {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  corner-shape: squircle;
}

.problem-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.problem-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.rules-notice:not(:empty) {
  margin-top: 10px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* backups tab */

.section-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.backup-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.backup-progress progress {
  width: 120px;
  accent-color: var(--accent);
}

.backups-tab .notice {
  margin-bottom: 12px;
}

/* notices, empty states */

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  corner-shape: squircle;
  font-size: 0.9rem;
}

.notice p {
  flex: 1 1 260px;
}

.notice-error {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
  color: var(--text);
}

.empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 28px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  corner-shape: squircle;
  background: var(--surface);
}

.empty p {
  max-width: 560px;
  color: var(--text-muted);
}

.empty .button {
  margin-top: 6px;
}

/* sign-in */

.signin {
  max-width: 400px;
  margin: 8vh auto 0;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  corner-shape: squircle;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.signin h1 {
  margin-bottom: 20px;
  font-size: 1.35rem;
}

.signin-form {
  display: grid;
}

.signin-form .button {
  margin-top: 16px;
}

.signin-error:not(:empty) {
  margin-top: 12px;
}

.signin-form .blocked-submit-hint {
  margin-top: 8px;
}

/* toasts and dialog */

.toasts {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 20px;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  corner-shape: squircle;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toast-in 200ms cubic-bezier(0.22, 1, 0.36, 1);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.toast-success {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
}

.toast-error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  corner-shape: squircle;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgb(10 12 16 / 0.45);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dialog-close {
  margin: -8px -8px 0 0;
}

.dialog-body {
  margin-top: 8px;
  color: var(--text-muted);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.noscript {
  padding: 24px 16px;
}

@media (prefers-reduced-motion: reduce) {
  .drawer,
  .toast,
  .row-new > * {
    animation: none;
  }
}

/* ghost skeletons: one highlight sweeps every bone on the page */

.reveal {
  position: relative;
}

[data-skeleton-ghost] {
  visibility: hidden;
  user-select: none;
}

[data-skeleton-layer],
[data-skeleton-status] {
  visibility: visible;
}

[data-skeleton-layer] {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.skeleton-bone,
.skeleton-surface {
  position: absolute;
}

.skeleton-bone {
  background-color: var(--muted);
  background-image: linear-gradient(90deg, transparent, var(--skeleton-highlight), transparent);
  background-repeat: no-repeat;
  background-size: var(--skeleton-band) 100%;
  background-position: calc(-1 * var(--skeleton-band)) 0;
  animation: skeleton-sweep 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes skeleton-sweep {
  0% {
    background-position: calc(-1 * var(--bone-x, 0px) - var(--skeleton-band)) 0;
  }
  70%,
  100% {
    background-position: calc(100vw - var(--bone-x, 0px)) 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-bone {
    animation: none;
    background-image: none;
  }
}

/* blocked submit: lines from a blocked button to each unfinished field */

[data-blocked-submit] {
  --blocked-color: var(--destructive, #e11d48);
  position: relative;
}

.blocked-submit-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.blocked-submit-connectors path {
  fill: none;
  stroke: var(--blocked-color);
  stroke-width: 2;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 240ms cubic-bezier(0.4, 0, 1, 1);
}

.blocked-submit-connectors circle {
  fill: var(--blocked-color);
  opacity: 0;
  transition: opacity 120ms ease;
}

.blocked-submit-connectors [data-active="true"] path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 320ms cubic-bezier(0, 0, 0.2, 1);

  @starting-style {
    stroke-dashoffset: 1;
  }
}

.blocked-submit-connectors [data-active="true"] circle {
  opacity: 1;
  transition: opacity 120ms ease 260ms;

  @starting-style {
    opacity: 0;
  }
}

[data-blocked="true"] {
  border-color: var(--blocked-color) !important;
  background-color: color-mix(in srgb, var(--blocked-color) 10%, transparent) !important;
  transition:
    background-color 200ms ease,
    border-color 200ms ease;
}

@media (prefers-reduced-motion: no-preference) {
  [data-blocked-submit][data-revealed="true"]
    [data-blocked-submit-button]:not([aria-disabled="true"], :hover, :active, :focus-visible) {
    transition-delay: 240ms;
  }
}

.blocked-submit-hint {
  min-height: 1lh;
  color: var(--text-muted);
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 200ms ease;
}

.blocked-submit-hint[data-revealed="true"] {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .blocked-submit-connectors path,
  .blocked-submit-connectors [data-active="true"] path {
    stroke-dashoffset: 0;
    transition: opacity 120ms ease;

    @starting-style {
      stroke-dashoffset: 0;
      opacity: 0;
    }
  }

  .blocked-submit-connectors [data-active="false"] path {
    opacity: 0;
  }

  .blocked-submit-connectors [data-active="true"] circle {
    transition-delay: 0ms;
  }
}

/* PaaS Console additions: auth, account menu, cards, analytics charts, settings & modals */

.boot-loading {
  padding: 16vh 16px;
  text-align: center;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.account-chip:hover,
.account-chip-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-chip-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-sm,
.avatar-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 0.78rem;
  font-weight: 650;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1.15rem;
  font-weight: 650;
}

.avatar-fallback {
  background: var(--accent-soft);
  color: var(--accent);
}

/* PaaS Sign-In */

.signin {
  max-width: 430px;
}

.signin-head {
  margin-bottom: 18px;
}

.signin-head h1 {
  margin-bottom: 4px;
}

.oauth-block {
  margin-top: 14px;
}

.button-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 550;
  text-decoration: none;
}

.button-google:hover:not(:disabled) {
  background: var(--surface-2);
}

.button-google:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.google-icon {
  flex-shrink: 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.otp-sent-to {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.otp-input {
  font-family: var(--mono);
  font-size: 1.3rem;
  letter-spacing: 0.35em;
  text-align: center;
}

.otp-links {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.dev-code-hint {
  margin-bottom: 12px;
}

.admin-fallback {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.admin-fallback summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
}

.admin-fallback[open] summary {
  margin-bottom: 12px;
}

/* Pills & live indicator */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 550;
  white-space: nowrap;
}

.pill-sm {
  padding: 1px 7px;
  font-size: 0.72rem;
}

.pill-accent {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-success {
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  background: var(--success-soft);
  color: var(--success);
}

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--border-strong);
  vertical-align: middle;
}

.pulse-dot-live {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

/* Apps list & app head */

.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-head-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.app-id-pill {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.app-cell {
  display: grid;
  gap: 2px;
}

.app-cell-sub {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-row-id {
  font-size: 0.8rem;
  font-weight: 400;
}

/* Segmented controls */

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  gap: 2px;
}

.segment-btn {
  padding: 5px 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.segment-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

/* Cards, KPI Grid, Charts */

.card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  corner-shape: squircle;
  background: var(--surface);
  display: grid;
  gap: 14px;
}

.card-danger {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.card-title {
  font-size: 1rem;
  font-weight: 620;
}

.card-sub {
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-stack,
.settings-stack {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.kpi-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  corner-shape: squircle;
  background: var(--surface);
  display: grid;
  gap: 4px;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-wrap {
  position: relative;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 170px;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.chart-hit {
  fill: transparent;
}

.chart-slot:hover .chart-hit {
  fill: color-mix(in srgb, var(--accent) 8%, transparent);
}

.chart-tooltip {
  position: absolute;
  top: 4px;
  right: 8px;
  display: grid;
  gap: 2px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  pointer-events: none;
}

/* Entity distribution bars */

.entity-bars {
  display: grid;
  gap: 8px;
}

.entity-bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 180px) 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

.entity-bar-row:hover {
  background: var(--surface-2);
}

.entity-bar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
}

.entity-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.entity-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.entity-bar-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Settings forms, copy rows, secret reveals */

.notice-info {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
  color: var(--text);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.field-grow {
  flex: 1 1 220px;
  display: grid;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.field {
  display: grid;
}

.field-span-2 {
  grid-column: 1 / -1;
}

.field-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.copy-list {
  display: grid;
  gap: 8px;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.copy-label {
  min-width: 84px;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-muted);
}

.copy-value {
  flex: 1 1 200px;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

.secret-reveal {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 45%, transparent);
  border-radius: var(--radius-sm);
  background: var(--success-soft);
}

.secret-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.secret-token {
  flex: 1 1 240px;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.button-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.dialog-wide {
  width: min(520px, calc(100vw - 32px));
}

.dialog-form {
  display: grid;
  gap: 12px;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-email {
  font-weight: 600;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.85rem;
}

.method-list {
  display: grid;
  gap: 10px;
}

.method-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.method-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
