:root {
  --bg: #F3F6F7;
  --surface: #FFFFFF;
  --ink: #0F1E25;
  --ink-2: #23343C;
  --muted: #56666E;
  --line: #DCE3E6;
  --line-soft: #EDF1F3;
  --accent: #0F766E;
  --accent-ink: #0B5F58;
  --accent-soft: #DDF2EE;
  --sold: #9A3E07;
  --sold-soft: #FDEEDC;
  --new: #1D4ED8;
  --new-soft: #E6EDFF;
  --lost: #4B5A62;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; }
button { cursor: pointer; }

.app {
  max-width: 560px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* header */
.top { padding: 16px 16px 12px; display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.title { flex: 1; min-width: 0; }
.title h1 { margin: 0; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.title p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: flex; align-items: center; justify-content: center; padding: 0; }

/* summary */
.summary { margin: 0 16px; padding: 12px 6px; background: var(--surface); border: 1px solid #E1E7EA; border-radius: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat b { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); }

/* drop pills */
.drops { display: flex; gap: 6px; padding: 12px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.drops::-webkit-scrollbar { display: none; }
.pill { flex: 0 0 52px; height: 62px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0; }
.pill small { font-size: 11px; font-weight: 600; color: var(--muted); }
.pill b { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 18px; }
.pill i { font-style: normal; font-size: 10px; font-weight: 500; color: var(--muted); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.active small, .pill.active i { color: #fff; }

/* search + filters */
.search { margin: 8px 16px 0; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 15px; color: var(--ink); }
.filters { display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; }
.chip { height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.chip span { font-weight: 500; color: var(--muted); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.active span { color: #C9D3D7; }

/* table */
.thead, .row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 40px 40px 40px; gap: 6px; align-items: center; }
.thead { padding: 8px 16px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: #44545C; background: #E8EEF0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.num { text-align: center; }
.sort { color: var(--accent-ink); }
.list { flex: 1; overflow-y: auto; background: var(--surface); -webkit-overflow-scrolling: touch; }

.group { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 16px; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); background: #F6F9FA; text-align: left; }
.code { min-width: 40px; height: 26px; padding: 0 6px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; display: flex; align-items: center; justify-content: center; }
.code.gen { background: var(--muted); }
.glabel { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.glabel b { font-size: 14px; }
.glabel span { font-size: 11px; color: var(--muted); }
.gcount { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.chev { transition: transform 0.15s; color: #44545C; }
.group[aria-expanded="false"] .chev { transform: rotate(-90deg); }

.row { padding: 6px 16px; min-height: 56px; border-bottom: 1px solid var(--line-soft); }
.row.checked { background: #EEF7F5; }
.row.lost { background: #FAFBFB; }
.check { width: 28px; height: 44px; display: flex; align-items: center; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.dom { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.name { border: 0; background: none; padding: 0; font-size: 14px; font-weight: 600; color: var(--ink); text-align: left; word-break: break-all; }
.row.sold .name { text-decoration: line-through; }
.row.lost .name { color: var(--muted); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 6px; }
.badge.new { background: var(--new-soft); color: var(--new); }
.badge.sold { background: var(--sold-soft); color: var(--sold); }
.badge.lost { padding: 1px 6px; border: 1px dashed #7A8790; color: var(--lost); }
.metric { text-align: center; font-size: 14px; font-weight: 600; padding: 4px 0; border-radius: 8px; color: var(--muted); }
.metric.dr { font-weight: 700; }
.metric.hi { background: var(--accent-soft); color: var(--accent-ink); }
.metric.mid { background: #EEF2F4; color: var(--ink-2); }
.empty, .note { margin: 0; padding: 16px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.empty { padding: 40px 24px; text-align: center; font-size: 14px; }

/* bottom bar */
.bar { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid #E1E7EA; display: flex; gap: 8px; }
.primary { flex: 1; height: 48px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.primary:disabled { opacity: 0.5; }
.secondary { height: 46px; border-radius: 12px; border: 1px solid #C9D3D7; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; }
.square { width: 48px; height: 48px; flex-shrink: 0; padding: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-2); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 13px; font-weight: 500; padding: 10px 16px; border-radius: 999px; white-space: nowrap; z-index: 20; }

/* bottom sheet */
.sheet-wrap { position: fixed; inset: 0; background: rgba(15, 30, 37, 0.5); display: flex; flex-direction: column; justify-content: flex-end; z-index: 10; }
.sheet-wrap[hidden] { display: none; }
.sheet { width: 100%; max-width: 560px; margin: 0 auto; max-height: 85vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 18px; }
.sheet .lead { margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.label { margin: 4px 0 0; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: #44545C; }
.preview { background: #EEF7F5; border: 1px solid #D5EBE6; border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; max-height: 280px; overflow-y: auto; }
.drop-item { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 600; color: var(--ink); }
.drop-item span { font-size: 13px; font-weight: 500; color: var(--muted); }
.drop-item.active { border-color: var(--accent); background: #EEF7F5; }
