/* Compact overrides on top of Pico: smaller base type, tighter spacing, denser
   tables. Loaded after pico.min.css so these win the cascade. */

:root {
  /* Pico scales the root from this var (100% -> 131% across breakpoints);
     pinning it lower shrinks everything at every width. ~14px base. */
  --pico-font-size: 87.5%;
  --pico-line-height: 1.4;

  --pico-spacing: 0.75rem;
  --pico-block-spacing-vertical: 0.85rem;
  --pico-block-spacing-horizontal: 1rem;
  --pico-form-element-spacing-vertical: 0.4rem;
  --pico-form-element-spacing-horizontal: 0.6rem;
  --pico-typography-spacing-vertical: 0.85rem;
}

.container {
  max-width: 1080px;
}

h1 {
  font-size: 1.7rem;
  margin-bottom: 0.25rem;
}

hgroup > p {
  margin-bottom: 0;
}

table {
  font-size: 0.92rem;
  margin-bottom: 0;
}

th,
td {
  padding: 0.3rem 0.55rem;
}

thead a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

thead a:hover {
  text-decoration: underline;
}

button {
  font-size: 0.88rem;
}

input {
  margin-bottom: 0;
}

.status {
  margin-bottom: 0.6rem;
}

/* Recent fills: give the market name room, keep the abbreviated wallet on one
   line (full address shows on hover via the cell title). */
.fills .col-market {
  min-width: 18rem;
}

.fills .col-wallet {
  white-space: nowrap;
}

/* Positions: a market past its close time but not yet settled. A compact pill,
   not Pico's full-size text highlight, so it reads as a status next to the time. */
mark.settling {
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

/* Wallets: transient banner for a rejected control action (bad stake, copy cap),
   sat above the table. Hidden until JS fills it, cleared after a few seconds. */
.flash {
  margin-bottom: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 0.35rem;
  font-size: 0.85rem;
  color: var(--pico-color-red-550, #b3261e);
  background: var(--pico-color-red-50, rgba(179, 38, 30, 0.12));
}

/* Pager: Prev / page X of Y / Next on one compact row under each table. */
.pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.pager button {
  width: auto;
  margin-bottom: 0;
  padding: 0.15rem 0.6rem;
}

.pager span {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Wallets: keep every row the same height whether or not it carries the ACTIVE
   stake input and copy button, so a page block stays uniform across pages.
   Fix the row height and shrink the in-cell controls to fit within it. */
#wallets tbody tr {
  height: 2.3rem;
}

#wallets tbody td {
  white-space: nowrap;
}

#wallets td input,
#wallets td button {
  height: 1.6rem;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  line-height: 1.4;
}

/* Logout: tiny form top-right of the dashboard. */
.logout-form {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  margin: 0;
}

.logout-form button {
  width: auto;
  margin: 0;
  padding: 0.15rem 0.6rem;
  font-size: 0.8rem;
}

/* Tables scroll within their own box on tablet widths, but on phones the
   horizontal scroll is ugly and hard to use, so we reflow the table into a
   stack of cards there (see the @media block below). */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* On phone widths: collapse wide tables into a stack of "cards" (one per row).
   Each <td> pairs with its column header via the data-label attribute, laid
   out label : value. No horizontal scrolling — every column is readable in
   the viewport. Targets tables tagged .rwd-card so narrow tables that already
   fit (none today) keep their grid layout. */
@media (max-width: 640px) {
  .container {
    padding: 0 0.6rem;
  }

  .status {
    line-height: 1.55;
  }

  /* The fills market column's 18rem min-width would force overflow even inside
     the card transform; release it on phones. */
  .fills .col-market {
    min-width: 0;
    white-space: normal;
  }

  .rwd-card thead {
    display: none;
  }

  .rwd-card,
  .rwd-card tbody,
  .rwd-card tr,
  .rwd-card td {
    display: block;
    width: 100%;
  }

  .rwd-card tr {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--pico-muted-border-color, #f1f1f1);
  }

  .rwd-card td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.12rem 0;
    white-space: normal;
    text-align: right;
  }

  /* Label comes from data-label on each cell; spacing-only cells (the wallets
     action column) hide their ::before entirely. */
  .rwd-card td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
  }

  .rwd-card td[data-label=""]::before {
    content: none;
  }

  /* Inputs/buttons in the wallets action rows: keep them inline at the right
     edge of their row rather than Pico's full-width form defaults. */
  .rwd-card td input,
  .rwd-card td button {
    width: auto;
  }
}
