* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1f2329; background: #f5f6f8; }
a { color: #2f6fed; cursor: pointer; text-decoration: none; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #d0d3d9; border-radius: 4px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2f6fed; }
textarea { width: 100%; font-family: Menlo, Consolas, monospace; font-size: 12px; }
code, .mono { font-family: Menlo, Consolas, monospace; font-size: 12px; }

.btn { padding: 6px 14px; border: 1px solid #d0d3d9; border-radius: 4px; background: #fff; cursor: pointer; font: inherit; }
.btn:hover { border-color: #2f6fed; color: #2f6fed; }
.btn.primary { background: #2f6fed; border-color: #2f6fed; color: #fff; }
.btn.primary:hover { background: #245bd1; color: #fff; }
.btn.danger { color: #d93026; }
.btn.danger:hover { border-color: #d93026; }
.btn.danger-fill { background: #d93026; border-color: #d93026; color: #fff; }
.btn.danger-fill:hover { background: #b9281f; color: #fff; }
.btn .count { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: #d93026; color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.btn .count[hidden] { display: none; }
.batch-btns { margin: 4px 0 0; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn:disabled, .btn:disabled:hover { opacity: .55; cursor: not-allowed; }
.disabled-link { color: #c0c4cc; cursor: not-allowed; }
.btn.block { width: 100%; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; background: #fff; padding: 32px; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.login-box h1 { font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-sub { text-align: center; color: #8f959e; margin: 0 0 20px; }
.login-box label { display: block; margin-bottom: 14px; color: #646a73; }
.login-box input { display: block; width: 100%; margin-top: 4px; }
.error { color: #d93026; min-height: 20px; margin: 8px 0 0; }

.tabs { display: flex; margin-bottom: 18px; border-bottom: 1px solid #e5e6eb; }
.tab { flex: 1; padding: 8px; border: 0; background: none; cursor: pointer; font: inherit; color: #646a73; border-bottom: 2px solid transparent; }
.tab.active { color: #2f6fed; border-bottom-color: #2f6fed; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 180px; background: #1f2937; color: #cbd5e1; flex-shrink: 0; }
.sidebar .brand { padding: 18px 20px; font-size: 16px; font-weight: 600; color: #fff; }
.sidebar a { display: block; padding: 10px 20px; color: #cbd5e1; }
.sidebar a:hover { background: #374151; }
.sidebar a.active { background: #2f6fed; color: #fff; }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: #fff; border-bottom: 1px solid #e5e6eb; }
.content { padding: 20px 24px; }

.panel { background: #fff; border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { background: #fff; border-radius: 6px; padding: 16px; }
.stat .num { font-size: 24px; font-weight: 600; }
.stat .label { color: #8f959e; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef0f3; text-align: left; white-space: nowrap; }
th { background: #fafbfc; color: #646a73; font-weight: 500; }
tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; color: #8f959e; padding: 24px; }

.badge { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; line-height: 20px; }
.badge.gray { background: #eef0f3; color: #646a73; }
.badge.green { background: #e3f6e8; color: #1a7f37; }
.badge.red { background: #fde8e7; color: #d93026; }
.badge.orange { background: #fff1e0; color: #c25e00; }
.badge.blue { background: #e6efff; color: #2f6fed; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c9cdd4; margin-right: 4px; }
.dot.on { background: #22c55e; }

.app-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid #e5e6eb; margin-bottom: 12px; }
.app-tabs a { padding: 8px 16px; color: #646a73; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.app-tabs a.active { color: #2f6fed; border-bottom-color: #2f6fed; font-weight: 500; }
.app-tabs small { color: #8f959e; margin-left: 4px; }
.back-link { margin: -4px 0 8px; font-size: 13px; }
.form-section { margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid #eef0f3; font-weight: 600; color: #333; }
.form-section:first-child { margin-top: 0; }
.form-section.fold { cursor: pointer; user-select: none; color: #666; }
.form-section.fold::before { content: '▸ '; }
.form-section.fold.open::before { content: '▾ '; }
table.kv td { padding: 6px 10px; border-bottom: 1px solid #eef0f3; }
table.kv td:first-child { width: 90px; color: #888; }
.section-title { font-size: 15px; font-weight: 600; margin: 4px 0 10px; }
.stats + .section-title { margin-top: 20px; }
.stat .sub { color: #8f959e; font-size: 12px; }
.stat.money .num { color: #1a7f37; }
.btn.on { border-color: #2f6fed; color: #2f6fed; }
td.num, th.num { text-align: right; }
.panel .stat { background: #f7f8fa; }
.trend-head a { font-size: 13px; }
.agents-table td { vertical-align: middle; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-right: 8px; border-radius: 50%; background: #e6efff; color: #2f6fed; font-weight: 600; font-size: 13px; vertical-align: middle; }
.auth-line { display: flex; align-items: center; gap: 6px; line-height: 24px; }
.money { color: #1a7f37; }
.ops { white-space: nowrap; }
.ops a + a { margin-left: 12px; }
.danger-link, .danger-link:hover { color: #d93026; }
.total-row td { font-weight: 600; background: #f7f8fa; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 4px 0 0 4px; }
.btn-group .btn:last-child { border-radius: 0 4px 4px 0; }
.btn-group .btn.on { background: #2f6fed; border-color: #2f6fed; color: #fff; position: relative; }

.trend-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.trend-head h3 { margin: 0; }
.trend-head .spacer { flex: 1; }
.trend-head select { padding: 2px 6px; font-size: 12px; }
.legend { display: inline-flex; align-items: center; gap: 6px; color: #646a73; font-size: 12px; }
.legend i { display: inline-block; margin-left: 8px; }
.legend .lg-line { width: 16px; height: 3px; border-radius: 2px; background: #2f6fed; }
.legend .lg-bar { width: 10px; height: 10px; border-radius: 2px; background: rgba(26,127,55,.35); }
.trend-box { position: relative; height: 260px; }
.trend svg { display: block; }
.trend .grid { stroke: #eef0f3; }
.trend .ax { fill: #8f959e; font-size: 11px; }
.trend .bar { fill: rgba(26,127,55,.28); }
.trend .line { fill: none; stroke: #2f6fed; stroke-width: 2; }
.trend .pt { fill: #fff; stroke: #2f6fed; stroke-width: 1.5; }
.trend .guide { stroke: #c9cdd4; stroke-dasharray: 3 3; }
.trend .tip { position: absolute; pointer-events: none; background: rgba(31,35,41,.92); color: #fff; font-size: 12px; line-height: 1.8; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
.trend .tip .sub { color: #c9cdd4; }
.trend-sum { color: #646a73; font-size: 13px; margin-top: 6px; }
.trend-sum b { color: #1f2329; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 10; }
.modal { background: #fff; border-radius: 8px; width: 480px; max-width: 94vw; max-height: 84vh; overflow: auto; }
.modal.wide { width: 720px; }
div.kv { display: grid; grid-template-columns: 72px 1fr 72px 1fr; gap: 8px 12px; font-size: 13px; align-items: baseline; }
div.kv .k { color: #8f959e; }
.table-wrap table { font-size: 13px; }
.table-wrap td, .table-wrap th { padding: 8px 10px; }
.modal-head { padding: 14px 20px; border-bottom: 1px solid #eef0f3; font-weight: 600; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid #eef0f3; display: flex; justify-content: flex-end; gap: 8px; }
.field { margin-bottom: 12px; }
.field > label { display: block; color: #646a73; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { color: #8f959e; font-size: 12px; margin-top: 2px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

/* 合伙人端配色，与开发端区分 */
.agent-theme .sidebar { background: #134e4a; }
.agent-theme .sidebar a:hover { background: #115e59; }
.agent-theme .sidebar a.active, .agent-theme .btn.primary { background: #0d9488; border-color: #0d9488; }
.agent-theme .btn.primary:hover { background: #0f766e; }
.agent-theme a, .agent-theme .tab.active { color: #0d9488; }
.agent-theme .sidebar a { color: #cbd5e1; }
.agent-theme .sidebar a.active { color: #fff; }
.agent-theme .app-tabs a { color: #646a73; }
.agent-theme .app-tabs a.active, .agent-theme .btn.on { color: #0d9488; border-color: #0d9488; }
.agent-theme .btn-group .btn.on { background: #0d9488; color: #fff; }
.agent-theme .trend .line, .agent-theme .trend .pt { stroke: #0d9488; }
.agent-theme .legend .lg-line { background: #0d9488; }
.agent-theme .btn:hover { border-color: #0d9488; color: #0d9488; }
.agent-theme .btn.primary:hover { color: #fff; }
.agent-theme .btn.danger:hover { border-color: #d93026; color: #d93026; }
.agent-theme .btn.danger-fill:hover { color: #fff; }
.agent-theme input:focus, .agent-theme select:focus, .agent-theme textarea:focus { border-color: #0d9488; }
.agent-theme .danger-link { color: #d93026; }

/* 窄屏（手机）：侧栏变顶部横排，详情两列 */
@media (max-width: 720px) {
    .layout { flex-direction: column; }
    .sidebar { width: auto; display: flex; flex-wrap: wrap; white-space: nowrap; }
    .toolbar .spacer { display: none; }
    .sidebar .brand { padding: 10px 14px; }
    .sidebar a { padding: 10px 14px; }
    .topbar { padding: 10px 12px; }
    .content { padding: 12px; }
    .panel { padding: 12px; }
    div.kv { grid-template-columns: 76px 1fr; }
    .mask { padding-top: 2vh; }
    .modal { max-height: 94vh; }
}

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 8px 18px; border-radius: 4px; z-index: 20; }
.toast.err { background: #d93026; }
