/* Structural rules every component needs regardless of look: reset,
   popover placement, busy buttons, loading placeholders, table basics.
   Link before ds.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.num {
  font-variant-numeric: tabular-nums;
}

.select,
.datepicker,
.menu-wrap {
  position: relative;
}
.listbox,
.menu,
.dp-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 60;
  margin: 0;
  list-style: none;
}
.row-menu .menu {
  left: auto;
  right: 0;
}
.drop-up > .listbox,
.drop-up > .menu,
.drop-up > .dp-pop {
  top: auto;
  bottom: calc(100% + 4px);
}
.listbox {
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
}
.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.option-check {
  visibility: hidden;
}
.option[aria-selected="true"] .option-check {
  visibility: visible;
}
.select-trigger,
.dp-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.select-trigger .ico-chevron {
  margin-left: auto;
}
.dp-grid {
  border-collapse: collapse;
}
.dp-day {
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.dp-head,
.dp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled {
  cursor: not-allowed;
}
.btn .spinner {
  display: none;
}
.btn.is-busy {
  pointer-events: none;
}
.btn.is-busy > :not(.spinner) {
  visibility: hidden;
}
.btn.is-busy .spinner {
  display: block;
  position: absolute;
  inset: 0;
  margin: auto;
}

.toast-region {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.toast-close {
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  padding: 4px;
}
.toast-close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

dialog.dialog {
  padding: 0;
  border: 0;
  color: var(--text);
  max-width: calc(100vw - 32px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.field {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field-msg {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.switch {
  position: relative;
  flex: none;
  padding: 0;
}
.switch-thumb {
  position: absolute;
  display: block;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.check input {
  appearance: none;
  margin: 0;
  flex: none;
  display: grid;
  place-content: center;
  cursor: pointer;
}
.check input::before {
  content: "";
}
.chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner-text {
  flex: 1;
  min-width: 0;
}
.empty {
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 12px;
}
.empty-title {
  margin: 0;
}
.tabs {
  display: inline-flex;
}
.progress {
  position: relative;
  overflow: hidden;
}
.progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
}
.progress-indeterminate > span {
  width: 35%;
  animation: ds-indeterminate 1.4s ease-in-out infinite;
}
@keyframes ds-indeterminate {
  from {
    left: -35%;
  }
  to {
    left: 100%;
  }
}
.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
/* Loading: elements marked .skel become placeholders while an ancestor is loading. */
.loading-line,
.page-progress {
  display: none;
}
.is-loading .loading-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.is-loading .page-progress {
  display: block;
}
.is-loading .skel {
  color: transparent !important;
  user-select: none;
}
.is-loading .chip.skel {
  background: none !important;
  border-color: transparent !important;
}
.is-loading .chip.skel > * {
  visibility: hidden;
}

.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  white-space: nowrap;
}
.table .num {
  text-align: right;
}
.table .col-date {
  text-align: left;
}
.chip-pct {
  margin-left: 0.35em;
}
.table .col-actions {
  width: 1%;
  text-align: right;
}
kbd {
  font: inherit;
}

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