[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: #000;
  background: #fff;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

h1 {
  margin: 0 0 20px;
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
}

label {
  font-size: 13px;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

nav {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

a {
  color: #000;
}

a[aria-current='page'] {
  font-weight: 600;
}

input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 380px;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid #000;
  border-radius: 0;
  font: inherit;
}

input[readonly] {
  background: #fff;
}

select,
textarea {
  max-width: 100%;
  padding: 8px 10px;
  font: inherit;
}

textarea {
  resize: vertical;
}

input:not([type='checkbox'], [type='radio']),
select {
  min-height: 40px;
}

input[type='checkbox'],
input[type='radio'] {
  display: inline-block;
  width: auto;
  margin: 0 6px 0 0;
}

.page-content > button,
form button,
dialog button,
.device-actions button,
#history-section button {
  margin: 4px 0;
  padding: 6px 10px;
  border: 1px solid #000;
  border-radius: 0;
  color: #000;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid #000;
  outline-offset: -2px;
}

form p {
  margin: 12px 0;
}

dl {
  display: grid;
  grid-template-columns: minmax(100px, 160px) minmax(0, 1fr);
  gap: 8px 16px;
  max-width: 760px;
  padding: 12px 0;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  font-family: inherit;
  overflow: auto;
  font-size: 13px;
}

dialog {
  box-sizing: border-box;
  width: min(480px, calc(100vw - 32px));
  max-width: 480px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 20px;
  border: 1px solid #000;
  border-radius: 0;
  color: #000;
  background: #fff;
}

dialog::backdrop {
  background: rgb(0 0 0 / 25%);
}

h2 {
  margin-top: 0;
  font-size: 20px;
}

.page-content {
  padding: 16px;
}

body > #status {
  margin: 12px 16px;
  padding: 10px 12px;
  border-left: 2px solid #000;
  background: #f5f5f5;
}

body > #status:empty,
[role='alert']:empty {
  display: none;
}

body:has(#login:not([hidden])) > #status {
  max-width: 420px;
  margin: 16px auto;
}

#login.page-content {
  width: calc(100% - 32px);
  max-width: 420px;
  margin: 40px auto;
  padding: 0;
}

#login input {
  max-width: none;
}

#login > button {
  width: 100%;
  margin-top: 8px;
}

.page-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  overflow-x: auto;
  border-bottom: 1px solid #000;
}

.page-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.page-tabs a[aria-current='page'] {
  border-bottom-color: #000;
  font-weight: 600;
}

.page-tabs a:hover {
  background: #eee;
}

.page-tabs a:focus-visible {
  background: #000;
  color: #fff;
  outline: 2px solid #000;
  outline-offset: -2px;
}

@media (max-width: 600px) {
  :is(#login, dialog, .cart-management, #settings-view) :is(input, select, textarea) {
    font-size: 16px;
  }
}

/* App theme: shared by the web app and the Pi kiosk.
   Theme paint uses important declarations so page layout rules cannot change it.
   Page styles may still size and arrange controls for tables, maps and forms.
   The shared header and tee-sheet calendar retain their original navigation styles.
   Google Maps controls keep their native styling; custom cart labels supply their own border. */
:root {
  --theme-ink: #000;
  --theme-paper: #fff;
  --theme-hover: #eee;
  --theme-focus: #000;
  --theme-control-padding: 8px 12px;
  --theme-control-font-size: 14px;
}

