:root {
  --brand: #2f54eb;
  --brand-dark: #1d39c4;
  --bg: #f5f6fa;
  --card: #ffffff;
  --line: #e8eaf0;
  --text: #1f2430;
  --muted: #8a90a2;
  --green: #22a06b;
  --red: #e5484d;
  --orange: #f5a623;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #2f54eb 0%, #5b7cff 55%, #7aa0ff 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 16px; padding: 32px 26px;
  box-shadow: 0 12px 40px rgba(20, 30, 80, .25);
}
.login-card h1 { font-size: 21px; margin: 0 0 4px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 54px;
}
.topbar .title { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar .title .role-tag {
  font-size: 11px; background: rgba(255,255,255,.22); padding: 2px 8px; border-radius: 20px; font-weight: 500;
}
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .user button {
  background: rgba(255,255,255,.16); color: #fff; border: none; padding: 6px 12px; border-radius: 8px; font-size: 13px;
}

.tabs {
  position: sticky; top: 54px; z-index: 19;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabs button {
  flex: 0 0 auto; border: none; background: none; padding: 14px 18px;
  font-size: 15px; color: var(--muted); position: relative; white-space: nowrap;
}
.tabs button.active { color: var(--brand); font-weight: 600; }
.tabs button.active::after {
  content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 3px;
  background: var(--brand); border-radius: 3px 3px 0 0;
}

.container { max-width: 1000px; margin: 0 auto; padding: 16px; }

/* ---------- Cards & stats ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; }
.stat .value.money { color: var(--green); }
.stat .value.warn { color: var(--orange); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; color: var(--text); background: #fff; outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 60px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand); color: #fff; border: none; padding: 11px 18px;
  border-radius: 10px; font-size: 15px; font-weight: 500;
}
.btn:active { background: var(--brand-dark); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: #eef1fb; color: var(--brand); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.orange { background: var(--orange); }
.btn.blue { background: #2f6fed; }
.btn.gray { background: #eceef3; color: #555; }
.btn:disabled { opacity: .5; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); background:#fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fafbff; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* ---------- Task cards ---------- */
.task { border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; margin-bottom: 12px; background: #fff; box-shadow: 0 1px 3px rgba(20,30,60,.05); transition: box-shadow .15s; }
.task:hover { box-shadow: 0 4px 16px rgba(20,30,60,.08); }
.task .th { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.task .th .who { font-weight: 700; font-size: 15px; }
.task .meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 8px 18px; font-size: 13px; margin-bottom: 4px; }
.task .meta > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task .meta > div.wide { grid-column: 1 / -1; }
.task .meta .k { color: var(--muted); }
.task .fb { background: #f7f8fc; border-radius: 10px; padding: 12px; font-size: 13px; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.task .fb .row { gap: 10px; }
.task .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.settle-search { margin: 6px 0 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.pending { background: #fff4e0; color: #b8760a; }
.badge.contacting { background: #e6eefc; color: #2f6fed; }
.badge.to_publish { background: #f0e9fb; color: #7a3fd0; }
.badge.need_info { background: #e6f0ff; color: #1d5fd6; }
.badge.rejected { background: #fde8e8; color: #c0353a; }
.badge.accepted { background: #e3f7ee; color: #1a7d51; }
.badge.settled { background: #e3f7ee; color: #1a7d51; }
.badge.unsettled { background: #fff4e0; color: #b8760a; }

.warn-box { background: #fff4e0; border: 1px solid #ffd591; color: #b8760a; padding: 8px 10px; border-radius: 8px; font-size: 13px; margin: 8px 0; }
.dup-box { background: #fde8e8; border: 1px solid #ffa8a8; color: #c0353a; padding: 8px 10px; border-radius: 8px; font-size: 13px; margin: 8px 0; }

input[type=checkbox] { width: auto; margin-right: 6px; vertical-align: middle; transform: scale(1.15); }
.proof-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.proof-img { width: 92px; height: 92px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; display: block; }

.settle-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 2px 12px; margin-bottom: 10px; }
.settle-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.settle-item:last-child { border-bottom: none; }
.settle-item .amt { margin-left: auto; color: var(--green); font-weight: 600; }
.settle-total { margin-bottom: 12px; font-size: 15px; }
.settle-total b { color: var(--green); font-size: 18px; }

.ledger { display: flex; flex-direction: column; }
.led-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.led-row:last-child { border-bottom: none; }
.led-t { font-weight: 600; font-size: 14px; }
.led-d { font-size: 12px; margin-top: 2px; }
.led-time { font-size: 12px; margin-top: 2px; }
.led-amt { font-weight: 700; font-size: 16px; white-space: nowrap; }
.led-amt.inc { color: var(--green); }
.led-amt.dec { color: var(--red); }

.filter-bar { display: flex; gap: 10px; padding: 12px 16px 0; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select { flex: 1 1 140px; }

.blogger-search { flex: 1 1 180px; }
.combo { position: relative; flex: 1 1 180px; }
.combo input { width: 100%; padding-right: 30px; }
.combo-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: transparent; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.combo-panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; max-height: 260px; overflow-y: auto; z-index: 30; display: none; box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.combo-item { padding: 10px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--line); }
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: #f2f5ff; }

.reason-ctx { background: #f2f5ff; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--text); margin-bottom: 10px; }
.field label.chk { display: flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; color: var(--text); }
.pool-tip { background: #eef7ff; color: #1560b0; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }

.install-card { max-width: 460px; text-align: left; }
.install-sec { font-weight: 600; color: var(--brand); margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.install-card .btn.ghost { margin-top: 4px; }

.link-btn { border: none; background: #eef1fb; color: var(--brand); border-radius: 6px; padding: 2px 9px; font-size: 12px; margin-left: 6px; vertical-align: middle; }
.link-btn:active { background: #dbe2fb; }

.type-field { display: flex; flex-direction: column; gap: 8px; }
.type-field .type-new { margin-top: 0; }

.plat-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.plat-row .type-row-in { flex: 1 1 60px; width: auto; min-width: 0; }
.plat-row .p-name { flex: 0 0 100px; }
.plat-row .p-url { flex: 1 1 200px; }
.plat-row .p-en { flex: 0 0 auto; white-space: nowrap; font-size: 13px; color: var(--muted); display: flex; align-items: center; }
code { background: #eef1fb; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

.empty-guide { text-align: center; padding: 48px 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-guide .eg-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.empty-guide .eg-sub { color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 360px; margin: 0 auto 18px; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal h3 { margin: 0 0 16px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%) translateY(-20px);
  background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #c0353a; }
.toast.ok { background: #1a7d51; }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; margin-bottom: 12px; }
.chips button {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 7px 15px; border-radius: 20px; font-size: 13px; font-weight: 500; transition: all .12s;
}
.chips button:hover { border-color: var(--brand); color: var(--brand); }
.chips button.active { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 2px 8px rgba(47,111,237,.3); }

@media (min-width: 720px) {
  .task .th .who { font-size: 16px; }
}
@media (max-width: 480px) {
  .container { padding: 12px; }
  .stat .value { font-size: 20px; }
}
