:root {
  --paper: #f4f0e8;
  --surface: #fffdf8;
  --ink: #1f2925;
  --muted: #68716b;
  --line: #ded8cc;
  --wood: #8b5e3c;
  --wood-dark: #5f3f2a;
  --terracotta: #b9684b;
  --olive: #6f7654;
  --bluegray: #637887;
  --soft-green: #e4eadf;
  --soft-red: #f3dfd6;
  --soft-blue: #e3e9eb;
  --shadow: 0 18px 50px rgba(55, 45, 35, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #e9e2d6;
}
.login-card {
  width: min(560px, 100%);
  padding: 52px;
  border: 1px solid rgba(95, 63, 42, 0.14);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--wood-dark);
  font-family: "Songti SC", serif;
  font-size: 28px;
}
.login-card h1 { margin: 8px 0 12px; font: 600 38px/1.2 "Songti SC", serif; }
.eyebrow { margin: 26px 0 0; color: var(--wood); font-size: 12px; font-weight: 700; letter-spacing: 0.16em; }
.login-copy { margin: 0 0 34px; color: var(--muted); line-height: 1.8; }
.login-card label { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 600; }
.login-row { display: flex; gap: 10px; }
.login-row input { min-width: 0; flex: 1; border: 1px solid var(--line); padding: 13px 14px; outline: 0; background: #fff; }
.login-row input:focus { border-color: var(--wood); box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.12); }
.login-row button, .quiet-button {
  border: 1px solid var(--wood-dark);
  padding: 12px 18px;
  color: #fff;
  background: var(--wood-dark);
}
.login-disclosure { margin: 30px 0 0; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.form-error { min-height: 20px; margin: 8px 0 0; color: #a34d38; font-size: 13px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  color: #f7f1e8;
  background: #26302c;
  z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark-small { width: 42px; height: 42px; flex: 0 0 auto; font-size: 20px; background: #9a6845; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 4px; color: #b9c0bc; font-size: 11px; letter-spacing: 0.12em; }
.sidebar nav { display: grid; gap: 5px; margin-top: 50px; }
.sidebar nav a { padding: 11px 13px; color: #c9ceca; border-left: 2px solid transparent; text-decoration: none; font-size: 14px; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; border-left-color: #c98d68; background: rgba(255,255,255,0.06); }
.sidebar-foot { margin-top: auto; color: #aeb7b2; font-size: 11px; line-height: 1.8; }
.sidebar-foot button { display: block; margin-top: 14px; padding: 0; border: 0; color: #d7dcd9; background: none; font-size: 12px; }
.status-dot { width: 7px; height: 7px; display: inline-block; margin-right: 6px; border-radius: 50%; background: #8eb080; }

.dashboard { margin-left: 232px; padding: 42px 4.5vw 50px; }
.topbar { display: flex; justify-content: space-between; gap: 30px; align-items: flex-end; }
.topbar .eyebrow { margin: 0 0 7px; }
.topbar h1 { margin: 0; font: 600 34px/1.2 "Songti SC", serif; }
.topbar-company { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.topbar-actions { text-align: right; }
.topbar-actions p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.topbar-actions strong { color: var(--ink); }
.quiet-button { color: var(--wood-dark); background: transparent; padding: 8px 15px; font-size: 13px; }
.quiet-button:hover { color: #fff; background: var(--wood-dark); }
.disclosure { display: flex; gap: 20px; align-items: center; margin-top: 28px; padding: 13px 16px; border-left: 3px solid var(--terracotta); background: #eee5d9; color: #5d554c; font-size: 13px; }
.disclosure strong { color: #7e4936; white-space: nowrap; }

.section { padding-top: 66px; scroll-margin-top: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 20px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.section-index { margin: 0; color: var(--terracotta); font: 600 13px/1 "Songti SC", serif; }
.section-heading h2 { margin: 0; font: 600 26px/1.25 "Songti SC", serif; }
.section-heading > p { margin: 0; color: var(--muted); font-size: 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card { min-height: 142px; padding: 21px; border: 1px solid var(--line); background: var(--surface); }
.kpi-card p { margin: 0; color: var(--muted); font-size: 12px; }
.kpi-card strong { display: block; margin: 17px 0 6px; font: 600 30px/1 "Songti SC", serif; }
.kpi-card small { color: var(--muted); }
.kpi-card.alert { border-top: 3px solid var(--terracotta); }
.overview-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 14px; margin-top: 14px; }
.panel { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 8px 24px rgba(55,45,35,0.03); }
.focus-panel, .activity-panel { padding: 24px; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.panel-heading h3 { margin: 0; font-size: 16px; }
.panel-heading span { color: var(--muted); font-size: 11px; }
.attention-item { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.attention-item:first-child { border-top: 0; }
.attention-item i { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--terracotta); }
.attention-item strong, .attention-item span { display: block; }
.attention-item strong { font-size: 14px; }
.attention-item span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.timeline { max-height: 310px; overflow: auto; }
.timeline-item { position: relative; padding: 0 0 18px 22px; border-left: 1px solid var(--line); }
.timeline-item::before { content: ""; position: absolute; left: -4px; top: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--wood); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item strong { display: block; font-size: 13px; }
.timeline-item p { margin: 5px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.timeline-item small { color: #929791; font-size: 10px; }

.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.quotation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.quotation-card { padding: 24px; }
.quotation-card .eyebrow { margin: 0 0 10px; }
.quotation-card h3 { margin: 0; font: 600 18px/1.45 "Songti SC", serif; }
.quotation-card > strong { display: block; margin: 20px 0 10px; font: 600 26px/1 "Songti SC", serif; }
.quotation-card > strong small { color: var(--muted); font: 400 12px/1 sans-serif; }
.quotation-card p:not(.eyebrow) { color: var(--muted); font-size: 12px; }
.quotation-card > small { color: #8a8278; font-size: 10px; }
.site-overview-grid { display: grid; gap: 14px; }
.site-card { padding: 26px; border-top: 3px solid var(--bluegray); }
.site-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 22px; background: var(--line); }
.site-summary div { padding: 16px; background: #f7f3ec; }
.site-summary span, .site-summary strong { display: block; }
.site-summary span { color: var(--muted); font-size: 10px; }
.site-summary strong { margin-top: 6px; font-size: 12px; line-height: 1.5; }
.site-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 20px 0 14px; }
.site-detail p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.site-detail strong { display: block; margin-bottom: 5px; color: var(--ink); }
.site-card > small { color: #8a8278; font-size: 10px; }
.project-card { padding: 24px; border-top: 3px solid var(--olive); }
.project-card.risk { border-top-color: var(--terracotta); }
.project-title { display: flex; justify-content: space-between; gap: 14px; }
.project-title h3 { margin: 0; font: 600 19px/1.35 "Songti SC", serif; }
.project-title p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--soft-green); color: #506047; font-size: 11px; white-space: nowrap; }
.badge.at_risk, .badge.pending { background: var(--soft-red); color: #8d4b39; }
.badge.confirmed, .badge.in_progress { background: var(--soft-blue); color: #536a78; }
.badge.delivered, .badge.approved, .badge.sent { background: var(--soft-green); color: #52634c; }
.badge.payable, .badge.completed { background: #dbe9d4; color: #435c3a; }
.badge.lead, .badge.measured, .badge.designing, .badge.quoted, .badge.contracted {
  background: var(--soft-blue);
  color: #536a78;
}
.badge.sales, .badge.designer, .badge.foreman { background: #eee5d9; color: var(--wood-dark); }
.badge.rejected, .badge.cancelled, .badge.expired { background: #ece9e4; color: #77736d; }
.progress-label { display: flex; justify-content: space-between; margin-top: 24px; font-size: 12px; }
.progress-track { width: 100%; height: 7px; margin-top: 8px; border: 0; border-radius: 0; appearance: none; background: #e8e3da; }
.progress-track::-webkit-progress-bar { background: #e8e3da; }
.progress-track::-webkit-progress-value { background: var(--olive); }
.progress-track::-moz-progress-bar { background: var(--olive); }
.project-facts { display: grid; gap: 10px; margin: 20px 0 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.project-facts div { display: flex; justify-content: space-between; gap: 18px; font-size: 12px; }
.project-facts span { color: var(--muted); }
.project-money { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-top: 18px; }
.project-money span, .project-money strong { display: block; }
.project-money span { color: var(--muted); font-size: 10px; }
.project-money strong { margin-top: 4px; font-size: 14px; }

.table-panel { padding: 4px 20px 14px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 15px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { color: var(--muted); font-weight: 500; }
td strong { font-weight: 600; }
.table-note { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.overdue { color: #9e4e3a; font-weight: 600; }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two-column .panel { padding: 24px; }
.team-grid .panel { max-height: 560px; overflow: auto; }
.stack-item { padding: 16px 0; border-top: 1px solid var(--line); }
.stack-item:first-child { border-top: 0; padding-top: 0; }
.stack-meta { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 7px; }
.stack-meta strong { font-size: 13px; }
.stack-item p { margin: 0; color: #454d48; font-size: 13px; line-height: 1.7; }
.stack-item small { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; }

.finance-panel { padding: 26px; }
.finance-total { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.finance-total div { padding: 18px; background: #f7f3ec; }
.finance-total span, .finance-total strong { display: block; }
.finance-total span { color: var(--muted); font-size: 11px; }
.finance-total strong { margin-top: 8px; font: 600 22px/1 "Songti SC", serif; }
.finance-projects { display: grid; gap: 16px; margin-top: 26px; }
.finance-subheading { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.finance-row { display: grid; grid-template-columns: 1.2fr repeat(4, 1fr); gap: 18px; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.finance-row:last-child { border-bottom: 0; padding-bottom: 0; }
.finance-row span, .finance-row strong { display: block; }
.finance-row span { color: var(--muted); font-size: 10px; }
.finance-row strong { margin-top: 5px; font-size: 13px; }

.approval-list { padding: 8px 24px; }
.approval-item { display: grid; grid-template-columns: 1.2fr 2fr 0.7fr 0.9fr; gap: 18px; align-items: center; padding: 17px 0; border-bottom: 1px solid var(--line); }
.approval-item:last-child { border-bottom: 0; }
.approval-item p { margin: 0; font-size: 12px; line-height: 1.5; }
.approval-item small { display: block; margin-top: 4px; color: var(--muted); }
.empty { padding: 26px 0; color: var(--muted); text-align: center; font-size: 13px; }

.knowledge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.knowledge-card { padding: 22px; }
.knowledge-card h3 { margin: 0; font: 600 18px/1.4 "Songti SC", serif; }
.knowledge-card p { margin: 12px 0 0; color: #515954; font-size: 13px; line-height: 1.8; }
.knowledge-card small { display: block; margin-top: 14px; color: var(--muted); font-size: 10px; }

footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 70px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(20px); opacity: 0; padding: 12px 16px; color: #fff; background: #26302c; box-shadow: var(--shadow); transition: 0.2s ease; z-index: 20; pointer-events: none; font-size: 12px; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .project-grid { grid-template-columns: 1fr; }
  .quotation-grid { grid-template-columns: 1fr; }
  .project-card { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; }
  .project-title, .progress-label, .progress-track { grid-column: 1; }
  .project-facts, .project-money { grid-column: 2; }
  .project-facts { grid-row: 1 / span 3; margin: 0; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: auto; min-height: auto; padding: 16px 18px; }
  .sidebar nav { display: flex; margin-top: 18px; overflow-x: auto; }
  .sidebar nav a { flex: 0 0 auto; border-left: 0; border-bottom: 2px solid transparent; }
  .sidebar nav a.active { border-left: 0; border-bottom-color: #c98d68; }
  .sidebar-foot { display: none; }
  .dashboard { margin-left: 0; padding: 28px 18px 40px; }
  .topbar { align-items: flex-start; }
  .topbar-actions p { display: none; }
  .disclosure { align-items: flex-start; flex-direction: column; gap: 5px; }
  .section { padding-top: 52px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .overview-grid, .two-column, .knowledge-grid { grid-template-columns: 1fr; }
  .project-card { display: block; }
  .project-facts { margin-top: 20px; }
  .finance-total { grid-template-columns: repeat(2, 1fr); }
  .finance-row { grid-template-columns: repeat(2, 1fr); }
  .site-summary, .site-detail { grid-template-columns: 1fr; }
  .finance-row > div:first-child { grid-column: 1 / -1; }
  .approval-item { grid-template-columns: 1fr; gap: 8px; }
  .login-card { padding: 34px 24px; }
  .login-row { flex-direction: column; }
  footer { flex-direction: column; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 118px; }
  .topbar h1 { font-size: 29px; }
  .topbar-company { max-width: 210px; }
  .finance-total { grid-template-columns: 1fr; }
}
