/* AdServer+ – app layer on top of Liquid Metal (liquid-metal.css).
   Order matters: `base` (our reset) must lose against the library's `components`, `app` (our additions)
   must win over the library, and Tailwind utilities (unlayered) must beat all three. Everything here uses --lm-* tokens only.
   Keep it small: if the library has a class for it, the template uses the library class. */
@layer base, components, app;

/* ── Reset (replaces Tailwind's preflight, which is unlayered and would flatten the library) ── */
@layer base {
  *,
  ::before,
  ::after {
    box-sizing: border-box;
    border: 0 solid var(--lm-line);
  }
  html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    line-height: 1.5;
    font-family: var(--lm-font);
  }
  body {
    margin: 0;
    min-height: 100%;
    line-height: inherit;
    font-family: var(--lm-font);
    color: var(--lm-text);
    -webkit-font-smoothing: antialiased;
    background:
      radial-gradient(
        70% 40% at 50% 0%,
        rgba(40, 80, 220, 0.35),
        transparent 70%
      ),
      radial-gradient(
        60% 40% at 90% 100%,
        rgba(100, 60, 220, 0.22),
        transparent 70%
      ),
      var(--lm-bg);
    background-attachment: fixed;
  }
  hr {
    height: 0;
    color: inherit;
    border-top-width: 1px;
  }
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-size: inherit;
    font-weight: inherit;
    margin: 0;
  }
  p,
  figure,
  blockquote,
  dl,
  dd,
  pre {
    margin: 0;
  }
  a {
    color: inherit;
    text-decoration: inherit;
  }
  b,
  strong {
    font-weight: 600;
  }
  code,
  kbd,
  samp,
  pre {
    font-family:
      ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1em;
  }
  small {
    font-size: 80%;
  }
  table {
    text-indent: 0;
    border-color: inherit;
    border-collapse: collapse;
  }
  button,
  input,
  optgroup,
  select,
  textarea {
    font-family: inherit;
    font-size: 100%;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;
    margin: 0;
    padding: 0;
  }
  button,
  select {
    text-transform: none;
  }
  button,
  [type="button"],
  [type="reset"],
  [type="submit"] {
    -webkit-appearance: button;
    background-color: transparent;
    background-image: none;
  }
  summary {
    display: list-item;
  }
  ol,
  ul,
  menu {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  textarea {
    resize: vertical;
  }
  input::placeholder,
  textarea::placeholder {
    opacity: 1;
    color: #7f8aa6;
  }
  img,
  svg,
  video,
  canvas,
  audio,
  iframe,
  embed,
  object {
    display: block;
    vertical-align: middle;
  }
  img,
  video {
    max-width: 100%;
    height: auto;
  }
  fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
  }
  [hidden] {
    display: none !important;
  }
  :focus-visible {
    outline: 2px solid var(--lm-blue-soft);
    outline-offset: 3px;
  }
  main:focus {
    outline: none;
  }
  ::selection {
    background: rgba(59, 107, 255, 0.45);
  }
  input[type="file"] {
    max-width: 100%;
    min-width: 0;
  }
  option {
    background: #111217;
    color: var(--lm-text);
  }
}

