/* Palette ported from the gun's lib/theme.dart so the two read as one family. */
:root {
  --blue-dark: #0b6fb5;
  --blue: #1488c9;
  --blue-light: #2aa6e5;
  --ink: #1c2330;
  --ash: #5a6577;
  --paper: #f4f6fa;
  --line: #dfe4ec;
  --card: #ffffff;
  --black: #101418;
  --green: #1f9d55;
  --green-soft: #e7f6ed;
  --amber: #d97706;
  --amber-soft: #fff4e2;
  --danger: #e83939;
  --danger-soft: #fdece9;
  --blue-soft: #eaf3ff;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

a { color: var(--blue-dark); }

/* ------------------------------------------------------------------ gate */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0b6fb5 0%, #101418 100%);
}

.gate-box {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(16, 20, 24, .3);
}

.gate-title { margin: 0 0 6px; font-size: 20px; letter-spacing: -.2px; }
.gate-sub { margin: 0 0 20px; color: var(--ash); font-size: 13px; }

/* ---------------------------------------------------------------- chrome */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-weight: 650;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.2px;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-note {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  color: var(--ash);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

.view { max-width: 1080px; margin: 0 auto; padding: 28px; }

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 28px 40px;
  color: var(--ash);
  font-size: 12px;
}

/* --------------------------------------------------------------- controls */

.input {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 136, 201, .16); }

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
}
.btn-primary { background: var(--blue-dark); color: #fff; }
.btn-primary:hover { background: #095e9b; }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-quiet {
  background: transparent;
  color: var(--ash);
  border-color: var(--line);
  padding: 6px 12px;
  font-size: 13px;
}
.btn-quiet:hover { color: var(--ink); border-color: #c6cedd; }
.btn-block { width: 100%; margin-top: 14px; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}
.segmented button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ash);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 16px;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--blue-dark); color: #fff; }

.error {
  margin: 12px 0 0;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f6cfc8;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13.5px;
}

.hint { color: var(--ash); font-size: 13px; margin: 10px 0 0; }

/* ---------------------------------------------------------------- lookup */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
}

.lookup { max-width: 560px; margin: 40px auto 0; }
.lookup h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.3px; }
.lookup .lede { margin: 0 0 22px; color: var(--ash); font-size: 14px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  color: var(--ash);
  margin-bottom: 7px;
}
.lookup-row { display: flex; gap: 10px; margin-top: 18px; align-items: center; }

/* --------------------------------------------------------------- results */

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ash);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 16px;
}
.crumb:hover { color: var(--blue-dark); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 20px; letter-spacing: -.2px; }
.page-head .sub { margin: 4px 0 0; color: var(--ash); font-size: 13px; }
.page-head .sub code { font-family: var(--mono); font-size: 12.5px; }

