/* Design tokens
   Change --app-primary to rebrand the whole application. */
:root {
  --app-primary: #0f766e;
  --app-primary-hover: #115e56;
  --app-primary-active: #0c4a44;
  --app-primary-soft: #e6f2f1;
  --app-primary-rgb: 15, 118, 110;
  --app-primary-hover-rgb: 17, 94, 86;

  --app-secondary: #3d5a80;
  --app-secondary-hover: #2f4868;
  --app-secondary-active: #253a54;
  --app-secondary-soft: #e8eef5;
  --app-secondary-rgb: 61, 90, 128;
  --app-secondary-hover-rgb: 47, 72, 104;
  --app-on-secondary: #ffffff;

  --app-bg: #f5f7fa;
  --app-surface: #ffffff;
  --app-surface-muted: #f8fafc;
  --app-surface-disabled: #e9ecef;

  --app-border: #e4e7ec;
  --app-border-strong: #d0d5dd;

  --app-text: #16191d;
  --app-text-rgb: 22, 25, 29;
  --app-text-muted: #667085;
  --app-text-disabled: #98a2b3;
  --app-on-primary: #ffffff;

  --app-success: #198754;
  --app-success-rgb: 25, 135, 84;
  --app-success-bg: #d4edda;
  --app-success-bg-hover: #badbcc;
  --app-success-text: #0f5132;
  --app-danger: #dc3545;
  --app-danger-rgb: 220, 53, 69;
  --app-danger-bg: #f8d7da;
  --app-danger-bg-hover: #f5c2c7;
  --app-danger-text: #842029;
  --app-on-danger: #ffffff;
  --app-danger-strong-bg: #ffcccc;
  --app-danger-strong-text: #b02a37;
  --app-warning: #ffc107;
  --app-warning-rgb: 255, 193, 7;
  --app-warning-bg: #fff3cd;
  --app-warning-bg-hover: #ffe69c;
  --app-warning-text: #664d03;
  --app-on-warning: #664d03;
  --app-warning-strong-bg: #ffe6cc;
  --app-warning-strong-text: #997404;
  --app-info: #0dcaf0;
  --app-info-rgb: 13, 202, 240;
  --app-info-bg: #cff4fc;
  --app-info-text: #055160;

  --app-radius-sm: 8px;
  --app-radius-inner-sm: 7px;
  --app-radius: 12px;
  --app-radius-inner: 11px;
  --app-radius-lg: 16px;
  --app-radius-inner-lg: 15px;

  --app-shadow-rgb: 16, 24, 40;
  --app-shadow-xs: 0 1px 2px rgba(var(--app-shadow-rgb), 0.05);
  --app-shadow-sm: 0 1px 3px rgba(var(--app-shadow-rgb), 0.08), 0 1px 2px rgba(var(--app-shadow-rgb), 0.04);
  --app-shadow-md: 0 4px 12px rgba(var(--app-shadow-rgb), 0.08);
  --app-shadow-lg: 0 12px 28px rgba(var(--app-shadow-rgb), 0.12);

  --app-transition: 0.15s ease-in-out;

  /* Consumed by Bootstrap utilities such as .text-primary and .bg-primary */
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: var(--app-primary-rgb);
  --bs-secondary: var(--app-secondary);
  --bs-secondary-rgb: var(--app-secondary-rgb);
  --bs-success: var(--app-success);
  --bs-success-rgb: var(--app-success-rgb);
  --bs-warning: var(--app-warning);
  --bs-warning-rgb: var(--app-warning-rgb);
  --bs-danger: var(--app-danger);
  --bs-danger-rgb: var(--app-danger-rgb);
  --bs-info: var(--app-info);
  --bs-info-rgb: var(--app-info-rgb);

  /* Reboot builds the link colour from the -rgb pair; .nav-link, .pagination
     and .btn-link read the plain pair. Both are needed to retint every link. */
  --bs-link-color: var(--app-primary);
  --bs-link-color-rgb: var(--app-primary-rgb);
  --bs-link-hover-color: var(--app-primary-hover);
  --bs-link-hover-color-rgb: var(--app-primary-hover-rgb);
  --bs-body-color: var(--app-text);
  --bs-body-color-rgb: var(--app-text-rgb);

  color-scheme: light;
}