@layer app {
  /* ── Skip link ─────────────────────────────────────────────────────────── */
  .skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 100;
    padding: 0.6rem 1rem;
    border-radius: var(--lm-radius-pill);
    background: var(--lm-chrome-200);
    color: var(--lm-text-on-metal);
    font: 600 0.875rem/1 var(--lm-font);
    transition: top 0.15s;
  }
  .skip-link:focus {
    top: 1rem;
  }

  /* ── App frame: Liquid Metal shell filling the viewport ────────────────── */
  .app-frame {
    height: 100vh;
    height: 100dvh;
    padding: 0.5rem;
    overflow: hidden;
  }
  @media (min-width: 1024px) {
    .app-frame {
      padding: 1rem;
    }
  }
  .lm-shell__content {
    scroll-behavior: smooth;
  }
  @media (prefers-reduced-motion: reduce) {
    .lm-shell__content {
      scroll-behavior: auto;
    }
  }
  .lm-shell__content > main {
    min-height: 100%;
  }
  .lm-topbar {
    gap: 0.75rem;
  }
  .lm-topbar h1 {
    font: 600 1.0625rem/1.2 var(--lm-font);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lm-sidebar .lm-sidebar__brand img {
    height: 1.25rem;
    width: auto;
  }

  /* ── Page heading (eyebrow + chrome title) ─────────────────────────────── */
  .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 1.5rem;
  }
  .page-heading {
    min-width: 0;
  }
  /* actions sit right next to the title: the primary one first, secondary ones after it */
  .page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }
  .page-actions:empty {
    display: none;
  }
  .page-eyebrow {
    margin: 0 0 0.35rem;
    font: 600 0.75rem/1 var(--lm-font);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lm-blue-soft);
  }
  .page-title {
    margin: 0;
    font: 700 clamp(1.6rem, 3.2vw, 2.25rem)/1.25 var(--lm-font);
    padding-bottom: 0.08em; /* background-clip:text clips at the box edge: keep descenders (g, y, p) inside */
    letter-spacing: -0.03em;
    background: linear-gradient(180deg, #fff 0%, #dfe5f1 45%, #aab6cf 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }

  /* ── Library gaps: icons in alerts/fields use the Bootstrap-Icons font instead of <svg> ── */
  .lm-alert > i.bi {
    grid-row: span 2;
    margin-top: 0.1rem;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--_c);
  }
  .lm-alert {
    position: relative;
  }
  .lm-alert--info {
    --_c: var(--lm-blue-soft);
  }
  .lm-alert > .alert-close {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
  }
  .lm-alert:has(> .alert-close) {
    padding-right: 3rem;
  }
  .lm-field > i.bi {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--lm-text-muted);
    pointer-events: none;
    font-size: 1rem;
    line-height: 1;
  }
  .lm-field--left > i.bi {
    left: 0.9rem;
    right: auto;
  }
  .lm-field--left > .lm-input,
  .lm-field--left > .filter-input {
    padding-left: 2.6rem;
  }
  .lm-input.lm-sm,
  .lm-select.lm-sm {
    min-height: 2.25rem;
    font-size: 0.875rem;
  }

  /* ── Form pieces the library does not ship ─────────────────────────────── */
  .field-error {
    margin-top: 0.35rem;
    font: 500 0.8125rem/1.35 var(--lm-font);
    color: #ff8f9e;
  }
  .lm-input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(255, 107, 125, 0.28);
  }
  .file-input {
    width: 100%;
    font: 400 0.875rem/1.3 var(--lm-font);
    color: var(--lm-text-muted);
  }
  .file-input::file-selector-button {
    margin-right: 0.85rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--lm-line-strong);
    border-radius: var(--lm-radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: var(--lm-text);
    font: 500 0.8125rem/1 var(--lm-font);
    cursor: pointer;
  }
  .file-input::file-selector-button:hover {
    background: rgba(255, 255, 255, 0.14);
  }
  input[type="date"],
  input[type="datetime-local"],
  input[type="time"] {
    color-scheme: dark;
  }
  .lm-input[type="number"] {
    font-variant-numeric: tabular-nums;
  }
  .lm-select[multiple] {
    background-image: none;
    padding: 0.5rem;
    min-height: 8rem;
  }
  legend.lm-card__title {
    padding: 0;
  }

  /* Floating action bar: compact pill, centred, stays at the bottom while the form scrolls */
  .action-bar {
    position: sticky;
    bottom: 1.25rem;
    z-index: 10;
    width: fit-content;
    max-width: 100%;
    margin: 1.5rem auto 0;
    padding: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid var(--lm-line-strong);
    border-radius: 1.25rem;
    background: rgba(14, 15, 19, 0.92);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .action-bar > .lm-btn-ghost,
  .action-bar > .lm-btn-outline,
  .action-bar > .lm-btn-danger {
    min-width: 7.5rem;
    min-height: 2.5rem;
    padding: 0 1.25rem;
  }
  .lm-stat__sub {
    font: 400 0.8125rem/1.2 var(--lm-font);
    color: var(--lm-text-muted);
  }

  /* ── Data helpers ──────────────────────────────────────────────────────── */
  .lm-table tbody th[scope="row"] {
    padding: 0.95rem 1.1rem;
    text-align: left;
    white-space: normal;
    background: transparent;
    font: 600 0.9rem/1.3 var(--lm-font);
    color: var(--lm-text);
    border-bottom: 1px solid var(--lm-line);
  }
  .lm-table tbody tr:last-child th[scope="row"] {
    border-bottom: 0;
  }
  .lm-table tbody tr:hover th[scope="row"] {
    background: rgba(255, 255, 255, 0.035);
  }
  .lm-table-wrap > .lm-table {
    min-width: 36rem;
  }
  .snippet {
    display: block;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--lm-line);
    border-radius: var(--lm-radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: var(--lm-text-muted);
    font:
      400 0.75rem/1.4 ui-monospace,
      SFMono-Regular,
      Menlo,
      monospace;
  }
  .meter {
    width: 100%;
    height: 0.5rem;
    margin-top: 0.4rem;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
    overflow: hidden;
  }
  .meter-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2f5cff, #86b0ff 60%, #fff);
    box-shadow: 0 0 14px rgba(59, 107, 255, 0.7);
  }
  .meter-warn {
    background: linear-gradient(90deg, #b45309, #ffc46b);
    box-shadow: 0 0 12px rgba(255, 196, 107, 0.55);
  }
  .meter-danger {
    background: linear-gradient(90deg, #b91c1c, #ff8f9e);
    box-shadow: 0 0 12px rgba(255, 107, 125, 0.55);
  }
  .chart-box {
    position: relative;
    height: 18rem;
  }
  .chart-box-sm {
    position: relative;
    height: 14rem;
  }
  .zone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
    gap: 1rem;
  }
  .zone-card {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
  }
  .docs-link {
    color: var(--lm-blue-soft);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .docs-link:hover {
    color: #fff;
  }
  .row-action {
    width: 2rem;
    height: 2rem;
  }
  .row-action-danger:hover {
    background: rgba(255, 107, 125, 0.18);
    color: #ff9aa8;
  }
  .row-action-primary:hover {
    background: rgba(59, 107, 255, 0.25);
    color: #cfdcff;
  }

  /* ── Global search + user menu ─────────────────────────────────────────── */
  .search-heading {
    padding: 0.5rem 0.75rem 0.25rem;
    font: 600 0.6875rem/1 var(--lm-font);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lm-text-muted);
  }
  .search-item {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--lm-radius-sm);
    font: 400 0.9rem/1.3 var(--lm-font);
    color: var(--lm-text);
  }
  .search-item:hover,
  .search-item:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
  }
  .topbar-search {
    padding-right: 1rem;
  }
  .user-btn {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.35rem;
    border-radius: var(--lm-radius-md);
    text-align: left;
    color: var(--lm-text);
    font: 500 0.875rem/1 var(--lm-font);
  }
  .user-btn:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .lm-sidebar[data-collapsed="true"] .user-btn > :not(.user-btn__icon) {
    display: none;
  }
  .lm-avatar {
    display: grid;
    place-items: center;
    flex: none;
    font: 600 0.8rem/1 var(--lm-font);
    color: var(--lm-text);
  }
  .menu-lang {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--lm-line);
  }

  /* ── Setup wizard ──────────────────────────────────────────────────────── */
  .wiz-steps {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 2rem;
    padding: 0 0 0.5rem;
    list-style: none;
    overflow-x: auto;
  }
  .wiz-steps li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
  }
  .wiz-steps li + li::before {
    content: "";
    width: 2rem;
    height: 2px;
    margin-right: 0.5rem;
    background: var(--lm-line-strong);
    border-radius: 2px;
  }
  @media (min-width: 768px) {
    .wiz-steps li + li::before {
      width: 4rem;
    }
  }
  @media (max-width: 767px) {
    .wiz-steps {
      gap: 0.25rem;
    }
    .wiz-steps li + li::before {
      width: 0.75rem;
      margin-right: 0.25rem;
    }
  }
  .wiz-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px var(--lm-line);
    color: var(--lm-text-muted);
    font: 700 0.875rem/1 var(--lm-font);
  }
  .wiz-dot .done-ic {
    display: none;
  }
  .wiz-label {
    display: none;
    font: 500 0.875rem/1 var(--lm-font);
    color: var(--lm-text-muted);
  }
  @media (min-width: 640px) {
    .wiz-label {
      display: inline;
    }
  }
  .wiz-steps li[data-state="done"] .wiz-dot {
    background: rgba(56, 224, 140, 0.16);
    box-shadow: inset 0 0 0 1px rgba(56, 224, 140, 0.5);
    color: var(--lm-green);
  }
  .wiz-steps li[data-state="done"] .num {
    display: none;
  }
  .wiz-steps li[data-state="done"] .done-ic {
    display: inline;
  }
  .wiz-steps li[data-state="done"]::before,
  .wiz-steps li[data-state="current"]::before {
    background: var(--lm-blue-soft);
  }
  .wiz-steps li[data-state="current"] .wiz-dot {
    color: var(--lm-text-on-metal);
    background: linear-gradient(180deg, #f4f7fc, #b6c0d4 55%, #e3e8f2);
    box-shadow:
      inset 0 1px 0 #fff,
      0 0 18px rgba(59, 107, 255, 0.55);
  }
  .wiz-steps li[data-state="current"] .wiz-label {
    color: var(--lm-text);
    font-weight: 600;
  }
  .wiz-heading {
    margin: 0 0 1rem;
    font: 600 1.25rem/1.2 var(--lm-font);
    letter-spacing: -0.015em;
  }
  .wiz-heading:focus {
    outline: none;
  }
  .wiz-heading:focus-visible {
    outline: 2px solid var(--lm-blue-soft);
    outline-offset: 4px;
    border-radius: 6px;
  }
  .wiz-context {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--lm-radius-md);
    border: 1px solid rgba(110, 150, 255, 0.4);
    background: rgba(59, 107, 255, 0.1);
    font-size: 0.875rem;
    color: var(--lm-text);
  }
  .wiz-link {
    background: none;
    border: 0;
    padding: 0.25rem 0.4rem;
    color: var(--lm-blue-soft);
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
  }
  .wiz-or {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--lm-text-muted);
    font: 700 0.75rem/1 var(--lm-font);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .wiz-or::before,
  .wiz-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--lm-line-strong);
  }
  .wiz-ico,
  .wiz-num,
  .stat-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--lm-radius-sm);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    color: var(--lm-blue-soft);
  }
  .wiz-ico,
  .stat-ico {
    width: 2.5rem;
    height: 2.5rem;
  }
  .wiz-num {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    font: 700 0.75rem/1 var(--lm-font);
  }
  .wiz-note {
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0.75rem;
    border-radius: var(--lm-radius-md);
    font-size: 0.8125rem;
    color: var(--lm-text);
    border: 1px solid rgba(110, 150, 255, 0.35);
    background: rgba(59, 107, 255, 0.09);
  }
  .wiz-note-warn {
    border-color: rgba(255, 196, 107, 0.45);
    background: rgba(255, 196, 107, 0.1);
  }
  .wiz-summary {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--lm-radius-md);
    border: 1px solid var(--lm-line);
    background: rgba(255, 255, 255, 0.03);
  }
  .wiz-summary dt {
    font: 700 0.6875rem/1 var(--lm-font);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lm-text-muted);
  }
  .wiz-summary dd {
    margin: 0.2rem 0 0;
    font-size: 0.875rem;
    color: var(--lm-text);
  }
  .wiz-type {
    display: block;
    cursor: pointer;
  }
  .wiz-type > input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }
  .wiz-type-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    padding: 1rem;
    border-radius: var(--lm-radius-md);
    border: 1px solid var(--lm-line);
    background: rgba(255, 255, 255, 0.03);
    transition:
      border-color 0.25s var(--lm-ease),
      background 0.25s var(--lm-ease),
      box-shadow 0.25s var(--lm-ease);
  }
  .wiz-type:hover .wiz-type-body {
    border-color: var(--lm-line-strong);
    background: rgba(255, 255, 255, 0.05);
  }
  .wiz-type input:checked + .wiz-type-body {
    border-color: rgba(110, 150, 255, 0.85);
    background: linear-gradient(
      160deg,
      rgba(59, 107, 255, 0.16),
      rgba(59, 107, 255, 0.05)
    );
    box-shadow:
      0 0 0 1px rgba(86, 134, 255, 0.3),
      0 0 30px rgba(59, 107, 255, 0.22);
  }
  .wiz-type input:focus-visible + .wiz-type-body {
    outline: 2px solid var(--lm-blue-soft);
    outline-offset: 3px;
  }

  /* Asset picker */
  dialog.asset-dialog {
    width: min(48rem, calc(100vw - 2rem));
    max-height: 80vh;
    padding: 0;
  }
  dialog.asset-dialog[open] {
    display: flex;
    flex-direction: column;
  }

  /* ── Auth pages ────────────────────────────────────────────────────────── */
  .auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
  }
  .auth-card {
    width: min(26rem, 100%);
    padding: 2rem;
  }

  /* ── Accessibility modes ───────────────────────────────────────────────── */
  @media (prefers-reduced-transparency: reduce) {
    .lm-card,
    .lm-sidebar,
    .lm-table-wrap,
    .lm-popover,
    .lm-navbar,
    .action-bar {
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
      background-color: #111217;
    }
  }
  @media (forced-colors: active) {
    .lm-card,
    .lm-table-wrap,
    .lm-popover,
    .lm-dialog,
    .lm-sheet,
    .lm-input,
    .lm-select {
      border: 1px solid CanvasText;
      backdrop-filter: none;
    }
    .lm-btn,
    .lm-btn-ghost,
    .lm-btn-soft,
    .lm-btn-outline,
    .lm-btn-danger,
    .lm-icon-btn {
      border: 1px solid ButtonText;
      forced-color-adjust: auto;
    }
    .page-title {
      -webkit-text-fill-color: CanvasText;
      color: CanvasText;
      background: none;
    }
    .lm-sidenav__item[aria-current="page"] {
      outline: 2px solid Highlight;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
      scroll-behavior: auto !important;
    }
  }
} /* /@layer app */

