/* The Guild bank page: the Stock table (cards on phones) with its switch, the
   Requests lists, the Settings tab, and the item, activity, approve and
   reject dialogs. */

/* Stock */
.bank-intro {
  max-width: 760px;
}

.bank-toolbar {
  align-items: center;
  justify-content: flex-start;
}

.bank-toolbar .search-label {
  margin-left: 0;
}

.bank-count {
  margin: 0 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* The visually hidden Actions heading stays inside the scrolling wrap. */
.bank-table-wrap {
  position: relative;
}

/* Long headings take two lines, so the table fits beside the sidebar. */
.bank-table .th-label {
  display: block;
  padding: 10px 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bank-table th {
  padding: 0 10px;
  vertical-align: bottom;
}

.bank-table td {
  padding: 6px 10px;
}

.bank-table .bank-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bank-table .bank-item-cell {
  min-width: 190px;
  white-space: normal;
}

/* The note and the pending count line up with the name, past the icon. */
.bank-item-note,
.bank-pending {
  display: block;
  margin: 0 0 2px 38px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.bank-pending {
  font-size: 11px;
  color: var(--warning);
}

.bank-out {
  color: var(--danger);
  font-weight: 600;
}

.bank-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.bank-icon-button {
  display: inline-grid;
  place-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
}

.bank-icon-button:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.bank-icon-button.is-danger:hover {
  border-color: var(--danger-border);
  color: var(--danger);
}

.bank-icon-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.bank-request-actions .button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

/* The "Shown in /guildbank" switch: a pill with a knob, green while shown. */
.bank-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 82px;
  height: 30px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bank-switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transform: translateY(-50%);
  transition: left 0.15s ease;
}

.bank-switch[aria-checked="true"] {
  padding: 0 32px 0 14px;
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.bank-switch[aria-checked="true"]::before {
  left: calc(100% - 24px);
  background: var(--success);
}

.bank-switch:hover {
  border-color: var(--border-hover);
}

.bank-switch:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .bank-switch::before {
    transition: none;
  }
}

/* Requests */
.bank-request-section {
  margin-top: 22px;
}

.bank-request-section + .bank-request-section {
  margin-top: 28px;
}

.bank-request-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 15px;
}

.bank-section-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.bank-requests {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.bank-request {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.bank-request:first-child {
  border-top: 0;
}

.bank-request:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.bank-request-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-width: 0;
}

.bank-request-item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  min-width: 0;
}

.bank-request-amount {
  font-size: 13px;
}

.bank-request-item small {
  font-size: 12px;
  color: var(--text-muted);
}

.bank-request-who {
  font-size: 13px;
  color: var(--text-secondary);
}

.bank-request-who strong {
  color: var(--text-primary);
}

.bank-request-state {
  grid-column: 1;
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.bank-short {
  margin-left: 6px;
  color: var(--warning);
  font-weight: 600;
}

.bank-request-actions {
  display: flex;
  gap: 6px;
  grid-column: 2;
  grid-row: 1 / span 2;
}

.bank-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Settings */
.bank-settings {
  max-width: 900px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.bank-settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 12px 28px;
  padding: 22px 24px;
  border-top: 1px solid var(--border);
}

.bank-settings-row:first-child {
  border-top: 0;
}

.bank-settings-head h2 {
  margin: 0 0 6px;
  font-size: 15px;
}

.bank-settings-body label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}

.bank-settings-body input[type="number"] {
  max-width: 140px;
}

.bank-channel-state {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.bank-channel-state.is-ok {
  color: var(--success);
}

.bank-channel-state.is-warning {
  color: var(--warning);
}

.bank-settings-actions {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Dialogs */
dialog.bank-item-dialog,
dialog.bank-activity-dialog {
  max-width: 600px;
}

.bank-form {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.bank-form label:not(.choice) {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}

.bank-form .field-error,
.bank-form .form-note {
  margin: -6px 0 0;
}

.bank-form label.choice {
  display: flex;
  justify-self: start;
}

.bank-pick {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.bank-pick label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}

.bank-catalog-results {
  display: grid;
  gap: 4px;
  max-height: 280px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.bank-catalog-results:empty {
  display: none;
}

.bank-catalog-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.bank-catalog-option small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.bank-catalog-option:hover:not(:disabled) {
  border-color: var(--accent-border);
}

.bank-catalog-option:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.bank-catalog-option:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bank-picked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 18px;
}

.bank-picked:empty {
  display: none;
}

.bank-activity-body {
  max-height: min(420px, 60dvh);
  margin-top: 16px;
  overflow-y: auto;
}

.bank-activity {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bank-activity-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.bank-activity-row:first-child {
  border-top: 0;
}

.bank-activity-row time {
  font-size: 12px;
  color: var(--text-muted);
}

.bank-activity-stock {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Phones: each item is a card, its numbers in a two-column grid. */
@media (max-width: 640px) {
  .bank-count {
    flex-basis: 100%;
    margin: 0;
  }

  .bank-toolbar .search-label,
  .bank-toolbar .search-label input {
    width: 100%;
  }

  .bank-toolbar .search-label {
    flex: 1 1 100%;
  }

  .bank-table-wrap {
    overflow: visible;
    border: 0;
    background: none;
  }

  .bank-table,
  .bank-table tbody,
  .bank-table tr,
  .bank-table td {
    display: block;
  }

  .bank-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .bank-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 14px;
    margin-bottom: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
  }

  .bank-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    max-width: none;
    padding: 6px 0;
    border-top: 0;
    white-space: normal;
  }

  .bank-table td[data-label]::before {
    content: attr(data-label);
    flex: none;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  .bank-table .bank-item-cell,
  .bank-table .bank-switch-cell,
  .bank-table td[data-label="Max per request"],
  .bank-table .bank-actions-cell {
    grid-column: 1 / -1;
  }

  .bank-table td.bank-number {
    text-align: right;
  }

  .bank-table .bank-item-cell {
    display: block;
    min-width: 0;
  }

  .bank-table .bank-actions-cell {
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .bank-row-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .bank-request {
    grid-template-columns: minmax(0, 1fr);
  }

  .bank-request-actions {
    grid-column: 1;
    grid-row: auto;
    margin-top: 6px;
  }

  .bank-request-actions .button {
    flex: 1 1 0;
  }

  .bank-settings-row {
    grid-template-columns: minmax(0, 1fr);
    padding: 18px 16px;
  }

  .bank-activity-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .bank-activity-row time {
    grid-column: 1 / -1;
  }
}
