/* Shared control surfaces, loaded after page styles. These !important surface
   rules intentionally replace legacy page-specific fills without changing layout. */
:root {
  --control-fill: var(--paper);
  --control-edge: var(--ink);
  --control-shadow: 0 2px 4px color-mix(in srgb, var(--ink) 15%, transparent);
}
:is(button, a.button, [role="tab"], .tab-bar a, .subtabs a, .has-tip, .unconfirmed-mark) {
  border: 1px solid var(--control-edge) !important;
  box-shadow: var(--control-shadow) !important;
}
:is(button, a.button, [role="tab"], .tab-bar a, .subtabs a, .has-tip, .unconfirmed-mark):not(.primary, .danger, .chosen, .active, .picked, [aria-pressed="true"], [aria-selected="true"], [aria-current]) {
  background: var(--control-fill) !important;
  color: var(--ink) !important;
}
/* Compact inline actions and tooltip triggers still need a visible edge. */
button.link { border-radius: var(--radius); padding: 2px 6px; text-decoration: none; }
.has-tip { border-radius: 4px; padding: 1px 3px; }
.has-tip .unconfirmed-mark { border: 0 !important; box-shadow: none !important; background: none !important; }
:is(button, a.button):not(:disabled, [aria-disabled="true"]):hover {
  box-shadow: 0 2px 6px color-mix(in srgb, var(--ink) 25%, transparent) !important;
}
:is(button, a.button):disabled, :is(button, a.button)[aria-disabled="true"] { box-shadow: none !important; }
@media print {
  .has-tip, .unconfirmed-mark { box-shadow: none !important; }
}

/* Selected pills retain semantic fills; active tabs retain a clear fill cue. */
:is([role="tab"][aria-selected="true"], .tab-bar [aria-current="page"], .subtabs [aria-current="page"]) {
  background: var(--ink) !important;
  color: var(--paper) !important;
}
:is(button, a.button)[aria-pressed="true"], button.chosen, button.picked {
  box-shadow: inset 0 0 0 1px currentColor, var(--control-shadow) !important;
}
button.danger { border-color: var(--red-pen) !important; }

/* Tab books: soft segmented rail, distinct from outlined action buttons.
   Keep .tabs' existing responsive visibility and the fixed mobile nav layout. */
:root :is([role="tablist"], .provider-tabs, .admin-tabs, .invoice-review-views) {
  display: flex !important;
}
:root :is([role="tablist"], .provider-tabs, .admin-tabs, .invoice-review-views, .tabs) {
  gap: 4px !important;
  flex-wrap: nowrap !important;
  padding: 4px !important;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--edge) !important;
  border-radius: 8px;
  background: color-mix(in srgb, var(--focus) 7%, var(--paper)) !important;
}
:root :is([role="tablist"], .provider-tabs, .admin-tabs, .invoice-review-views, .tabs) > :is(button, a, [role="tab"]) {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px !important;
  margin: 0 !important;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  background: transparent !important;
  color: var(--ink-soft) !important;
  box-shadow: none !important;
  text-decoration: none;
  white-space: nowrap;
}
:root :is([role="tablist"], .provider-tabs, .admin-tabs, .invoice-review-views, .tabs) > :is([aria-selected="true"], [aria-pressed="true"], [aria-current="page"], .chosen, .active) {
  background: var(--paper) !important;
  color: var(--ink) !important;
  border-color: var(--edge) !important;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 10%, transparent) !important;
  font-weight: 700;
}
:root :is([role="tablist"], .provider-tabs, .admin-tabs, .invoice-review-views, .tabs) .count {
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 24px;
  background: color-mix(in srgb, var(--ink) 8%, var(--paper)) !important;
  color: var(--ink) !important;
  font-size: var(--text-sm);
}
[role="tab"][aria-selected="true"] .count { background: color-mix(in srgb, var(--focus) 16%, var(--paper)) !important; }
@media (pointer: coarse) {
  :root :is([role="tablist"], .provider-tabs, .admin-tabs, .invoice-review-views, .tabs) > :is(button, a, [role="tab"]) { min-height: 44px; }
}

/* Invoice item names are text navigation within the review, not action buttons. */
.compact-invoice-review .compact-quick-table .compact-item-name button,
.compact-invoice-review .compact-quick-table .compact-item-name button:hover {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  border-radius: 0;
}
.compact-invoice-review .compact-quick-table .compact-item-name button:hover { text-decoration: underline; text-underline-offset: 3px; }
.compact-invoice-review .compact-quick-table .compact-item-name button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* Shared table-name navigation: opt in for names, never bulk/sort/action controls. */
table :is(button,a).table-item-link,
table :is(button,a).table-item-link:hover {
 border: 0 !important; box-shadow: none !important; background: transparent !important;
 color: var(--ink) !important; border-radius: 0; padding: 4px 0;
 font: inherit; font-weight: 600 !important; text-align: left;
 white-space: normal; overflow-wrap: anywhere; text-decoration: none;
}
table :is(button,a).table-item-link:hover { text-decoration: underline; text-underline-offset: 3px; }
table :is(button,a).table-item-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (pointer: coarse) { table :is(button,a).table-item-link { display: inline-flex; align-items: center; min-height: 44px; } }