.rows { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: grid;
  grid-template-columns: 150px 92px 238px 232px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.rows.no-net .row { grid-template-columns: 150px 92px 238px minmax(0, 1fr) 92px; }

.row:hover { border-color: var(--blue-light); box-shadow: 0 3px 14px rgba(16, 20, 24, .07); }

.row-type { display: flex; align-items: center; gap: 9px; font-weight: 650; min-width: 0; }
.row-type .glyph {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  font-size: 14px;
  background: var(--paper);
  flex: none;
}
.row-type-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.row-type-label { line-height: 1.25; }
.row-ref {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: #9aa4b4;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-who {
  font-size: 12.5px;
  color: var(--ash);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-when { text-align: right; font-size: 13px; }
.row-when .t { color: var(--ash); }

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  white-space: nowrap;
}

.empty { text-align: center; padding: 46px 24px; }
.empty h2 { margin: 0 0 8px; font-size: 17px; }
.empty p { margin: 0 auto 16px; color: var(--ash); max-width: 460px; font-size: 14px; }

.skeleton {
  height: 62px;
  border-radius: 12px;
  background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 50%, #eef1f6 75%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------------------------------------------------------------- detail */

.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-head h1 { margin: 0; font-size: 21px; letter-spacing: -.2px; }

.meta { padding: 6px 20px; margin-bottom: 20px; }
.meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.meta-row:last-child { border-bottom: 0; }
.meta-row dt { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--ash); }
.meta-row dd { margin: 0; text-align: right; font-size: 14px; }
.meta-row dd.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

.banner {
  background: var(--amber-soft);
  border: 1px solid #f3d9ab;
  border-left: 4px solid var(--amber);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.banner h3 { margin: 0 0 5px; font-size: 13px; color: var(--amber); letter-spacing: .3px; }
.banner p { margin: 0; font-size: 13.5px; color: var(--ink); }
.banner code { font-family: var(--mono); font-size: 12.5px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 14px; }

.cardblk {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.cardblk.scanned { border: 2px solid var(--blue); box-shadow: 0 0 0 3px rgba(20, 136, 201, .1); }

.cardblk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.cardblk-marking { font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.cardblk-id { font-family: var(--mono); font-size: 11px; color: var(--ash); margin-top: 2px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .9px;
  padding: 3px 7px;
  border-radius: 5px;
}
.tag-scanned  { background: var(--blue-soft);   color: var(--blue-dark); }
.tag-drained  { background: var(--danger-soft); color: var(--danger); }
.tag-restored { background: var(--green-soft);  color: var(--green); }
.tag-target   { background: var(--blue-soft);   color: var(--blue-dark); }
.tag-source   { background: var(--paper);       color: var(--ash); }

.bal { width: 100%; border-collapse: collapse; }
.bal th, .bal td { padding: 10px 16px; font-size: 13.5px; text-align: right; }
.bal th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .7px;
  color: var(--ash);
  width: 104px;
  white-space: nowrap;
}
.bal tr + tr td, .bal tr + tr th { border-top: 1px solid #eef1f6; }
.bal .num { font-variant-numeric: tabular-nums; }
.bal .arrow { color: #b9c2d1; width: 22px; padding: 0; }
.bal .after { font-weight: 650; }
.bal .delta { width: 92px; font-variant-numeric: tabular-nums; font-weight: 600; }
.delta-up { color: var(--green); }
.delta-down { color: var(--danger); }
.delta-flat { color: #b9c2d1; }

.moved {
  padding: 9px 16px;
  border-top: 1px solid #eef1f6;
  background: #fbfcfe;
  font-size: 12px;
  color: var(--ash);
}
.moved b { color: var(--ink); font-variant-numeric: tabular-nums; }

.row-primary { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }

.row-role {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .9px;
  color: var(--ash);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
}
.row-mark { font-family: var(--mono); font-size: 13.5px; color: var(--ash); }
.row-mark.is-this { color: var(--ink); font-weight: 700; }
.row-this {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 5px;
  padding: 2px 6px;
}
.row-count { font-size: 12px; color: #9aa4b4; }

@media (max-width: 720px) {
  .view, .footer { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 0 16px; }
  .row { grid-template-columns: 1fr auto; row-gap: 10px; }
  .row-primary, .row-net { grid-column: 1 / -1; }
  .row-net { align-self: start; }
  .cards { grid-template-columns: 1fr; }
}

.derived {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 9px;
  font-weight: 700;
  color: var(--ash);
  vertical-align: super;
  margin-left: 3px;
  cursor: help;
}

.segmented.disabled { opacity: .45; }
.segmented button:disabled { cursor: not-allowed; }

.mono-head { font-family: var(--mono); font-size: .82em; font-weight: 700; word-break: break-all; }

.empty code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}

.meta-row dd a { color: var(--blue-dark); text-decoration: none; border-bottom: 1px solid #bcd9ef; }
.meta-row dd a:hover { border-bottom-color: var(--blue-dark); }

.bal-head td {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .8px;
  color: #9aa4b4;
  padding-top: 9px;
  padding-bottom: 5px;
}
.bal-head + tr td, .bal-head + tr th { border-top: 1px solid var(--line); }


/* --- net effect on the searched card, in the results list --- */

.row-net {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid #9fd0ef;
  border-radius: 8px;
  padding: 5px 10px;
  background: var(--card);
  min-width: 0;
}
.net-mark { font-family: var(--mono); font-size: 11px; color: #9aa4b4; line-height: 1.2; }
.net-row { display: flex; align-items: baseline; gap: 11px; white-space: nowrap; }
.net-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.net-label { font-size: 10.5px; font-weight: 600; color: #9aa4b4; white-space: nowrap; }

/* The cashier is the first column worth losing when width runs short. */
@media (max-width: 1080px) {
  .row { grid-template-columns: 146px 88px minmax(0, 1fr) 232px 92px; }
  .rows.no-net .row { grid-template-columns: 146px 88px minmax(0, 1fr) 92px; }
  .row-who { display: none; }
}

/* --- POINTS toggle: cash / bonus / accum. sit behind it --- */

.bal-toggle { cursor: pointer; }
.bal-toggle:hover th, .bal-toggle:hover td { background: #f7f9fc; }
.chev {
  /* Drawn with borders — the ▸ glyph renders as a dot at this size.
     The negative left margin cancels the right margin, so POINTS stays
     aligned with the other row labels. */
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4.5px solid #a8b2c2;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  margin-left: -12px;
  margin-right: 7.5px;
  vertical-align: 1.5px;
  transition: transform .12s ease;
}
.bal-toggle:hover .chev { border-left-color: var(--blue-dark); }
.expanded .chev { transform: rotate(90deg) translateX(-1px); }

.bal-sub { display: none; }
.expanded .bal-sub { display: table-row; }
.bal-sub th { font-weight: 600; color: #9aa4b4; padding-left: 28px; }
.bal-sub td { color: var(--ash); }
.bal-sub .after { font-weight: 600; }