[data-theme="dark"] {
  --app-primary: #2dd4bf;
  --app-primary-hover: #5eead4;
  --app-primary-active: #14b8a6;
  --app-primary-soft: rgba(45, 212, 191, 0.16);
  --app-primary-rgb: 45, 212, 191;
  --app-primary-hover-rgb: 94, 234, 212;

  --app-secondary: #8ba3c7;
  --app-secondary-hover: #a8bdda;
  --app-secondary-active: #6f8fb5;
  --app-secondary-soft: rgba(139, 163, 199, 0.16);
  --app-secondary-rgb: 139, 163, 199;
  --app-secondary-hover-rgb: 168, 189, 218;
  --app-on-secondary: #0f1419;

  --app-bg: #0f1419;
  --app-surface: #1a222c;
  --app-surface-muted: #151c24;
  --app-surface-disabled: #243040;

  --app-border: #2c3640;
  --app-border-strong: #3d4a57;

  --app-text: #e8eef4;
  --app-text-rgb: 232, 238, 244;
  --app-text-muted: #9aa6b2;
  --app-text-disabled: #667085;
  --app-on-primary: #042f2e;

  --app-success: #75b798;
  --app-success-rgb: 117, 183, 152;
  --app-success-bg: #1a3d2e;
  --app-success-bg-hover: #214a38;
  --app-success-text: #d1e7dd;
  --app-danger: #ea868f;
  --app-danger-rgb: 234, 134, 143;
  --app-danger-bg: #4a1d24;
  --app-danger-bg-hover: #5c252e;
  --app-danger-text: #f8d7da;
  --app-on-danger: #4a1d24;
  --app-danger-strong-bg: #5c252e;
  --app-danger-strong-text: #f1aeb5;
  --app-warning: #ffda6a;
  --app-warning-rgb: 255, 218, 106;
  --app-warning-bg: #4a3b14;
  --app-warning-bg-hover: #5c4a1a;
  --app-warning-text: #ffe69c;
  --app-on-warning: #664d03;
  --app-warning-strong-bg: #5c4a1a;
  --app-warning-strong-text: #ffc107;
  --app-info: #6edff6;
  --app-info-rgb: 110, 223, 246;
  --app-info-bg: #163a44;
  --app-info-bg-hover: #1c4a56;
  --app-info-text: #cff4fc;

  --app-shadow-rgb: 0, 0, 0;

  --bs-primary: var(--app-primary);
  --bs-primary-rgb: var(--app-primary-rgb);
  --bs-secondary: var(--app-secondary);
  --bs-secondary-rgb: var(--app-secondary-rgb);
  --bs-success: var(--app-success);
  --bs-success-rgb: var(--app-success-rgb);
  --bs-warning: var(--app-warning);
  --bs-warning-rgb: var(--app-warning-rgb);
  --bs-danger: var(--app-danger);
  --bs-danger-rgb: var(--app-danger-rgb);
  --bs-info: var(--app-info);
  --bs-info-rgb: var(--app-info-rgb);
  --bs-link-color: var(--app-primary);
  --bs-link-color-rgb: var(--app-primary-rgb);
  --bs-link-hover-color: var(--app-primary-hover);
  --bs-link-hover-color-rgb: var(--app-primary-hover-rgb);
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-body-color-rgb: var(--app-text-rgb);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme-preference="system"]:not([data-theme="light"]) {
    --app-primary: #2dd4bf;
    --app-primary-hover: #5eead4;
    --app-primary-active: #14b8a6;
    --app-primary-soft: rgba(45, 212, 191, 0.16);
    --app-primary-rgb: 45, 212, 191;
    --app-primary-hover-rgb: 94, 234, 212;

    --app-secondary: #8ba3c7;
    --app-secondary-hover: #a8bdda;
    --app-secondary-active: #6f8fb5;
    --app-secondary-soft: rgba(139, 163, 199, 0.16);
    --app-secondary-rgb: 139, 163, 199;
    --app-secondary-hover-rgb: 168, 189, 218;
    --app-on-secondary: #0f1419;

    --app-bg: #0f1419;
    --app-surface: #1a222c;
    --app-surface-muted: #151c24;
    --app-surface-disabled: #243040;

    --app-border: #2c3640;
    --app-border-strong: #3d4a57;

    --app-text: #e8eef4;
    --app-text-rgb: 232, 238, 244;
    --app-text-muted: #9aa6b2;
    --app-text-disabled: #667085;
    --app-on-primary: #042f2e;

    --app-success: #75b798;
    --app-success-rgb: 117, 183, 152;
    --app-success-bg: #1a3d2e;
    --app-success-bg-hover: #214a38;
    --app-success-text: #d1e7dd;
    --app-danger: #ea868f;
    --app-danger-rgb: 234, 134, 143;
    --app-danger-bg: #4a1d24;
    --app-danger-bg-hover: #5c252e;
    --app-danger-text: #f8d7da;
    --app-on-danger: #4a1d24;
    --app-danger-strong-bg: #5c252e;
    --app-danger-strong-text: #f1aeb5;
    --app-warning: #ffda6a;
    --app-warning-rgb: 255, 218, 106;
    --app-warning-bg: #4a3b14;
    --app-warning-bg-hover: #5c4a1a;
    --app-warning-text: #ffe69c;
    --app-on-warning: #664d03;
    --app-warning-strong-bg: #5c4a1a;
    --app-warning-strong-text: #ffc107;
    --app-info: #6edff6;
    --app-info-rgb: 110, 223, 246;
    --app-info-bg: #163a44;
    --app-info-bg-hover: #1c4a56;
    --app-info-text: #cff4fc;

    --app-shadow-rgb: 0, 0, 0;

    --bs-primary: var(--app-primary);
    --bs-primary-rgb: var(--app-primary-rgb);
    --bs-secondary: var(--app-secondary);
    --bs-secondary-rgb: var(--app-secondary-rgb);
    --bs-success: var(--app-success);
    --bs-success-rgb: var(--app-success-rgb);
    --bs-warning: var(--app-warning);
    --bs-warning-rgb: var(--app-warning-rgb);
    --bs-danger: var(--app-danger);
    --bs-danger-rgb: var(--app-danger-rgb);
    --bs-info: var(--app-info);
    --bs-info-rgb: var(--app-info-rgb);
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: var(--app-primary-rgb);
    --bs-link-hover-color: var(--app-primary-hover);
    --bs-link-hover-color-rgb: var(--app-primary-hover-rgb);
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-body-color-rgb: var(--app-text-rgb);

    color-scheme: dark;
  }
}

