/* ===== Card Joy 桌面版 设计系统 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #eef2ff;
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0;
  --slate-300: #cbd5e1; --slate-400: #94a3b8; --slate-500: #64748b;
  --slate-600: #475569; --slate-700: #334155; --slate-800: #1e293b; --slate-900: #0f172a;
  --emerald: #059669; --emerald-bg: #ecfdf5;
  --amber: #d97706; --amber-bg: #fffbeb;
  --rose: #e11d48; --rose-bg: #fff1f2;
  --teal: #0d9488; --teal-bg: #f0fdfa;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--slate-800);
  background: var(--slate-100);
  overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: 13px; }
input, select, textarea { font-family: inherit; font-size: 13px; color: var(--slate-800); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.boot-loading { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--slate-500); background: var(--slate-900); }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.15); border-top-color: #818cf8; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 登录页 ===== */
.login-wrap {
  height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: radial-gradient(ellipse at top, #1e293b 0%, #0f172a 60%); padding: 24px;
}
.login-card { width: 430px; max-width: 94vw; background: #fff; border-radius: 18px; padding: 34px 38px 30px; box-shadow: 0 24px 64px rgba(0,0,0,.45); }
.login-logo { display: flex; align-items: center; gap: 13px; margin-bottom: 6px; }
.login-logo .mark { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #6366f1, #4338ca); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: .5px; }
.login-logo h1 { font-size: 21px; color: var(--slate-900); letter-spacing: 1px; }
.login-sub { color: var(--slate-400); font-size: 12px; margin-bottom: 22px; padding-left: 57px; }
.login-server { background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 10px; padding: 11px 13px; margin-bottom: 18px; display: flex; align-items: center; gap: 9px; font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot.bad { background: #f43f5e; box-shadow: 0 0 0 3px rgba(244,63,94,.18); }
.login-server .url { flex: 1; color: var(--slate-600); word-break: break-all; }
.login-server a { color: var(--brand); font-weight: 600; text-decoration: none; cursor: pointer; }
.mode-tabs { display: flex; background: var(--slate-100); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.mode-tabs button { flex: 1; padding: 9px; border-radius: 8px; font-weight: 600; color: var(--slate-500); font-size: 13px; }
.mode-tabs button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--slate-600); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50); outline: none; font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); background: #fff; }
.field input.pin { letter-spacing: 6px; font-size: 18px; text-align: center; font-weight: 700; }
.login-error { background: var(--rose-bg); color: var(--rose); border: 1px solid #fecdd3; border-radius: 10px; padding: 10px 12px; font-size: 12px; margin-bottom: 14px; }
.btn-login { width: 100%; padding: 12px; background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; border-radius: 11px; font-size: 15px; font-weight: 700; letter-spacing: 2px; transition: opacity .2s; }
.btn-login:hover { opacity: .92; }
.btn-login:disabled { opacity: .5; cursor: not-allowed; }
.login-hint { margin-top: 16px; text-align: center; font-size: 11px; color: var(--slate-400); line-height: 1.7; }

/* ===== 顶栏 ===== */
.topbar { background: #fff; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 56px; flex-shrink: 0; }
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.topbar .brand b { font-size: 15px; color: var(--slate-900); }
.topbar .brand .ver { font-size: 10px; color: var(--slate-400); font-weight: 600; }
.topbar .conn { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--slate-500); background: var(--slate-50); border: 1px solid var(--slate-200); padding: 5px 11px; border-radius: 999px; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar .user .name { font-size: 13px; font-weight: 700; color: var(--slate-700); background: var(--brand-light); border: 1px solid #c7d2fe; padding: 5px 12px; border-radius: 999px; }
.topbar .user .name.admin { background: var(--amber-bg); border-color: #fde68a; color: #92400e; }
.btn-logout { color: var(--slate-500); font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.btn-logout:hover { background: var(--slate-100); color: var(--rose); }
.conn-banner { background: #fef2f2; color: #b91c1c; font-size: 12px; font-weight: 600; text-align: center; padding: 7px; border-bottom: 1px solid #fecaca; flex-shrink: 0; }

/* ===== 主内容 ===== */
.main { flex: 1; overflow-y: auto; padding: 18px 20px 30px; }
.month-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.month-bar .label { font-size: 12px; font-weight: 700; color: var(--slate-500); letter-spacing: 1px; margin-right: 2px; }
.month-chip { padding: 7px 15px; border-radius: 999px; background: #fff; border: 1px solid var(--slate-200); color: var(--slate-600); font-weight: 600; font-size: 12.5px; transition: all .15s; }
.month-chip:hover { border-color: #c7d2fe; color: var(--brand); }
.month-chip.active { background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(79,70,229,.28); }
.month-chip .cnt { opacity: .65; font-size: 11px; margin-left: 3px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12.5px; color: var(--slate-500); font-weight: 700; margin-bottom: 8px; white-space: nowrap; }
.kpi .k-value { font-size: 26px; font-weight: 800; color: var(--slate-900); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi .k-value small { font-size: 13px; font-weight: 600; color: var(--slate-400); margin-left: 2px; }
.kpi.hero { grid-column: span 2; background: linear-gradient(135deg, #4338ca, #6366f1); border: none; display: flex; flex-direction: column; justify-content: center; }
.kpi.hero .k-label { color: rgba(255,255,255,.8); font-size: 13.5px; margin-bottom: 10px; }
.kpi.hero .k-value { color: #fff; font-size: 38px; letter-spacing: -.5px; }
.kpi.hero .k-sub { margin-top: 10px; font-size: 13px; font-weight: 700; color: rgba(255,255,255,.85); background: rgba(255,255,255,.16); border-radius: 999px; padding: 4px 12px; width: fit-content; }
.kpi.green .k-value { color: var(--emerald); }
.kpi.red .k-value { color: var(--rose); }

/* Tabs */
.tabbar { display: flex; gap: 4px; background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 5px; margin-bottom: 16px; box-shadow: var(--shadow); width: fit-content; }
.tabbar button { padding: 9px 20px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--slate-500); letter-spacing: .5px; }
.tabbar button.active { background: var(--brand-light); color: var(--brand); }
.tabbar button:hover:not(.active) { color: var(--slate-800); }

/* 卡片 */
.card { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--slate-100); flex-wrap: wrap; }
.card-head h3 { font-size: 13px; font-weight: 800; color: var(--slate-800); letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.card-head h3::before { content: ""; width: 4px; height: 15px; background: var(--brand); border-radius: 2px; display: inline-block; }
.card-body { padding: 16px 18px; }

/* 筛选栏 */
.filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr auto; gap: 9px; padding: 14px 18px; align-items: center; }
.filters input, .filters select { width: 100%; padding: 9px 12px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50); outline: none; font-size: 12.5px; font-weight: 600; }
.filters input:focus, .filters select:focus { border-color: var(--brand); background: #fff; }
.btn-clear-filter { font-size: 12px; color: var(--brand); background: var(--brand-light); font-weight: 700; padding: 9px 14px; border-radius: 10px; white-space: nowrap; }
.btn-clear-filter:hover { background: #e0e7ff; }

/* 表格 */
.table-wrap { overflow: auto; max-height: calc(100vh - 480px); }
table.data { width: 100%; min-width: 1560px; border-collapse: collapse; }
table.data th { position: sticky; top: 0; background: var(--slate-100); color: var(--slate-600); font-size: 11.5px; font-weight: 800; text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--slate-200); white-space: nowrap; z-index: 2; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--slate-100); font-size: 12.5px; vertical-align: top; white-space: nowrap; }
table.data tbody tr:hover { background: #f8fafc; }
.mono { font-variant-numeric: tabular-nums; }
.chip-machine { background: var(--brand-light); color: #4338ca; border: 1px solid #c7d2fe; padding: 3px 9px; border-radius: 8px; font-weight: 700; font-size: 11.5px; }
.chip-card { font-weight: 800; color: var(--slate-900); }
.code-cell { max-width: 250px; white-space: normal; word-break: break-all; line-height: 1.5; }
.code-cell .note { display: inline-block; margin-top: 4px; background: var(--slate-100); color: var(--slate-500); font-size: 11px; padding: 2px 7px; border-radius: 6px; }
.v-emerald { color: var(--emerald); font-weight: 800; }
.v-teal { color: var(--teal); font-weight: 800; }
.v-orange { color: #c2410c; font-weight: 800; }
.v-rose { color: var(--rose); font-weight: 800; }
.profit-pill { padding: 3px 9px; border-radius: 8px; font-weight: 800; display: inline-block; }
.profit-pill.pos { background: #ffedd5; color: #9a3412; }
.profit-pill.neg { background: var(--rose-bg); color: var(--rose); }
.status-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid; }
.status-btn.done { background: var(--emerald-bg); color: var(--emerald); border-color: #a7f3d0; }
.status-btn.doing { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.status-btn .sdot { width: 6px; height: 6px; border-radius: 50%; }
.status-btn.done .sdot { background: #10b981; }
.status-btn.doing .sdot { background: #f59e0b; }
.op-btn { padding: 5px 8px; border-radius: 7px; color: var(--slate-500); font-size: 12px; }
.op-btn:hover { background: var(--brand-light); color: var(--brand); }
.op-btn.danger:hover { background: var(--rose-bg); color: var(--rose); }
.empty-row { text-align: center; padding: 46px 0 !important; color: var(--slate-400); }
.empty-row b { display: block; font-size: 14px; color: var(--slate-500); margin-bottom: 5px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 10px; font-weight: 700; font-size: 13px; transition: all .15s; }
.btn-primary { background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; box-shadow: 0 3px 10px rgba(79,70,229,.3); }
.btn-primary:hover { opacity: .93; }
.btn-ghost { background: #fff; color: var(--slate-600); border: 1px solid var(--slate-200); }
.btn-ghost:hover { border-color: #c7d2fe; color: var(--brand); }
.btn-danger { background: var(--rose-bg); color: var(--rose); border: 1px solid #fecdd3; }
.btn-danger:hover { background: #ffe4e6; }
.btn-sm { padding: 7px 13px; font-size: 12px; border-radius: 8px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px; }
.modal { background: #fff; border-radius: 16px; width: 720px; max-width: 96vw; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 28px 70px rgba(0,0,0,.35); animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--slate-100); }
.modal-head h3 { font-size: 15px; font-weight: 800; color: var(--slate-900); }
.modal-close { font-size: 18px; color: var(--slate-400); padding: 4px 8px; border-radius: 7px; }
.modal-close:hover { background: var(--slate-100); color: var(--slate-700); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--slate-100); display: flex; justify-content: flex-end; gap: 10px; background: var(--slate-50); border-radius: 0 0 16px 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.calc-preview { grid-column: span 3; background: var(--slate-900); border-radius: 12px; padding: 12px 16px; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.calc-preview .item { display: flex; flex-direction: column; gap: 1px; }
.calc-preview .item .l { font-size: 10.5px; color: #94a3b8; }
.calc-preview .item .v { font-size: 16px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.calc-preview .item.profit .v { color: #34d399; }
.calc-preview .item.profit.neg .v { color: #fb7185; }
.clipboard-box { grid-column: span 3; border: 1px dashed var(--slate-300); border-radius: 12px; padding: 12px; background: var(--slate-50); }
.clipboard-box summary { font-size: 12px; font-weight: 700; color: var(--slate-600); cursor: pointer; }
.clipboard-box textarea { width: 100%; margin-top: 9px; border: 1px solid var(--slate-200); border-radius: 9px; padding: 9px; min-height: 64px; resize: vertical; background: #fff; outline: none; font-size: 12px; }
.clipboard-box .row { display: flex; gap: 9px; margin-top: 8px; }

/* 排行榜 */
.rank-list { display: flex; flex-direction: column; gap: 13px; }
.rank-item .rank-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.rank-item .rank-head b { color: var(--slate-700); }
.rank-item .rank-head span { font-weight: 800; color: var(--slate-900); font-variant-numeric: tabular-nums; }
.rank-bar { height: 9px; background: var(--slate-100); border-radius: 999px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 999px; }
.rank-bar.indigo i { background: linear-gradient(90deg, #6366f1, #4f46e5); }
.rank-bar.emerald i { background: linear-gradient(90deg, #34d399, #059669); }

/* 月度报表 */
.report-total { display: flex; gap: 12px; margin-bottom: 14px; }
.report-total .kpi { flex: 1; }
table.report { width: 100%; border-collapse: collapse; }
table.report th { background: var(--slate-100); font-size: 12px; font-weight: 800; color: var(--slate-600); padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
table.report td { padding: 13px 14px; border-bottom: 1px solid var(--slate-100); font-size: 13px; font-variant-numeric: tabular-nums; }
table.report tr:hover td { background: #f8fafc; }
table.report .month-cell { font-weight: 800; color: var(--slate-800); font-size: 14px; }
.badge-cur { background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; font-size: 10px; padding: 2.5px 9px; border-radius: 999px; margin-left: 8px; font-weight: 700; }
.btn-view-month { color: var(--brand); font-weight: 700; font-size: 12px; background: var(--brand-light); padding: 6px 13px; border-radius: 8px; }
.btn-view-month:hover { background: #e0e7ff; }

/* 管理总台 */
.admin-grid { display: flex; flex-direction: column; gap: 16px; }
.add-worker-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 12px; padding: 13px; }
table.workers { width: 100%; border-collapse: collapse; }
table.workers th { background: var(--slate-50); font-size: 11.5px; font-weight: 800; color: var(--slate-500); text-align: left; padding: 9px 12px; }
table.workers td { padding: 10px 12px; border-top: 1px solid var(--slate-100); font-size: 12.5px; vertical-align: middle; }
.switch { position: relative; width: 36px; height: 20px; background: #cbd5e1; border-radius: 999px; transition: background .18s; display: inline-block; vertical-align: middle; margin-right: 8px; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--emerald); }
.switch.on::after { left: 18px; }
.switch-label { font-size: 11.5px; font-weight: 600; vertical-align: middle; }
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip { display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--slate-200); padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--slate-700); }
.type-chip button { color: var(--slate-400); font-size: 14px; font-weight: 800; }
.type-chip button:hover { color: var(--rose); }
.audit-table td { font-size: 12px; }
.audit-table .time { color: var(--slate-400); white-space: nowrap; font-size: 11.5px; }
.audit-table .act { font-weight: 700; white-space: nowrap; }

/* Toast */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 9px; z-index: 200; }
.toast { background: var(--slate-900); color: #fff; padding: 11px 17px; border-radius: 11px; font-size: 13px; font-weight: 600; box-shadow: 0 10px 28px rgba(0,0,0,.3); display: flex; align-items: center; gap: 9px; animation: slideIn .25s ease-out; max-width: 380px; }
.toast.ok::before { content: "✓"; color: #34d399; font-weight: 800; }
.toast.err { background: #991b1b; }
.toast.err::before { content: "!"; color: #fca5a5; font-weight: 800; }
.toast.sync::before { content: "⟳"; color: #a5b4fc; font-weight: 800; }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 确认对话框 */
.confirm-body { padding: 22px; font-size: 13.5px; color: var(--slate-700); line-height: 1.8; }
.confirm-body b { color: var(--slate-900); }
.confirm-modal { width: 420px; }
