/* ────────────────────────────────────────────────────────────────
   Two surfaces, one accent. No shadows anywhere — depth comes from
   hairlines and fills, the way macOS and iOS Reminders do it.
   ──────────────────────────────────────────────────────────────── */
:root {
  --white:      #FFFFFF;
  --gray:       #F5F5F7;   /* the only other surface */
  --hairline:   #E3E3E8;
  --hairline-2: #EDEDF0;

  --label:      #1D1D1F;
  --label-2:    #86868B;
  --label-3:    #B0B0B8;

  --blue:       #007AFF;
  --blue-soft:  rgba(0, 122, 255, 0.10);
  --blue-ring:  rgba(0, 122, 255, 0.16);

  --up:         #C8102E;   /* price moved against you */
  --up-soft:    rgba(200, 16, 46, 0.09);
  --live:       #00A050;
  --hover:      rgba(0, 0, 0, 0.04);
  --btn-hover:  #EBEBF0;
  --track:      #E3E3E8;
  --thumb:      #D6D6DB;
  --scrim:      rgba(0, 0, 0, 0.12);

  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --pill: 980px;

  --sidebar: 244px;
  --ease:   cubic-bezier(0.32, 0.72, 0, 1);   /* Apple's spring-ish curve */
  --quick:  140ms var(--ease);
}

/* ── dark ────────────────────────────────────────────────────────
   Same two surfaces, inverted: content sits lighter than the chrome,
   the way a macOS window sits above its sidebar. Only tokens change.
   ──────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --white:      #1C1C1E;
    --gray:       #141416;
    --hairline:   #303034;
    --hairline-2: #262629;
    --label:      #F5F5F7;
    --label-2:    #98989F;
    --label-3:    #636366;
    --blue:       #0A84FF;
    --blue-soft:  rgba(10, 132, 255, 0.16);
    --blue-ring:  rgba(10, 132, 255, 0.30);
    --up:         #FF453A;
    --up-soft:    rgba(255, 69, 58, 0.18);
    --live:       #30D158;
    --hover:      rgba(255, 255, 255, 0.06);
    --btn-hover:  #2C2C30;
    --track:      #39393D;
    --thumb:      #3A3A3E;
    --scrim:      rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --white:      #1C1C1E;
  --gray:       #141416;
  --hairline:   #303034;
  --hairline-2: #262629;
  --label:      #F5F5F7;
  --label-2:    #98989F;
  --label-3:    #636366;
  --blue:       #0A84FF;
  --blue-soft:  rgba(10, 132, 255, 0.16);
  --blue-ring:  rgba(10, 132, 255, 0.30);
  --up:         #FF453A;
  --up-soft:    rgba(255, 69, 58, 0.18);
  --live:       #30D158;
  --hover:      rgba(255, 255, 255, 0.06);
  --btn-hover:  #2C2C30;
  --track:      #39393D;
  --thumb:      #3A3A3E;
  --scrim:      rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--gray);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv09" 1;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }

.num { font-variant-numeric: tabular-nums; }

/* ── shell ───────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100vh; overflow: hidden; }

/* ── sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--gray);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; overflow: hidden;
}
.brand {
  padding: 20px 18px 14px;
  display: flex; align-items: baseline; gap: 7px;
}
.brand h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.brand .count { font-size: 11px; color: var(--label-3); }

.views { padding: 0 10px 6px; display: flex; flex-direction: column; gap: 1px; }
.view {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--r-sm);
  color: var(--label); text-align: left; width: 100%;
  transition: background var(--quick), color var(--quick);
}
.view:hover { background: var(--hover); }
.view[aria-selected="true"] { background: var(--blue); color: #fff; }
.view[aria-selected="true"] .dot { background: #fff; }
.view[aria-selected="true"] .view-n { color: rgba(255, 255, 255, 0.75); }
.view .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); transition: background var(--quick); }
.view .lbl { flex: 1; font-weight: 500; }
.view-n { font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; }

.filters { flex: 1; overflow-y: auto; padding: 8px 16px 28px; }
.filters::-webkit-scrollbar { width: 8px; }
.filters::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 4px; border: 2px solid var(--gray); }
.filters::-webkit-scrollbar-track { background: transparent; }

.group { border-top: 1px solid var(--hairline); padding: 13px 0 3px; }
.group:first-child { border-top: 0; }
.group > h3 {
  font-size: 11px; font-weight: 600; color: var(--label-2);
  letter-spacing: 0.02em; text-transform: uppercase; margin-bottom: 9px;
}
.field { margin-bottom: 9px; }
.field > label { display: block; font-size: 11.5px; color: var(--label-2); margin-bottom: 4px; }

input[type="text"], input[type="number"], select {
  width: 100%; background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 5px 8px;
  transition: border-color var(--quick), box-shadow var(--quick);
}
input:focus, select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3.5px var(--blue-ring);   /* focus ring, not elevation */
}
input[type="number"] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; }
input::placeholder { color: var(--label-3); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* switch — iOS toggle, scaled down */
.switch { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; }
.switch span { font-size: 12.5px; }
.switch input { appearance: none; width: 34px; height: 21px; border-radius: var(--pill);
  background: var(--track); position: relative; cursor: pointer; transition: background 220ms var(--ease); flex: none; }
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; transition: transform 260ms var(--ease);
}
.switch input:checked { background: #34C759; }
.switch input:checked::after { transform: translateX(13px); }
.switch input:active::after { width: 20px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 3px 9px; border-radius: var(--pill); background: var(--white);
  border: 1px solid var(--hairline); font-size: 11.5px; color: var(--label-2);
  transition: all var(--quick);
}
.chip:hover { border-color: var(--label-3); color: var(--label); }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip:active { transform: scale(0.94); }

/* ── main ────────────────────────────────────────────────────── */
.main { background: var(--white); display: flex; flex-direction: column; overflow: hidden; }

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--hairline); flex: none;
}
.search { position: relative; flex: 1; max-width: 340px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--label-3); }
.search input { padding-left: 28px; background: var(--gray); border-color: transparent; }
.search input:focus { background: var(--white); }