/* Base */
body {
  background-color: var(--app-bg);
  color: var(--app-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  letter-spacing: -0.011em;
}

.lead {
  font-size: 1.05rem;
  color: var(--app-text-muted);
}

.text-muted {
  color: var(--app-text-muted) !important;
}

.text-success {
  color: var(--app-success) !important;
}

/* Link colour comes from the --bs-link-* tokens above, but Reboot still emits
   text-decoration: underline literally, so it has to be cleared here. The
   exclusions matter: a:hover outranks .btn and friends, so without them every
   anchor rendered as a button or nav item picks up an underline on hover. */
a:where(:not(.btn, .nav-link, .navbar-brand, .dropdown-item, .page-link, .list-group-item-action)) {
  text-decoration: none;
}

a:where(:not(.btn, .nav-link, .navbar-brand, .dropdown-item, .page-link, .list-group-item-action)):hover {
  text-decoration: underline;
}

hr {
  border-color: var(--app-border);
  opacity: 1;
}

/* Navigation */
.navbar.bg-light {
  background-color: var(--app-surface) !important;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-xs);
  padding: 0.5rem 0.75rem;
}

.navbar > .container {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.navbar .navbar-nav .nav-link {
  color: var(--app-text-muted);
  font-weight: 500;
  border-radius: var(--app-radius-sm);
  padding: 0.5rem 0.75rem;
  transition: background-color var(--app-transition), color var(--app-transition);
}

.navbar .navbar-nav .nav-link:hover,
.navbar .navbar-nav .nav-link:focus {
  color: var(--app-primary);
  background-color: var(--app-primary-soft);
}

.navbar-brand {
  color: var(--app-text-muted);
  font-weight: 600;
  letter-spacing: -0.011em;
  pointer-events: none;
}

.navbar-toggler {
  fill: var(--app-text-muted);
  border-radius: var(--app-radius-sm);
  border-color: var(--app-border);
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.2);
}