@layer app {
  /* Bootstrap-Icons inside library components that were drawn for <svg> */
  .lm-sidenav__item > i.bi,
  .lm-subnav a > i.bi {
    flex: none;
    width: 1.25rem;
    font-size: 1.15rem;
    line-height: 1;
    text-align: center;
  }
  .lm-item__icon > i.bi,
  .lm-navbar__icon > i.bi,
  .lm-radio-card__icon > i.bi,
  .lm-empty > .lm-item__icon > i.bi {
    font-size: 1.15rem;
    line-height: 1;
  }
  .lm-btn > i.bi,
  .lm-btn-ghost > i.bi,
  .lm-btn-soft > i.bi,
  .lm-btn-outline > i.bi,
  .lm-btn-danger > i.bi,
  .lm-btn-link > i.bi {
    font-size: 1.05em;
    line-height: 1;
  }
  .lm-btn-soft.lm-sm > i.bi,
  .lm-btn-outline.lm-sm > i.bi {
    font-size: 1em;
  }
  .lm-icon-btn > i.bi {
    font-size: 1.1rem;
    line-height: 1;
  }
  .lm-menu__item > i.bi {
    width: 1.1rem;
    text-align: center;
  }
  .app-userbar {
    padding-top: 0.6rem;
    border-top: 1px solid var(--lm-line);
  }
  .app-userbar .lm-dropdown {
    display: block;
  }
  .app-userbar .lm-menu {
    min-width: 15rem;
  }
  .lm-sidebar .lm-sidenav {
    padding-bottom: 0.5rem;
  }
  .app-brand-mark {
    display: block;
    flex: none;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
  }
  .lm-toolbar > form,
  .lm-toolbar > div {
    min-width: 0;
  }
}