.spacer { flex: 1; }
.meta { font-size: 11.5px; color: var(--label-3); display: flex; align-items: center; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: var(--pill); background: var(--gray);
  font-weight: 500; font-size: 12.5px; white-space: nowrap;
  transition: background var(--quick), transform 90ms var(--ease), opacity var(--quick);
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.95); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

select.sort { width: auto; background: var(--gray); border-color: transparent; padding-right: 26px; cursor: pointer; }

/* progress — a hairline that fills */
.progress { height: 2px; background: var(--hairline-2); flex: none; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--blue); transition: width 300ms var(--ease); }
.progress[hidden] { display: none; }

/* ── table ───────────────────────────────────────────────────── */
.scroll { flex: 1; overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 5px; border: 3px solid var(--white); }

table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--white);
  border-bottom: 1px solid var(--hairline);
  font-size: 11px; font-weight: 600; color: var(--label-2);
  text-transform: uppercase; letter-spacing: 0.02em;
  padding: 9px 12px; text-align: right; white-space: nowrap;
}
thead th:nth-child(-n+2) { text-align: left; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--hairline-2); text-align: right; white-space: nowrap; }
tbody td:nth-child(-n+2) { text-align: left; }
tbody tr { transition: background var(--quick); cursor: default; }
tbody tr:hover { background: var(--gray); }
tbody tr.sel { background: var(--blue-soft); }

td.star { width: 30px; padding-right: 0; }
.star-btn { color: var(--label-3); display: block; transition: color var(--quick), transform 200ms var(--ease); }
.star-btn:hover { color: var(--label-2); }
.star-btn[aria-pressed="true"] { color: var(--blue); }
.star-btn:active { transform: scale(0.8); }
.star-btn.pop { animation: pop 340ms var(--ease); }
@keyframes pop { 0% { transform: scale(1); } 38% { transform: scale(1.32); } 100% { transform: scale(1); } }

.dom { font-weight: 500; letter-spacing: -0.005em; }
.dom .tld { color: var(--label-3); font-weight: 400; }
.dom a { color: inherit; }
tbody tr:hover .dom a { color: var(--blue); }

/* price: one column. live replaces snapshot, delta explains the change. */
.price { font-weight: 600; font-variant-numeric: tabular-nums; }
.price.is-live { color: var(--blue); }
.delta {
  display: inline-block; margin-left: 5px; padding: 1px 5px; border-radius: var(--pill);
  font-size: 10.5px; font-weight: 600; background: var(--up-soft); color: var(--up);
  animation: slidein 320ms var(--ease);
}
@keyframes slidein { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

tr.flash { animation: flash 1100ms ease-out; }
@keyframes flash { 0% { background: rgba(0, 122, 255, 0.14); } 100% { background: transparent; } }

.ends.soon { color: var(--up); font-weight: 600; }
.ends.soon::before {
  content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--up); margin-right: 5px; vertical-align: middle;
  animation: breathe 1.9s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.muted { color: var(--label-3); }
.livedot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--live); margin-right: 5px; vertical-align: middle;
}