@layer app-theme {
  *,
  *::before,
  *::after {
    border-radius: 0 !important;
  }

  :is(button, input, select, textarea, summary, a) {
    -webkit-tap-highlight-color: transparent;
  }

  :is(button, [role='button'], .cart-actions a, .dashboard-map-link, nav a):not(
    :where(.site-header *, .booking-header *, .tee-calendar-navigation *, .page-tabs *, #cart-map *)
  ) {
    box-sizing: border-box;
    border: 1px solid var(--theme-ink) !important;
    background: var(--theme-paper) !important;
    color: var(--theme-ink) !important;
    padding: var(--theme-control-padding) !important;
    min-height: 40px;
    font-family: inherit !important;
    font-size: var(--theme-control-font-size) !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    cursor: pointer;
  }

  :is(input, select, textarea):not(
    :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
  ) {
    border: 1px solid var(--theme-ink) !important;
    background: var(--theme-paper) !important;
    color: var(--theme-ink) !important;
    accent-color: var(--theme-ink);
    box-shadow: none !important;
  }

  summary:not(:where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)) {
    color: var(--theme-ink) !important;
    background: var(--theme-paper) !important;
  }

  :is(button, a):not(
      :where(
        .site-header *,
        .booking-header *,
        .tee-calendar-navigation *,
        .page-tabs *,
        #cart-map *
      )
    )[aria-current]:not([aria-current='false']),
  button[aria-pressed='true']:not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ),
  button.is-selected:not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ) {
    background: var(--theme-focus) !important;
    color: var(--theme-paper) !important;
  }

  @media (hover: hover) {
    :is(button, [role='button'], a, summary, input, select, textarea):not(
        :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
      ):hover:not(:focus):not(:disabled):not([aria-disabled='true']) {
      background: var(--theme-hover) !important;
      color: var(--theme-ink) !important;
    }
  }

  :is(button, [role='button'], a, summary, input, select, textarea):not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ):focus:not(:disabled) {
    background: var(--theme-focus) !important;
    color: var(--theme-paper) !important;
    border-color: var(--theme-ink) !important;
    outline: 2px solid var(--theme-ink) !important;
    outline-offset: -2px !important;
  }

  :is(input, textarea):not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ):focus::placeholder {
    color: #ccc !important;
  }

  /* Native option popups should remain readable independently of select focus. */
  select
    option:not(:where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)) {
    background: var(--theme-paper) !important;
    color: var(--theme-ink) !important;
  }

  :is(button, input, select, textarea):not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ):disabled,
  [aria-disabled='true']:not(
    :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
  ) {
    background: var(--theme-paper) !important;
    color: var(--theme-ink) !important;
    opacity: 0.45 !important;
    cursor: default !important;
  }
}

@layer app-theme {
  /* Browser autofill paints over background-color; keep it in the same theme. */
  input:is(:autofill, :-webkit-autofill):not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ) {
    -webkit-text-fill-color: var(--theme-ink) !important;
    box-shadow: inset 0 0 0 1000px var(--theme-paper) !important;
  }
  input:is(:autofill, :-webkit-autofill):not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ):hover:not(:focus):not(:disabled) {
    box-shadow: inset 0 0 0 1000px var(--theme-hover) !important;
  }
  input:is(:autofill, :-webkit-autofill):not(
      :where(.site-header *, .booking-header *, .tee-calendar-navigation *, #cart-map *)
    ):focus:not(:disabled) {
    -webkit-text-fill-color: var(--theme-paper) !important;
    box-shadow: inset 0 0 0 1000px var(--theme-focus) !important;
    caret-color: var(--theme-paper);
  }
}

/* Shared map popups on staff and cart screens. */
.cart-details {
  min-width: 220px;
  max-width: 300px;
  color: #000;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.cart-details > strong {
  display: block;
  font-size: 16px;
}

.cart-details p {
  margin: 6px 0;
}

.cart-position-summary {
  color: #555;
  font-size: 12px;
}

.cart-map-assignment {
  margin: 12px 0;
}

.cart-map-assignment > a {
  display: inline-block;
  padding: 6px 0;
  font-weight: 600;
}

.cart-location-details {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #ddd;
}

.cart-location-details summary {
  padding: 4px 0;
  cursor: pointer;
  font-size: 12px;
}

.cart-details dl {
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
  padding: 8px 0 0;
  border: 0;
  font-size: 12px;
}

.cart-details :is(a, summary):hover {
  background: #eee;
}

.cart-details :is(a, summary):focus-visible {
  outline: 2px solid #000;
  outline-offset: -2px;
}