[data-theme="dark"] .navbar-toggler {
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28232, 238, 244, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

@media (prefers-color-scheme: dark) {
  html[data-theme-preference="system"]:not([data-theme="light"]) .navbar-toggler {
    --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28232, 238, 244, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  }
}

/* Cards */
.card {
  background-color: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-sm);
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--app-border);
  padding: 1.15rem 1.5rem;
  font-weight: 600;
}

.card-header:first-child {
  border-radius: var(--app-radius-inner-lg) var(--app-radius-inner-lg) 0 0;
}

.card-body {
  padding: 1.5rem;
}

/* Flush tables (p-0 / p-md-0) sit on the card edge; clip so bottom corners
   follow the card radius instead of the table’s square cells. */
.card > .card-body.p-0:last-child {
  overflow: hidden;
  border-bottom-left-radius: var(--app-radius-inner-lg);
  border-bottom-right-radius: var(--app-radius-inner-lg);
}

@media (min-width: 768px) {
  .card > .card-body.p-md-0:last-child {
    overflow: hidden;
    border-bottom-left-radius: var(--app-radius-inner-lg);
    border-bottom-right-radius: var(--app-radius-inner-lg);
  }
}

.card-footer {
  background-color: var(--app-surface-muted);
  border-top: 1px solid var(--app-border);
  padding: 1rem 1.5rem;
}

/* Buttons */
.btn {
  border-radius: var(--app-radius-sm);
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background-color var(--app-transition), border-color var(--app-transition),
    color var(--app-transition), box-shadow var(--app-transition);
}

.btn-sm {
  border-radius: var(--app-radius-sm);
  padding: 0.35rem 0.7rem;
}

.btn-lg {
  border-radius: var(--app-radius);
}

.btn:focus,
.btn:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.2);
}

.btn-primary {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
  color: var(--app-on-primary);
}

.btn-primary:hover {
  background-color: var(--app-primary-hover);
  border-color: var(--app-primary-hover);
  color: var(--app-on-primary);
}

.btn.btn-primary:active,
.btn.btn-primary:focus,
.btn.btn-check:checked + .btn.btn-primary,
.btn.btn-primary.active {
  background-color: var(--app-primary-active);
  border-color: var(--app-primary-active);
}

.btn.btn-primary:disabled,
.btn.btn-primary.disabled {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}

.btn.btn-outline-primary {
  color: var(--app-primary);
  border-color: var(--app-primary);
}

.btn.btn-outline-primary:hover,
.btn.btn-outline-primary:active,
.btn.btn-outline-primary:focus {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
  color: var(--app-on-primary);
}

/* Secondary is used exclusively for Back/Cancel actions, so it is rendered
   as a quiet neutral button rather than a solid grey slab. */
.btn.btn-secondary {
  background-color: var(--app-surface);
  border-color: var(--app-border-strong);
  color: var(--app-text);
}

.btn.btn-secondary:hover,
.btn.btn-secondary:active,
.btn.btn-secondary:focus {
  background-color: var(--app-surface-muted);
  border-color: var(--app-border-strong);
  color: var(--app-text);
}

.btn.btn-outline-secondary {
  color: var(--app-text-muted);
  border-color: var(--app-border-strong);
}

.btn.btn-outline-secondary:hover,
.btn.btn-outline-secondary:active,
.btn.btn-outline-secondary:focus {
  background-color: var(--app-surface-muted);
  border-color: var(--app-border-strong);
  color: var(--app-text);
}

/* Forms */
.form-label {
  font-weight: 500;
  color: var(--app-text);
  margin-bottom: 0.4rem;
}

.form-control,
.form-select {
  background-color: var(--app-surface);
  border-radius: var(--app-radius-sm);
  border-color: var(--app-border-strong);
  padding: 0.5rem 0.75rem;
  color: var(--app-text);
  transition: border-color var(--app-transition), box-shadow var(--app-transition);
}

/* Restores the room Bootstrap reserves for the chevron, which the shared
   padding above would otherwise collapse. The stroke is inlined in the data
   URI and cannot read --app-text-muted, so it must be changed by hand. */
