:root {
  --bg: #f3f6f6; --card: #ffffff; --ink: #14272b; --ink-soft: #5b6d70; --line: #dde5e6;
  --brand: #0e7c66; --brand-ink: #ffffff; --brand-soft: #e3f3ef; --head: #0e2a2f;
  --danger: #c0392b; --danger-soft: #fbe9e7; --warn: #b9770e; --warn-soft: #fdf2e0;
  --ok: #1e8449; --ok-soft: #e6f5ec; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a1c; --card: #172427; --ink: #e4eeef; --ink-soft: #97aaad; --line: #2a3b3e;
    --brand: #29b394; --brand-ink: #06231c; --brand-soft: #173a33; --head: #0a1416;
    --danger: #ef7b6e; --danger-soft: #3a1f1c; --warn: #f0b45a; --warn-soft: #3a2e1a;
    --ok: #63c98b; --ok-soft: #173525; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; }
textarea { min-height: 80px; resize: vertical; }
a { color: var(--brand); }
.boot { padding: 40px; text-align: center; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.top { background: var(--head); color: #fff; display: flex; align-items: center; gap: 14px; padding: 10px 16px; position: sticky; top: 0; z-index: 20; }
.top .brand { font-family: Sora, sans-serif; font-weight: 700; font-size: 17px; white-space: nowrap; }
.top .brand small { font-weight: 600; opacity: .6; margin-left: 4px; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav button { background: none; border: 0; color: #cfe3e0; padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.top nav button.on { background: rgba(255,255,255,.14); color: #fff; }
.top .who { font-size: 13px; opacity: .85; white-space: nowrap; }
.top .who button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: 3px 8px; margin-left: 8px; font-size: 12px; }
.bottom-nav { display: none; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 760px) {
  .top nav { display: none; }
  .top .who span { display: none; }
  main { padding: 12px 12px 84px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav button { flex: 1; background: none; border: 0; padding: 10px 2px; font-size: 12px; color: var(--ink-soft); }
  .bottom-nav button.on { color: var(--brand); font-weight: 600; }
}

/* ---------- building blocks ---------- */
.btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 600; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.plain { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: wait; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 220px; min-width: 160px; width: auto; }
.toolbar select { width: auto; flex: 0 1 auto; }
.toolbar .spacer { flex: 1; }
h1 { font-family: Sora, sans-serif; font-size: 20px; margin: 4px 0 12px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.won { background: var(--ok-soft); color: var(--ok); }
.badge.lost { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.overdue { color: var(--danger); font-weight: 600; }
.today { color: var(--warn); font-weight: 600; }
.empty { padding: 18px; text-align: center; color: var(--ink-soft); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tile .k { font-size: 12px; color: var(--ink-soft); }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--ink-soft); }

/* ---------- lists ---------- */
.rows { display: flex; flex-direction: column; }
.row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--brand-soft); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.row .side { text-align: right; font-size: 13px; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
table.tbl th, table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.tbl th { font-size: 12px; color: var(--ink-soft); font-weight: 600; background: var(--bg); }
table.tbl tr.click { cursor: pointer; }
table.tbl tr.click:hover td { background: var(--brand-soft); }
td.num, th.num { text-align: right; }

/* ---------- board ---------- */
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.col { flex: 0 0 260px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; max-height: calc(100vh - 210px); overflow-y: auto; }
.col h4 { margin: 2px 4px 8px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.col h4 .muted { font-weight: 500; }
.opp { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.opp:hover { border-color: var(--brand); }
.opp .n { font-size: 11px; color: var(--ink-soft); }
.opp .t { font-weight: 600; font-size: 14px; margin: 1px 0 3px; }
.opp .c { font-size: 13px; color: var(--ink-soft); }
.opp .f { display: flex; justify-content: space-between; font-size: 12px; margin-top: 6px; gap: 6px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; padding: 18px; width: 100%; max-width: 640px; box-shadow: 0 10px 40px rgba(0,0,0,.3); position: relative; }
.modal.wide { max-width: 900px; }
.modal h2 { margin: 0 0 4px; font-size: 18px; padding-right: 30px; }
.modal .x { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 22px; color: var(--ink-soft); }
.modal .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 760px) { .modal-bg { padding: 0; } .modal { border-radius: 0; min-height: 100vh; } }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 12px; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 3px; }
.field .req { color: var(--danger); }
.section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.section h3 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 14px; margin-top: 10px; }
.facts .k { font-size: 12px; color: var(--ink-soft); }
.facts .v { font-size: 14px; word-break: break-word; }
.timeline .act { border-left: 3px solid var(--brand); padding: 4px 0 8px 10px; margin-bottom: 6px; }
.timeline .act .h { font-size: 12px; color: var(--ink-soft); }
.timeline .act .b { white-space: pre-wrap; }
.picker { position: relative; }
.picker .results { position: absolute; left: 0; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; z-index: 5; max-height: 240px; overflow-y: auto; box-shadow: var(--shadow); }
.picker .results div { padding: 7px 10px; cursor: pointer; font-size: 14px; }
.picker .results div:hover, .picker .results div.hl { background: var(--brand-soft); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--brand-soft); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--ink); font-size: 14px; margin-top: 10px; }
.notice.ok { background: var(--ok-soft); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0e2a2f, #0e5a4b); }
.login-card { background: var(--card); border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; }
.login-card .brand { font-family: Sora, sans-serif; font-size: 22px; font-weight: 700; }
.login-card .brand small { display: block; font-family: system-ui; font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.method-toggle { display: flex; gap: 6px; margin: 16px 0; }
.method-toggle button { flex: 1; padding: 7px; border-radius: 8px; border: 1px solid var(--line); background: none; }
.method-toggle button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.login-card .field { margin-bottom: 12px; }
.login-card .btn { width: 100%; }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 10px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 1em; }
.login-logo { margin-top: 24px; max-width: 150px; }

.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--head); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 100; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