@layer app {
  .lm-toolbar > select,
  .lm-toolbar > .lm-select,
  .lm-toolbar form > select {
    width: auto;
    min-width: 9rem;
  }
  .relative > input[type="search"].lm-input,
  .relative > input.lm-input.lm-sm[type="search"] {
    padding-left: 2.4rem;
  }
  .lm-stat-value + .lm-stat__label,
  .lm-stat__label {
    margin-top: 0.35rem;
    display: block;
  }
  .lm-check {
    margin-top: 0;
  }
  input.lm-check[type="checkbox"],
  input.lm-radio {
    vertical-align: middle;
  }
}

@layer app {
  /* Absolutely positioned tooltips inside table cells must clip to the scroll wrapper, not the page */
  .lm-table-wrap {
    position: relative;
  }
}

@layer app {
  /* Big KPI numbers must fit a half-width card on phones */
  @media (max-width: 640px) {
    .lm-stat-value {
      font-size: 1.75rem;
    }
  }
}

@layer app {
  main > nav > .lm-breadcrumb {
    margin: 0 0 0.6rem;
  }
}

@layer app {
  .user-btn__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.15rem;
    color: var(--lm-text-muted);
  }
}

@layer app {
  .lm-toolbar {
    justify-content: flex-start;
  }
}

