:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6ec; --accent: #2457d6;
  --red-bg: #fde8e8; --red-fg: #b42318; --yellow-bg: #fff6d6; --yellow-fg: #8a6100; --green-bg: #e7f6ec; --green-fg: #19713a; --grey-bg: #eef0f3;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 18px; } h3 { font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red-fg); min-height: 1.4em; margin: 4px 0; }

.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); border-radius: 12px; padding: 24px; width: 100%; max-width: 360px; box-shadow: 0 2px 12px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.topbar { background: #1d2a4d; color: #fff; display: flex; align-items: center; gap: 12px; padding: 8px 16px; position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 600; white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; -webkit-overflow-scrolling: touch; }
.nav a { color: #cfd8f5; text-decoration: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: 14px; }
.nav a.active { background: #3a4c85; color: #fff; }
.who { font-size: 13px; white-space: nowrap; }
.who button.link { color: #cfd8f5; }
.main { padding: 16px; max-width: 1400px; margin: 0 auto; }

button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px; padding: 6px 12px; }
button:hover { border-color: #b9c0cf; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--red-fg); border-color: #f1b8b3; }
button.link { background: none; border: none; padding: 0 4px; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #cfd4de; border-radius: 6px; background: #fff; color: var(--text); max-width: 100%; }
textarea { width: 100%; min-height: 90px; }
input[type=number] { width: 110px; text-align: right; }

.card { background: var(--card); border-radius: 10px; padding: 14px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 10px; padding: 10px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); min-width: 140px; }
.stat b { font-size: 24px; display: block; }
.stat.red b { color: var(--red-fg); } .stat.yellow b { color: var(--yellow-fg); }

.table-wrap { overflow-x: auto; background: var(--card); border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f8f9fb; font-weight: 600; color: #444c5e; position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-red td { background: var(--red-bg); }
tr.row-yellow td { background: var(--yellow-bg); }
tr.row-green td { background: var(--green-bg); }
tr.row-grey td { background: var(--grey-bg); }
tr.row-inactive td:first-child { opacity: .6; }
.tag { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 10px; background: var(--grey-bg); color: var(--muted); margin-left: 4px; }
.tag.warn { background: var(--yellow-bg); color: var(--yellow-fg); }
.tag.new { background: #e5ecff; color: var(--accent); }
.status-red { color: var(--red-fg); font-weight: 600; } .status-yellow { color: var(--yellow-fg); font-weight: 600; } .status-green { color: var(--green-fg); font-weight: 600; }
.layout-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1100px) { .layout-2 { grid-template-columns: 1fr 340px; align-items: start; } }

dialog { border: none; border-radius: 12px; padding: 20px; width: min(480px, 94vw); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2330; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.toast.err { background: var(--red-fg); }
.bar { position: relative; height: 10px; background: #e6e9ef; border-radius: 5px; min-width: 120px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar > s { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--red-fg); }
.settings-form { display: grid; gap: 12px; max-width: 520px; }
.settings-form label { display: flex; flex-direction: column; gap: 4px; }
.note { background: #f8f9fb; border-left: 3px solid var(--accent); padding: 8px 12px; margin: 8px 0; font-size: 13px; color: #444c5e; }
.tag-stage, .tag-btn { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 10px; margin-left: 4px; border: 1px solid transparent; line-height: 1.6; }
.tag-btn { cursor: pointer; text-decoration: underline; }
.tag-stage.pending, .tag-btn.pending { background: var(--yellow-bg); color: var(--yellow-fg); }
.tag-stage.following, .tag-btn.following { background: #e5ecff; color: var(--accent); }
.tag-stage.done-good, .tag-btn.done-good { background: var(--green-bg); color: var(--green-fg); }
.tag-stage.done-bad, .tag-btn.done-bad { background: var(--red-bg); color: var(--red-fg); }
.leader-head { margin: 18px 0 8px; }
.talk-card.closed { opacity: .85; }
.talk-card.focus { outline: 2px solid var(--accent); }
.talk-head { margin-bottom: 8px; }
.talk-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.talk-steps > li { padding-left: 4px; border-left: 3px solid var(--line); padding-left: 10px; }
.step-name { font-weight: 600; margin-right: 6px; }
.pre { white-space: pre-wrap; }
.followups { margin: 4px 0 0; padding-left: 18px; }
.trend.improved { color: var(--green-fg); font-weight: 600; }
.trend.worse { color: var(--red-fg); font-weight: 600; }
.trend.same { color: var(--muted); }
@media (max-width: 640px) {
  .nav { order: 3; flex-basis: 100%; } .who { margin-left: auto; }
  .main { padding: 10px; } th, td { padding: 6px 8px; font-size: 13px; } input[type=number] { width: 90px; }
}