tbody tr { animation: rise 260ms var(--ease) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.empty { padding: 64px 20px; text-align: center; color: var(--label-3); }
.empty strong { display: block; color: var(--label-2); font-size: 14px; font-weight: 500; margin-bottom: 4px; }

/* ── drawer ──────────────────────────────────────────────────── */
.backdrop {
  position: fixed; inset: 0; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity 240ms var(--ease); z-index: 40;
}
.backdrop.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px; z-index: 50;
  background: var(--white); border-left: 1px solid var(--hairline);
  transform: translateX(100%); transition: transform 320ms var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer.on { transform: none; }
.drawer header { padding: 18px 18px 13px; border-bottom: 1px solid var(--hairline); position: relative; }
.d-close {
  position: absolute; top: 15px; right: 15px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; color: var(--label-2); background: var(--gray);
  transition: background var(--quick), color var(--quick), transform 90ms var(--ease);
}
.d-close:hover { background: var(--btn-hover); color: var(--label); }
.d-close:active { transform: scale(0.9); }
.drawer header .d-name { padding-right: 30px; }
.drawer header .d-name { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; word-break: break-all; }
.drawer header .d-sub { font-size: 11.5px; color: var(--label-2); margin-top: 2px; }
.drawer .body { flex: 1; overflow-y: auto; padding: 4px 18px 20px; }
.drawer .grp { border-top: 1px solid var(--hairline-2); padding: 12px 0 4px; }
.drawer .grp:first-child { border-top: 0; }
.drawer .grp h4 {
  font-size: 11px; font-weight: 600; color: var(--label-2);
  text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 7px;
}
.row { display: flex; justify-content: space-between; align-items: baseline; padding: 3.5px 0; }
.row dt { color: var(--label-2); font-size: 12.5px; }
.row dd { font-variant-numeric: tabular-nums; font-weight: 500; }
.drawer footer { padding: 13px 18px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; }
.drawer footer .btn { flex: 1; justify-content: center; }

/* colour scheme drives native form controls and scrollbars too */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
:root[data-theme="dark"] { color-scheme: dark; }

/* ── saved searches ──────────────────────────────────────────── */
.saved { padding: 2px 10px 8px; }
.saved-head {
  font-size: 11px; font-weight: 600; color: var(--label-2);
  letter-spacing: 0.02em; text-transform: uppercase; padding: 6px 8px 5px;
}
.saved-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border-radius: var(--r-sm);
  transition: background var(--quick);
}
.saved-row:hover { background: var(--hover); }
.saved-row .lbl { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-row .rm { color: var(--label-3); opacity: 0; transition: opacity var(--quick), color var(--quick); }
.saved-row:hover .rm { opacity: 1; }
.saved-row .rm:hover { color: var(--up); }

/* ── sidebar footer ──────────────────────────────────────────── */
.sidebar-foot {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--hairline);
}
.seg {
  position: relative; flex: 1; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--track); border-radius: var(--r-sm); padding: 2px;
}
.seg button {
  position: relative; z-index: 1; padding: 3px 0; font-size: 11.5px; font-weight: 500;
  color: var(--label-2); border-radius: 5px; transition: color var(--quick);
}
.seg button[aria-selected="true"] { color: var(--label); }
.seg-pill {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; width: calc((100% - 4px) / 3);
  background: var(--white); border-radius: 5px;
  transition: transform 300ms var(--ease);
}
.icon-btn {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  color: var(--label-2); flex: none;
  transition: background var(--quick), color var(--quick), transform 90ms var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--label); }
.icon-btn:active { transform: scale(0.9); }

/* ── settings sheet ──────────────────────────────────────────── */
.sheet-scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 240ms var(--ease);
}
.sheet-scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 70; top: 50%; left: 50%; width: 400px;
  max-height: min(84vh, 720px);
  background: var(--white); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translate(-50%, -48%) scale(0.97); opacity: 0; pointer-events: none;
  transition: transform 280ms var(--ease), opacity 200ms var(--ease);
}
.sheet.on { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.sheet header {
  position: relative; padding: 16px 18px 13px; border-bottom: 1px solid var(--hairline);
}
.sheet header h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.sheet header .d-close { top: 14px; right: 14px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 18px 18px; }
.sheet footer {
  flex: none; display: flex; gap: 8px; padding: 12px 18px;
  border-top: 1px solid var(--hairline);
}
.sheet footer .btn { flex: 1; justify-content: center; }
.sheet-grp { border-top: 1px solid var(--hairline-2); margin-top: 14px; padding-top: 12px; }
.sheet-grp h4 {
  font-size: 11px; font-weight: 600; color: var(--label-2);
  text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 8px;
}
.hint { font-size: 11.5px; color: var(--label-2); line-height: 1.5; margin-bottom: 12px; }
.hint strong { color: var(--label); font-weight: 600; }
.pair-btn { display: flex; gap: 6px; }
.pair-btn input { flex: 1; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline label { flex: 1; margin: 0; font-size: 12.5px; color: var(--label); }
.field.inline input { width: 62px; flex: none; text-align: right; }
.field.inline .suffix { font-size: 11.5px; color: var(--label-2); width: 22px; }
.sheet-status {
  margin-top: 14px; font-size: 12px; min-height: 17px;
  color: var(--label-2); transition: color var(--quick);
}
.sheet-status.ok { color: var(--live); }
.sheet-status.bad { color: var(--up); }

/* ── drawer price limit ──────────────────────────────────────── */
.limit {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-top: 1px solid var(--hairline);
}
.limit label { flex: 1; font-size: 12.5px; color: var(--label-2); }
.limit-in { position: relative; width: 108px; }
.limit-in span {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--label-3); font-size: 12.5px; pointer-events: none;
}
.limit-in input { padding-left: 18px; text-align: right; }
