/* Shared Material defaults only: reset, tokens, controls and reusable content.
   Inputs: material-input.css. Tables: material-table.css. Layout: dashboard.css.
   Page rules: <page>.css.
   Plain CSS served directly; the OS selects the light/dark palette. */
@layer reset, tokens, components, layout, pages;
/* material.Assets declares and preloads bundled Roboto with a content-hashed URL. */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, dl, dd { margin: 0; }
  button, input, select, textarea { font: inherit; }
  button, summary, input[type="checkbox"] { cursor: pointer; }
  a { color: inherit; text-decoration: none; }
  svg { flex-shrink: 0; vertical-align: middle; }
  [hidden] { display: none !important; }
  :focus-visible { outline: 3px solid var(--md-primary); outline-offset: 3px; }
}
@layer tokens {
  :root {
    color-scheme: light dark;
    --md-primary: light-dark(#173f35, #a8d5b8);
    --md-on-primary: light-dark(#fff, #123b2c);
    --md-primary-container: light-dark(#e7efdf, #294c3b);
    --md-on-primary-container: light-dark(#173f35, #e7efdf);
    --md-surface: light-dark(#ffffff, #141c18);
    --md-background: light-dark(#f6f7f2, #101813);
    --md-surface-low: light-dark(#f6f7f2, #18231c);
    --md-surface-container: light-dark(#f1f4ed, #1c2922);
    --md-surface-high: light-dark(#edf1e8, #2a382f);
    --md-on-surface: light-dark(#173f35, #e4ebe1);
    --md-on-surface-variant: light-dark(#5f6b64, #b4c1b7);
    --md-outline: light-dark(#7b887f, #94a398);
    --md-outline-variant: light-dark(#e0e5dc, #3e5043);
    --md-secondary-container: light-dark(#e7efdf, #344d3c);
    --md-on-secondary-container: light-dark(#173f35, #e7efdf);
    --md-on-error: light-dark(#fff, #690005);
    --md-on-error-container: light-dark(#410002, #ffdad6);
    --md-success: light-dark(#286c50, #9ed5ad);
    --md-success-container: light-dark(#c7eed4, #204c34);
    --md-on-success-container: light-dark(#145331, #b5f2cc);
    --md-warning-container: light-dark(#ffdea6, #533e13);
    --md-on-warning-container: light-dark(#624000, #ffdea6);
    --md-inverse-surface: light-dark(#173f35, #e4ebe1);
    --md-inverse-on-surface: light-dark(#f6f7f2, #173f35);
    --md-error: light-dark(#ba1a1a, #ffb4ab);
    --md-error-container: light-dark(#ffdad6, #6d1511);
    --md-radius: 24px;
    --md-radius-control: 14px;
    --md-radius-button: 16px;
    --md-radius-small: 12px;
    --md-ease-standard: cubic-bezier(.2, 0, 0, 1);
    --md-ease-enter: cubic-bezier(.05, .7, .1, 1);
    --md-ease-exit: cubic-bezier(.3, 0, .8, .15);
    --md-duration-short: 150ms;
    --md-duration-medium: 250ms;
    --md-duration-long: 350ms;
    --md-motion: var(--md-duration-short) var(--md-ease-standard);
    --md-motion-spatial: var(--md-duration-medium) var(--md-ease-standard);
    --md-state-hover: 8%;
    --md-state-pressed: 10%;
    --md-shadow: light-dark(rgb(23 63 53 / .08), rgb(0 0 0 / .32));
    --md-elevation-1: 0 1px 2px var(--md-shadow), 0 1px 3px 1px color-mix(in srgb, var(--md-shadow) 50%, transparent);
    --md-elevation-2: 0 2px 6px 2px var(--md-shadow), 0 1px 2px color-mix(in srgb, var(--md-shadow) 75%, transparent);
    --md-elevation-3: 0 4px 8px 3px var(--md-shadow), 0 1px 3px color-mix(in srgb, var(--md-shadow) 75%, transparent);
    --md-scrim: rgb(0 0 0 / .4);
    font-family: "Roboto", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--md-background);
    color: var(--md-on-surface);
  }
}
@layer components {
  .animate-spin { display: inline-flex; animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(1turn); } }
  .admin-filter-fields { margin: 0; padding: 0; border: 0; }
  .admin-loading { display: flex; align-items: center; gap: 12px; padding: 24px; color: var(--md-on-surface-variant); }

  .btn {
    display: inline-flex; justify-content: center; align-items: center; gap: 8px;
    min-block-size: 40px; padding: 10px 20px; border: 1px solid transparent; border-radius: var(--md-radius-button);
    color: var(--md-on-primary); background: var(--md-primary); font-size: 14px; font-weight: 500; letter-spacing: .1px;
    transition: background-color var(--md-motion), box-shadow var(--md-motion), border-radius var(--md-motion-spatial);
    &[data-variant="outline"] { color: var(--md-primary); background: transparent; border-color: var(--md-outline); }
    &[data-variant="ghost"] { color: var(--md-primary); background: transparent; }
    &[data-size^="icon"] { padding: 10px; inline-size: 40px; }
    @media (hover: hover) {
      &:hover:not(:disabled, [aria-disabled="true"]) { box-shadow: inset 0 0 0 100px color-mix(in srgb, currentColor var(--md-state-hover), transparent); }
    }
  }
  select {
    min-block-size: var(--md-field-height, 56px); inline-size: 100%; min-inline-size: 0; max-inline-size: 100%;
    padding: var(--md-field-padding-block, 15px) var(--md-field-padding-inline, 16px);
    border: 1px solid var(--md-outline); border-radius: var(--md-radius-control);
    font-size: var(--md-field-font-size, 16px); line-height: 24px;
    background: var(--md-surface); color: var(--md-on-surface);
    &::placeholder { color: var(--md-on-surface-variant); }
    &:focus { border-color: var(--md-primary); }
  }
  /* Inputs and selects share a density; table filters stay compact. Include the
     floating-label wrapper so its empty label is centered at the same height. */
  :is([data-slot="table-container"], [data-table-view="cards"], .material-filter-panel, .datetimepicker-time) :is(input[type="search"], select, .material-text-field:has(> input[type="search"])) {
    --md-field-height: 44px;
    --md-field-font-size: 14px;
    --md-field-padding-block: 9px;
    --md-field-padding-inline: 12px;
  }
  input[type="checkbox"] { accent-color: var(--md-primary); inline-size: 18px; block-size: 18px; margin: 0; vertical-align: middle; }
  select:not([multiple]):is(:not([size]), [size="1"]) {
    cursor: pointer; font-weight: 400;
    transition: background var(--md-motion), border-color var(--md-motion);
    &:hover:not(:disabled), &:open { background: var(--md-surface-high); border-color: var(--md-primary); }
    &:disabled { cursor: default; opacity: .5; }
  }
  /* Customize the native picker without replacing its keyboard/form behavior.
     Browsers without base-select retain their native options popup. */
  @supports (appearance: base-select) {
    select:not([multiple]):is(:not([size]), [size="1"]) {
      appearance: base-select;
      align-items: center; gap: 12px;
      &::picker-icon {
        content: ""; inline-size: 9px; block-size: 9px;
        border-inline-end: 2px solid currentColor; border-block-end: 2px solid currentColor;
        rotate: 45deg; margin: -4px 4px 0 auto; color: var(--md-on-surface-variant);
        transition: rotate var(--md-motion);
      }
      &:open::picker-icon { rotate: 225deg; color: var(--md-primary); }
      &::picker(select) {
        appearance: base-select;
        /* A border in the surface color insets the native scrollport, including
           its scrollbar. Padding alone leaves the scrollbar at the outer edge. */
        margin-block: 6px; padding: 0;
        border: 8px solid var(--md-surface-container); border-radius: 16px;
        outline: 1px solid var(--md-outline-variant);
        background: var(--md-surface-container); color: var(--md-on-surface);
        box-shadow: var(--md-elevation-2);
        max-block-size: min(360px, calc(100dvh - 24px));
        max-inline-size: calc(100vw - 24px);
        scrollbar-width: thin;
        scrollbar-color: var(--md-outline) var(--md-surface-container);
      }
      option {
        display: flex; align-items: center; gap: 12px;
        min-block-size: 44px; padding: 10px 12px; border-radius: 10px;
        color: var(--md-on-surface); overflow-wrap: anywhere;
        &:checked { background: var(--md-secondary-container); color: var(--md-on-secondary-container); font-weight: 550; }
        &:hover:not(:disabled) { box-shadow: inset 0 0 0 100px color-mix(in srgb, currentColor var(--md-state-hover), transparent); }
        &:focus-visible { outline: 2px solid var(--md-primary); outline-offset: -2px; }
        &:disabled { opacity: .5; }
        &::checkmark { color: var(--md-primary); }
      }
    }
  }
  .filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .filter-chip {
    position: relative; display: inline-flex; align-items: center; gap: 8px; min-block-size: 40px;
    padding: 8px 14px; border: 1px solid var(--md-outline); border-radius: 10px; cursor: pointer; font-weight: 500;
    input { position: absolute; opacity: 0; inset: 0; inline-size: 100%; block-size: 100%; }
    &:has(:checked) { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: transparent; }
    .chip-check { display: none; }
    &:has(:checked) .chip-check { display: inline; }
    &:has(:focus-visible) { outline: 3px solid var(--md-primary); outline-offset: 3px; }
    &:hover { box-shadow: inset 0 0 0 100px color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
  }
  .admin-status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--md-radius-small); font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--md-surface-high); color: var(--md-on-surface-variant); }
  .admin-status[data-status="created"] { background: var(--md-primary-container); color: var(--md-on-primary-container); }
  .admin-status[data-status="progress"] { background: light-dark(#ffdea6, #533e13); color: light-dark(#624000, #ffdea6); }
  .admin-status[data-status="completed"] { background: light-dark(#c7eed4, #204c34); color: light-dark(#145331, #b5f2cc); }
  .admin-status[data-status="error"] { background: var(--md-error-container); color: var(--md-error); }
  .admin-id { display: flex; gap: 6px; align-items: center; color: var(--md-primary); font-size: 12px; font-variant-numeric: tabular-nums; }
  .admin-id > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-id:hover { text-decoration: underline; }
  .admin-date { display: grid; font-variant-numeric: tabular-nums; }
  .admin-date span + span { color: var(--md-on-surface-variant); font-size: 12px; }
  .sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .filter-chip:has(:checked), [data-slot="table-row"]:has(input:checked) { outline: 2px solid Highlight; }
}

/* Native multi-select dropdown: top-layer popover escapes table overflow. */
@layer components {
  .material-filter-trigger {
    display: flex; align-items: center; gap: 8px; inline-size: 100%; min-block-size: 44px;
    padding: 10px 12px; border: 1px solid var(--md-outline); border-radius: var(--md-radius-small);
    background: var(--md-surface); color: var(--md-on-surface); text-align: start;
    > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; }
    &:hover, &[aria-expanded="true"] { background: var(--md-surface-high); border-color: var(--md-primary); }
    &[aria-expanded="true"] svg { rotate: 180deg; }
  }
  .material-filter-count { display: grid; place-items: center; min-inline-size: 22px; block-size: 22px; border-radius: 50%; background: var(--md-primary-container); color: var(--md-on-primary-container); font-size: 12px; }
  .material-filter-panel {
    position: fixed; position-anchor: auto; inset: auto;
    top: calc(anchor(bottom) + 6px); left: anchor(left); margin: 0;
    position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
    inline-size: min(300px, calc(100vw - 24px)); max-block-size: min(420px, calc(100dvh - 24px));
    overflow: clip; padding: 12px; border: 1px solid var(--md-outline-variant); border-radius: 16px;
    &:popover-open { display: flex; flex-direction: column; }
    background: var(--md-surface-container); color: var(--md-on-surface);
    box-shadow: var(--md-elevation-2); font-size: 14px;
    > header { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 8px; padding-inline: 4px; }
    > .material-text-field { flex-shrink: 0; align-self: stretch; margin-block: 12px 8px; }
  }
  .material-filter-options {
    display: grid; gap: 4px; min-block-size: 0; overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--md-outline) var(--md-surface-container);
    scrollbar-gutter: stable;
    &:hover, &:focus-within { scrollbar-color: var(--md-primary) var(--md-surface-container); }
    label { display: flex; align-items: center; gap: 12px; min-block-size: 44px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
    label:hover { box-shadow: inset 0 0 0 100px color-mix(in srgb, currentColor var(--md-state-hover), transparent); }
    label:has(:checked) { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
    input { flex-shrink: 0; }
    span { overflow-wrap: anywhere; }
    p { padding: 12px; color: var(--md-on-surface-variant); }
  }
}
