:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1b1f24;
  --muted: #667085;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --danger: #c4320a;
  --ok: #067647;
  --warn: #b54708;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); text-align: center; }

/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 32px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 24px; color: var(--muted); }

/* layout */
header { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
header .brand { font-weight: 700; }
header nav { display: flex; gap: 4px; }
header nav button { background: none; border: 0; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
header nav button.active { background: var(--bg); color: var(--text); font-weight: 600; }
header .me { margin-left: auto; color: var(--muted); font-size: 14px; display: flex; gap: 12px; align-items: center; }
main { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* form controls */
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.field { margin-bottom: 16px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
.check input { width: auto; }
.btn { padding: 9px 16px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 500; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 1em; }
.hint { color: var(--muted); font-size: 13px; }

/* summary */
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; min-width: 110px; cursor: pointer; text-align: left; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.active { border-color: var(--accent); }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters .check { margin: 0; white-space: nowrap; }
.filters select { width: auto; flex: 0 1 200px; }

/* table */
.tablewrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f3f6ff; }
td.wrap { white-space: normal; min-width: 180px; }
.sub { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: #eef2f6; }
.pill.s-new { background: #fff1e6; color: var(--warn); }
.pill.s-won { background: #e7f6ec; color: var(--ok); }
.pill.s-lost { background: #f2f4f7; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* panel */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 760px; }
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 11; overflow-y: auto; padding: 20px 24px 40px; box-shadow: -4px 0 24px rgba(16, 24, 40, .12); }
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer .top { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; }
.section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }
.section h3 { font-size: 14px; margin: 0 0 12px; }
.suggest { background: #f3f6ff; border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.row { display: flex; gap: 8px; align-items: end; }
.row > .field { flex: 1; margin-bottom: 0; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b1f24; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 20; }
#toast.show { opacity: 1; }

@media (max-width: 720px) {
  header { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  header .me { margin-left: 0; width: 100%; justify-content: space-between; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .stats { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .stat { flex: 0 0 auto; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
.full { width: 100%; }
.mt0 { margin-top: 0; }