/* ── Onboarding tour (Driver.js popover, Liquid Metal look) ─────── */
.driver-popover.lm-tour {
  background:
    linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.07),
      rgba(255, 255, 255, 0.015) 55%
    ),
    #111217;
  color: var(--lm-text);
  border: 1px solid var(--lm-line-strong);
  border-radius: var(--lm-radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  max-width: 22rem;
  font-family: var(--lm-font);
}
.lm-tour .driver-popover-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--lm-text);
}
.lm-tour .driver-popover-description {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--lm-text-muted);
}
.lm-tour .driver-popover-description a {
  color: var(--lm-blue-soft);
  text-decoration: underline;
}
.lm-tour .driver-popover-progress-text {
  color: var(--lm-text-muted);
  font-size: 0.8rem;
}
.lm-tour .driver-popover-footer button {
  background: rgba(255, 255, 255, 0.07);
  color: var(--lm-text);
  border: 1px solid var(--lm-line-strong);
  border-radius: var(--lm-radius-pill);
  padding: 0.4rem 1rem;
  text-shadow: none;
  font-size: 0.85rem;
}
.lm-tour .driver-popover-next-btn {
  background: var(--lm-blue);
  border-color: var(--lm-blue-soft);
}
.lm-tour .driver-popover-close-btn {
  color: var(--lm-text-muted);
}
.lm-tour .driver-popover-arrow-side-left.driver-popover-arrow {
  border-left-color: #111217;
}
.lm-tour .driver-popover-arrow-side-right.driver-popover-arrow {
  border-right-color: #111217;
}
.lm-tour .driver-popover-arrow-side-top.driver-popover-arrow {
  border-top-color: #111217;
}
.lm-tour .driver-popover-arrow-side-bottom.driver-popover-arrow {
  border-bottom-color: #111217;
}

