* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: #222; background: #f6f7f9; }
#app { max-width: 1400px; margin: 0 auto; padding: 0 16px 40px; }
.muted { color: #888; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid #ddd; margin-bottom: 16px; }
.topbar h1 { font-size: 18px; margin: 0 auto 0 0; }
.viewer-badge { background: #fff3cd; border: 1px solid #e0c97f; color: #7a5b00; padding: 4px 10px; border-radius: 4px; font-size: 13px; }

button, .btn { background: #4a7ebb; color: #fff; border: 0; border-radius: 4px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
button:hover { filter: brightness(1.08); }
button.ghost { background: #fff; color: #333; border: 1px solid #ccc; }
button.danger { background: #c0392b; }
button.small { padding: 2px 8px; font-size: 12px; }
select, input, textarea { font: inherit; padding: 6px 8px; border: 1px solid #bbb; border-radius: 4px; background: #fff; }

.login-card { max-width: 340px; margin: 80px auto; background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 24px; }
.login-card h2 { margin-top: 0; }
.login-card label { display: block; margin: 12px 0 4px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 16px; }

.project-head { display: flex; align-items: center; gap: 10px; margin: 20px 0 6px; }
.project-head .dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.project-head h2 { font-size: 17px; margin: 0; }

.gantt-wrap { overflow-x: auto; background: #fff; border: 1px solid #ddd; border-radius: 6px; }
svg text { font-family: inherit; }

.split { display: grid; grid-template-columns: 340px 1fr; gap: 12px; align-items: start; }
.tree { background: #fff; border: 1px solid #ddd; border-radius: 6px; max-height: 70vh; overflow-y: auto; }
.trow { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid #f0f0f0; }
.trow:hover { background: #f2f6fb; }
.trow.selected { background: #dce9f7; }
.trow .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .mv { visibility: hidden; }
.trow:hover .mv { visibility: visible; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.budget { color: #777; font-size: 12px; }

.form-panel { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 14px; margin-top: 12px; }
.form-panel label { display: block; margin: 8px 0 3px; font-size: 13px; color: #555; }
.form-panel input, .form-panel select, .form-panel textarea { width: 100%; }
.form-row { display: flex; gap: 10px; }
.form-row > div { flex: 1; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal .box { background: #fff; border-radius: 8px; padding: 20px; width: 520px; max-width: 94vw; max-height: 86vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }
.token-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #eee; }
.token-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 20; }
.toast { background: #323232; color: #fff; padding: 10px 14px; border-radius: 6px; margin-top: 8px; max-width: 360px; }
.toast.err { background: #a93226; }

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block !important; position: absolute; inset: 0; }
}

.budget-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.budget-bar h2 { font-size: 17px; margin: 0 auto 0 0; }
.budget-table { border-collapse: collapse; width: 100%; background: #fff; font-size: 13px; }
.budget-table th, .budget-table td { border: 1px solid #e3e3e3; padding: 3px 4px; text-align: right; white-space: nowrap; }
.budget-table th { background: #f2f4f7; position: sticky; top: 0; }
.budget-table td:first-child, .budget-table th:first-child { text-align: left; white-space: normal; min-width: 220px; }
.budget-table td.bcell input { width: 84px; text-align: right; padding: 2px 4px; font-size: 12px; border: 1px solid transparent; background: transparent; }
.budget-table td.bcell input:hover, .budget-table td.bcell input:focus { border-color: #9db8d2; background: #fff; }
.budget-table td.bcell input.fact { color: #1a6b1a; }
.budget-table td.bcell input.unpaid-plan { background: #fff7e6; }
.budget-table tr.section td { background: #eaf0f7; font-weight: bold; text-align: left; }
.budget-table tr.total td { background: #dce9f7; font-weight: bold; }
.budget-table .paid-cb { width: auto !important; }
.budget-wrap { overflow: auto; max-height: 74vh; border: 1px solid #ddd; border-radius: 6px; }
.badge-link { font-size: 12px; color: #777; }

.budget-strip { padding: 8px 10px; margin-top: 8px; background:#fffbe8; border:1px solid #e6d9a8; border-radius:6px; font-size:13px; }
.bs-fact { color:#1a6b1a; }