.form-select {
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* Firefox refuses to paint author colours on <option> as soon as the <select>
   carries a background-image, which silently killed the occupied-slot styling
   on the time picker. Selects whose options are styled therefore drop the
   background chevron and take one from this wrapper instead. The !important is
   deliberate: Bootstrap re-adds a background-image on .is-invalid and .is-valid
   with higher specificity, and any image at all brings the bug back.
   The grid keeps the chevron centred on the select when the validation
   message underneath it becomes visible. */
.select-chevron {
  display: grid;
  grid-template-columns: 1fr;
}

.select-chevron > .form-select {
  grid-area: 1 / 1;
  background-image: none !important;
}

.select-chevron > .invalid-feedback {
  grid-area: 2 / 1;
}

.select-chevron::after {
  content: "";
  grid-area: 1 / 1;
  align-self: center;
  justify-self: end;
  width: 14px;
  height: 14px;
  margin-right: 0.85rem;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
/* */

.form-control-sm,
.form-select-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
  border-radius: var(--app-radius-sm);
}

.form-select-sm {
  padding-right: 2rem;
}
/* */

.form-control:focus,
.form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.15);
}

.form-control::placeholder {
  color: var(--app-text-muted);
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
  background-color: var(--app-surface-disabled);
  color: var(--app-text-disabled);
}

/* The drop-down list itself is drawn by the browser and ignores ordinary CSS,
   which is why its highlight stays the default blue. Chrome and Edge 135+ opt
   out of that via appearance: base-select. Anything else keeps the native
   list untouched. Limited to wider viewports so phones keep the OS picker,
   which is easier to use on touch than an in-page popover. */
@supports (appearance: base-select) {
  @media (min-width: 769px) {
    .form-select,
    .form-select::picker(select) {
      appearance: base-select;
    }

    /* base-select turns the chevron into a real child, so the control has to
       lay out as a row or Bootstrap's display:block stacks it under the label. */
    .form-select {
      display: flex;
      align-items: center;
      justify-content: space-between;
      background-image: none;
      padding-right: 0.75rem;
      gap: 0.5rem;
    }

    .form-select-sm {
      padding-right: 0.6rem;
    }

    /* Reuses the chevron above so Chrome matches the browsers that still get
       the native control, instead of base-select's solid triangle. */
    .form-select::picker-icon {
      content: "";
      flex: none;
      width: 14px;
      height: 14px;
      background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
      background-repeat: no-repeat;
      background-position: center;
      background-size: contain;
      transition: transform var(--app-transition);
    }

    .form-select:open::picker-icon {
      transform: rotate(180deg);
    }

    /* base-select supplies its own icon, so the wrapper must not add a second. */
    .select-chevron::after {
      display: none;
    }

    .form-select::picker(select) {
      background-color: var(--app-surface);
      border: 1px solid var(--app-border);
      border-radius: var(--app-radius);
      box-shadow: var(--app-shadow-md);
      padding: 0.35rem;
      margin-top: 0.25rem;
    }

    .form-select option {
      border-radius: var(--app-radius-sm);
      padding: 0.5rem 0.75rem;
      color: var(--app-text);
    }

    .form-select option::checkmark {
      display: none;
    }

    .form-select option:checked {
      background-color: var(--app-primary-soft);
      color: var(--app-primary);
      font-weight: 500;
    }

    .form-select option:not(:disabled):hover,
    .form-select option:not(:disabled):focus {
      background-color: var(--app-primary);
      color: var(--app-on-primary);
    }
  }
}

.form-check-input,
.form-check-label {
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}

.form-check-input:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.15);
}

.input-group-text {
  background-color: var(--app-surface-muted);
  border-color: var(--app-border-strong);
  border-radius: var(--app-radius-sm);
  color: var(--app-text-muted);
}

/* Tables */
/* 5.3 resolves cell colours through --bs-table-*-bg/-color rather than the
   --bs-table-accent-bg the row selectors used to set, so the palette has to be
   declared on .table itself. --bs-table-color is spelled out because its
   default, --bs-emphasis-color, is pure black rather than the body text tone. */