/* tour refinements */
.lm-tour .driver-popover-title {
  padding-right: 2.5rem;
}
.lm-tour .driver-popover-close-btn {
  top: 0.7rem;
  right: 0.8rem;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--lm-text);
  font-size: 1.25rem;
}
.lm-tour .driver-popover-close-btn:hover,
.lm-tour .driver-popover-close-btn:focus {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.lm-tour .driver-popover-footer button:hover,
.lm-tour .driver-popover-footer button:focus {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: var(--lm-blue-soft);
}
.lm-tour .driver-popover-footer .driver-popover-next-btn:hover,
.lm-tour .driver-popover-footer .driver-popover-next-btn:focus {
  background: #4d7bff;
}
.lm-tour .driver-popover-footer button:focus-visible,
.lm-tour .driver-popover-close-btn:focus-visible {
  outline: 2px solid var(--lm-blue-soft);
  outline-offset: 2px;
}
.lm-tour .tour-doc {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--lm-radius-md);
  border: 1px solid var(--lm-line-strong);
  background: rgba(59, 107, 255, 0.14);
  color: var(--lm-text);
  text-decoration: none;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.lm-tour .tour-doc:hover,
.lm-tour .tour-doc:focus-visible {
  background: rgba(59, 107, 255, 0.28);
  border-color: var(--lm-blue-soft);
}
.lm-tour .tour-doc > .bi:first-child {
  font-size: 1.9rem;
  color: var(--lm-blue-soft);
}
.lm-tour .tour-doc > span {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.lm-tour .tour-doc strong {
  font-weight: 600;
  color: #fff;
}
.lm-tour .tour-doc small {
  color: var(--lm-text-muted);
  font-size: 0.8rem;
}
.lm-tour .tour-doc > .bi:last-child {
  color: var(--lm-text-muted);
}
/* sidebar item in focus: stronger tint + glowing orbit border */
#sidebar .driver-active-element.lm-sidenav__item {
  color: #fff;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background:
    linear-gradient(#1c1e26, #1c1e26) padding-box,
    conic-gradient(
        from var(--lm-angle),
        rgba(127, 166, 255, 0.25) 0 40%,
        #7fa6ff 70%,
        #fff 85%,
        rgba(127, 166, 255, 0.25) 100%
      )
      border-box;
  box-shadow:
    0 0 22px rgba(59, 107, 255, 0.7),
    0 0 4px rgba(127, 166, 255, 0.9);
  animation: lm-orbit 3s linear infinite;
}

/* Primary save: filled blue plate on the ghost button */
.lm-btn-ghost.is-save {
  --_plate: #2f5fff;
  --_edge: rgba(150, 180, 255, 0.85);
  color: #fff;
  box-shadow: 0 0 18px rgba(59, 107, 255, 0.45);
}
.lm-btn-ghost.is-save:hover,
.lm-btn-ghost.is-save:focus-visible {
  --_plate: #4d7bff;
  color: #fff;
  box-shadow: 0 0 24px rgba(77, 123, 255, 0.7);
}

/* Info icon + tooltip (replaces inline hints and side-panel explanations) */
.lm-info {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--lm-text-muted);
  font-size: 0.95rem;
  cursor: help;
  transition:
    color 0.2s,
    background 0.2s;
}
.lm-info:hover,
.lm-info:focus {
  color: var(--lm-blue-soft);
  background: rgba(127, 166, 255, 0.14);
  outline: none;
}
.lm-info:focus-visible {
  outline: 2px solid var(--lm-blue-soft);
  outline-offset: 1px;
}
.lm-info--card {
  position: absolute;
  top: 1rem;
  right: 1rem;
}
.lm-info[data-lm-tip]::after {
  left: auto;
  right: -0.4rem;
  bottom: auto;
  top: calc(100% + 0.5rem);
  width: max-content;
  max-width: min(19rem, 72vw);
  white-space: pre-line;
  text-align: left;
  font-weight: 400;
  line-height: 1.5;
  transform: translateY(-4px);
}
.lm-info[data-lm-tip]:hover::after,
.lm-info[data-lm-tip]:focus::after {
  opacity: 1;
  transform: none;
}
.lm-info--start[data-lm-tip]::after {
  left: -0.4rem;
  right: auto;
}
.lm-card:has(.lm-info:hover, .lm-info:focus) {
  z-index: 30;
}
.lm-card--padinfo > .lm-card__title,
.lm-card--padinfo > legend {
  padding-right: 2rem;
}

/* Radio / checkbox cards: indicator left, info icon top right, no sub-text */
.lm-radio-card-wrap,
.lm-check-card {
  position: relative;
}
.lm-radio-card-wrap .lm-radio-card__body,
.lm-check-card .lm-radio-card__body {
  align-items: center;
  padding: 0.55rem 3rem 0.55rem 1.1rem;
  min-height: 2.875rem;
}
.lm-radio-card-wrap .lm-radio-card__body::after,
.lm-check-card .lm-radio-card__body::after {
  order: -1;
  margin-left: 0;
}
.lm-radio-card-wrap > .lm-info,
.lm-check-card > .lm-info {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  z-index: 2;
}
.lm-active-card .lm-radio-card__input:checked + .lm-radio-card__body {
  border-color: rgba(56, 224, 140, 0.8);
  background: linear-gradient(
    160deg,
    rgba(56, 224, 140, 0.16),
    rgba(56, 224, 140, 0.04)
  );
  box-shadow:
    0 0 0 1px rgba(56, 224, 140, 0.3),
    0 0 30px rgba(56, 224, 140, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.lm-active-card .lm-radio-card__input:checked + .lm-radio-card__body::after {
  border-color: rgba(120, 240, 180, 0.8);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E")
      center / 72% no-repeat,
    linear-gradient(180deg, #4be39b, #1fb871);
  box-shadow: 0 0 14px rgba(56, 224, 140, 0.6);
}

/* Flatpickr in Liquid Metal look */
.flatpickr-calendar {
  background: rgba(17, 18, 23, 0.985);
  border: 1px solid var(--lm-line-strong);
  border-radius: var(--lm-radius-md);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  color: var(--lm-text);
  font-family: var(--lm-font);
}
.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after {
  display: none;
}
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year,
span.flatpickr-weekday,
.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
  color: var(--lm-text);
  fill: var(--lm-text);
  background: transparent;
}
span.flatpickr-weekday {
  color: var(--lm-text-muted);
  font-weight: 500;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  color: var(--lm-text-muted);
  fill: var(--lm-text-muted);
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
  fill: var(--lm-blue-soft);
}
.flatpickr-day {
  color: var(--lm-text);
  border-radius: 10px;
  border-color: transparent;
}
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay,
.flatpickr-day.flatpickr-disabled {
  color: rgba(141, 153, 184, 0.45);
}
.flatpickr-day:hover,
.flatpickr-day:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: transparent;
}
.flatpickr-day.today {
  border-color: var(--lm-blue-soft);
}
.flatpickr-day.today:hover {
  background: rgba(127, 166, 255, 0.2);
  color: #fff;
  border-color: var(--lm-blue-soft);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--lm-blue);
  border-color: var(--lm-blue-soft);
  color: #fff;
  box-shadow: 0 0 14px rgba(59, 107, 255, 0.6);
}
.flatpickr-time {
  border-top: 1px solid var(--lm-line);
}
.flatpickr-time input:hover,
.flatpickr-time input:focus,
.flatpickr-time .flatpickr-am-pm:hover {
  background: rgba(255, 255, 255, 0.08);
}
.flatpickr-time .numInputWrapper span.arrowUp::after {
  border-bottom-color: var(--lm-text-muted);
}
.flatpickr-time .numInputWrapper span.arrowDown::after {
  border-top-color: var(--lm-text-muted);
}
.flatpickr-time .flatpickr-time-separator {
  color: var(--lm-text-muted);
}
.numInputWrapper:hover {
  background: rgba(255, 255, 255, 0.06);
}
.flatpickr-current-month
  .flatpickr-monthDropdown-months
  .flatpickr-monthDropdown-month {
  background: #111217;
}
input.lm-input.flatpickr-input + input,
.flatpickr-input[readonly] {
  cursor: pointer;
}

/* Leaner sidebar + buttons */
.lm-sidebar {
  --_w: 14.5rem;
  padding: 0.75rem;
}
.lm-sidenav__item {
  height: 2.3rem;
  padding: 0 0.7rem;
  gap: 0.65rem;
  font-size: 0.84rem;
}
.lm-sidenav__item > i.bi {
  font-size: 0.95rem;
}
.lm-sidenav__label {
  padding: 0.85rem 0.7rem 0.3rem;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}
.lm-sm {
  min-height: 2rem;
  font-size: 0.8125rem;
}
.lm-sm:not(.lm-input):not(.lm-select) {
  padding: 0 0.85rem; /* inputs keep their own padding (search icon!) */
}
.lm-btn {
  --lm-btn-h: 2.75rem;
  font-size: 0.9375rem;
}
.lm-btn-ghost,
.lm-btn-soft,
.lm-btn-outline,
.lm-btn-danger {
  font-size: 0.875rem;
}
.lm-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
}

/* Setup checklist in the sidebar */
.nav-setup-count {
  margin-left: 0.4rem;
  opacity: 0.7;
}
.nav-setup {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-setup a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.28rem 0.7rem;
  border-radius: 8px;
  color: var(--lm-text-muted);
  font-size: 0.76rem;
  line-height: 1.25;
  text-decoration: none;
}
.nav-setup a:hover {
  color: var(--lm-text);
  background: rgba(255, 255, 255, 0.05);
}
.nav-setup a.is-current {
  color: var(--lm-text);
}
.nav-setup .bi {
  font-size: 0.8rem;
  flex: none;
}
.nav-setup .bi-check-circle-fill {
  color: var(--lm-green);
}
.nav-setup a.is-current .bi {
  color: var(--lm-blue-soft);
}
.lm-sidebar[data-collapsed="true"] .nav-setup {
  display: none;
}

/* Equal-height type cards */
.lm-radio-cards {
  align-items: stretch;
}
.lm-radio-card-wrap {
  display: flex;
}
.lm-radio-card-wrap > .lm-radio-card {
  flex: 1;
  display: flex;
}
.lm-radio-card-wrap .lm-radio-card__body {
  flex: 1;
}

/* Active: softer glow */
.lm-active-card .lm-radio-card__input:checked + .lm-radio-card__body {
  border-color: rgba(56, 224, 140, 0.5);
  background: linear-gradient(
    160deg,
    rgba(56, 224, 140, 0.1),
    rgba(56, 224, 140, 0.02)
  );
  box-shadow:
    0 0 0 1px rgba(56, 224, 140, 0.14),
    0 0 14px rgba(56, 224, 140, 0.1);
}
.lm-active-card .lm-radio-card__input:checked + .lm-radio-card__body::after {
  border-color: rgba(120, 240, 180, 0.5);
  box-shadow: 0 0 6px rgba(56, 224, 140, 0.3);
}

/* Collapsible cards */
.lm-collapse {
  position: absolute;
  top: 1rem;
  right: 2.9rem;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--lm-text-muted);
  cursor: pointer;
  transition:
    transform 0.25s var(--lm-ease),
    color 0.2s,
    background 0.2s;
}
.lm-collapse:hover,
.lm-collapse:focus-visible {
  color: var(--lm-text);
  background: rgba(255, 255, 255, 0.1);
}
[data-collapsible] > legend {
  cursor: pointer;
}
.is-collapsed .lm-collapse {
  transform: rotate(-90deg);
}
.is-collapsed > legend {
  margin-bottom: 0;
  opacity: 0.75;
}
.is-collapsed > :not(legend):not(.lm-info):not(.lm-collapse) {
  display: none;
}