.table {
  --bs-table-color: var(--app-text);
  --bs-table-bg: var(--app-surface);
  --bs-table-hover-bg: var(--app-primary-soft);
  --bs-table-hover-color: var(--app-text);
  --bs-table-striped-bg: rgba(var(--app-shadow-rgb), 0.02);
  --bs-table-striped-color: var(--app-text);
  border-color: var(--app-border);
  color: var(--app-text);
}

.table > thead th {
  background-color: var(--app-surface-muted);
  color: var(--app-text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--app-border);
  padding: 0.75rem;
}

.table > tbody td {
  padding: 0.75rem;
  border-color: var(--app-border);
}

.table-responsive {
  border-radius: var(--app-radius);
}

/* Badges */
.badge {
  font-weight: 500;
  border-radius: var(--app-radius-sm);
  padding: 0.35em 0.7em 0.45em;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.badge.bg-primary {
  color: var(--app-on-primary);
}

.badge.bg-secondary {
  color: var(--app-on-secondary);
}

.badge.bg-danger {
  color: var(--app-on-danger);
}

.badge.bg-success {
  color: var(--app-success-text);
  background-color: var(--app-success-bg) !important;
}

.badge.bg-info {
  color: var(--app-info-text);
  background-color: var(--app-info-bg) !important;
}

.badge.bg-warning,
.badge.bg-warning.text-dark {
  color: var(--app-on-warning);
}

/* Accordion */
.accordion {
  --bs-accordion-border-color: var(--app-border);
}

.accordion-item {
  border-color: var(--app-border);
  background-color: var(--app-surface);
}

.accordion-item:first-of-type,
.accordion-item:first-of-type .accordion-button {
  border-top-left-radius: var(--app-radius);
  border-top-right-radius: var(--app-radius);
}

.accordion-item:last-of-type,
.accordion-item:last-of-type .accordion-button.collapsed {
  border-bottom-left-radius: var(--app-radius);
  border-bottom-right-radius: var(--app-radius);
}

.accordion-button {
  font-weight: 500;
  color: var(--app-text);
  padding: 1rem 1.25rem;
}

.accordion-button:not(.collapsed) {
  color: var(--app-primary);
  background-color: var(--app-primary-soft);
  box-shadow: none;
}

.accordion-button:focus {
  /* border-color: var(--app-border); */
  /* box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.15); */
  box-shadow: none;
}

/* Chevron shape via mask so fill can use theme tokens. */
.accordion-button::after {
  background-image: none;
  background-color: var(--app-text);
  -webkit-mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: var(--bs-accordion-btn-icon-width);
  mask-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: var(--bs-accordion-btn-icon-width);
}

.accordion-button:not(.collapsed)::after {
  background-image: none;
  background-color: var(--app-primary);
}

/* Dropdowns */
.dropdown-menu {
  background-color: var(--app-surface);
  border-color: var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-md);
  padding: 0.35rem;
  color: var(--app-text);
}

.dropdown-item {
  border-radius: var(--app-radius-sm);
  padding: 0.5rem 0.75rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--app-primary-soft);
  color: var(--app-primary);
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: var(--app-primary);
  color: var(--app-on-primary);
}

/* Modals */
.modal-content {
  background-color: var(--app-surface);
  color: var(--app-text);
  border: none;
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-lg);
}

.modal-header,
.modal-footer {
  border-color: var(--app-border);
  padding: 1.15rem 1.5rem;
}

/* .modal-content sets --app-text; keep titles readable on warning headers. */
.modal-header.bg-warning,
.card-header.bg-warning {
  color: var(--app-on-warning);
}

.modal-body {
  padding: 1.5rem;
}

/* Alerts */
.alert {
  border-radius: var(--app-radius);
  border-width: 1px;
  padding: 1rem 1.25rem;
}

/* List groups */
.list-group-item {
  border-color: var(--app-border);
  color: var(--app-text);
}

.list-group-item:first-child {
  border-top-left-radius: var(--app-radius-sm);
  border-top-right-radius: var(--app-radius-sm);
}

.list-group-item:last-child {
  border-bottom-left-radius: var(--app-radius-sm);
  border-bottom-right-radius: var(--app-radius-sm);
}

.list-group-item-action:hover,
.list-group-item-action:focus {
  background-color: var(--app-primary-soft);
  color: var(--app-primary);
}

/* Footer */
footer.border-top {
  border-color: var(--app-border) !important;
}