/* Dark grey base with faint rising bubbles (brightness knobs: --lm-bg, gradient stops, .lm-shell alpha, bubble alpha .16-.22) */
:root { --lm-bg: #0b0c10; --lm-surface: #111217; --lm-surface-2: #16181f; --lm-line: rgba(200, 205, 220, 0.11); --lm-line-strong: rgba(200, 205, 220, 0.22); --lm-text-muted: #979ead; }
.lm-shell { background: rgba(9, 10, 13, 0.55); }
body.lm-surface { position: relative; background: radial-gradient(120% 80% at 50% 115%, #14161c 0%, var(--lm-bg) 55%, #07080b 100%); }
body.lm-surface::after { content: ""; position: fixed; left: 0; right: 0; top: 0; pointer-events: none; z-index: 0;
  height: calc(100vh + 480px);
  background-image:
    radial-gradient(circle at 12% 70%, transparent 0 5px, rgba(200,210,230,.14) 5.5px 6.5px, transparent 7px),
    radial-gradient(circle at 38% 20%, transparent 0 9px, rgba(200,210,230,.11) 9.5px 10.5px, transparent 11px),
    radial-gradient(circle at 64% 85%, transparent 0 4px, rgba(200,210,230,.15) 4.5px 5.5px, transparent 6px),
    radial-gradient(circle at 83% 40%, transparent 0 7px, rgba(200,210,230,.12) 7.5px 8.5px, transparent 9px),
    radial-gradient(circle at 92% 92%, transparent 0 3px, rgba(200,210,230,.14) 3.5px 4.5px, transparent 5px);
  background-size: 480px 480px;
  animation: bubbles-rise 70s linear infinite; }
@keyframes bubbles-rise { to { transform: translateY(-480px); } }
.app-frame { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { body.lm-surface::after { animation: none; } }
/* Licence field in the welcome step */
.lm-tour .tour-license { margin-top: .9rem; padding: .8rem .9rem; border: 1px solid var(--lm-line); border-radius: var(--lm-radius-md); background: rgba(255,255,255,.03); }
.lm-tour .tour-license label { display: block; font-size: .8rem; font-weight: 600; color: var(--lm-text); }
.lm-tour .tour-license p { margin: .15rem 0 .55rem; font-size: .78rem; color: var(--lm-text-muted); }
.lm-tour .tour-license__row { display: flex; gap: .5rem; }
.lm-tour .tour-license__row .lm-input { min-height: 2rem; font-size: .8rem; padding: 0 .7rem; }
.lm-tour .tour-license p.tour-license__msg { margin: .5rem 0 0; min-height: 1em; }
.lm-tour .tour-license__msg.is-ok { color: var(--lm-green); }
.lm-tour .tour-license__msg.is-warn { color: var(--lm-amber); }

/* the native select behind a combobox must never show */
.lm-combobox > select, select[data-combobox][hidden] { display: none !important; }

/* campaign detail: calmer chart height */
.lm-card .chart-box { height: 14rem; }
.lm-popover[hidden], .lm-combobox__panel[hidden] { display: none !important; }

/* sign-in & co: the card (and the bubbles behind it) must stay in front of the bubble layer */
.auth-wrap { position: relative; z-index: 1; }

/* Tutorial video (templates/panel/_video.html, static/js/video.js) */
.lm-video {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.25rem;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--lm-line-strong);
  border-radius: var(--lm-radius-md);
  background: radial-gradient(circle at 50% 40%, rgba(59, 107, 255, 0.18), transparent 65%), rgba(5, 8, 22, 0.7);
  color: var(--lm-text);
  text-align: center;
}
button.lm-video {
  cursor: pointer;
}
button.lm-video:hover,
button.lm-video:focus-visible {
  border-color: var(--lm-blue-soft);
}
.lm-video > .bi {
  font-size: 2.4rem;
  color: var(--lm-blue-soft);
}
.lm-video > span {
  font-size: 0.8rem;
  color: var(--lm-text-muted);
}
.lm-video.is-soon {
  border-style: dashed;
}
iframe.lm-video {
  display: block;
  border: 0;
}
.lm-tour .tour-video { margin-top: 1rem; }

/* Sidebar text: line-height 1 clipped descenders (g, p, y) because the span hides overflow */
.lm-sidenav__text { line-height: 1.5; }

/* Assets page */
.asset-row { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.asset-thumb {
  flex: none; width: 3.5rem; height: 3.5rem; padding: 0.25rem; cursor: zoom-in;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--lm-line); border-radius: 0.6rem; background: rgba(255, 255, 255, 0.06);
}
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; }
.asset-actions form { display: flex; margin: 0; }
.asset-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 8rem; padding: 1rem; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--lm-line-strong); border-radius: 0.9rem; color: var(--lm-text-muted);
  transition: border-color 0.15s, background-color 0.15s;
}
.asset-drop > i.bi { font-size: 1.75rem; line-height: 1; }
.asset-drop:hover, .asset-drop.is-over, #asset-file-input:focus-visible + .asset-drop { border-color: var(--lm-blue-soft); background: rgba(59, 107, 255, 0.08); }
.asset-drop__file { color: var(--lm-text); font-size: 0.875rem; word-break: break-all; }
.asset-preview { width: min(64rem, calc(100vw - 2rem)); }
.asset-preview__bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.asset-preview__bar .lm-dialog__title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-preview img { display: block; max-width: 100%; max-height: calc(100vh - 12rem); margin: 0 auto; object-fit: contain; }

.date-popover { right: auto; width: 16rem; padding: 1rem; }

/* Settings button: descenders (g) were clipped by the truncating span */
.user-btn .truncate { line-height: 1.5; }
/* "Get started" sits at the bottom of the sidebar, above Settings */
.nav-setup-wrap { padding: 0.5rem 0 0.6rem; text-align: center; }
.nav-setup-wrap .nav-setup a { justify-content: center; }
.lm-sidebar[data-collapsed="true"] .nav-setup-wrap { display: none; }

.brand-logo { height: 2rem; width: auto; display: block; }
