:root {
  color-scheme: light;
  --bg: #f3f1eb;
  --surface: #fffefa;
  --surface-2: #ece9e1;
  --text: #17211d;
  --muted: #68736e;
  --border: #dcd9d0;
  --accent: #285f4e;
  --accent-soft: #e1efe9;
  --warning: #a7652a;
  --warning-soft: #fff0df;
  --danger: #a94743;
  --shadow: 0 16px 48px rgb(27 41 34 / 12%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgb(40 95 78 / 13%), transparent 34%),
    radial-gradient(circle at 85% 85%, rgb(167 101 42 / 12%), transparent 30%),
    #f3f1eb;
}

.auth-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 13px;
  color: #f7fffb;
  background: var(--accent);
  font-size: 20px;
  font-weight: 600;
}

.brand-mark.small { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; }
.auth-heading h1 { margin: 18px 0 0; font-size: 28px; letter-spacing: -.03em; }
.auth-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.auth-form { display: grid; gap: 13px; margin-top: 26px; }
.auth-form label, .dialog-body label, .form-row label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.auth-form input, .dialog-body input, .dialog-body select, .form-row input, .form-row select, .search-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #fbfaf6;
  font-size: 12px;
}
.auth-form input:focus, .dialog-body input:focus, .dialog-body select:focus, .form-row input:focus, .form-row select:focus, .search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(40 95 78 / 10%); }
.primary-btn, .secondary-btn, .danger-btn {
  display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 6px;
  padding: 0 13px; border-radius: 9px; font-size: 11px; font-weight: 500; white-space: nowrap;
}
.primary-btn { border: 1px solid var(--accent); color: #f7fffb; background: var(--accent); }
.secondary-btn { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.danger-btn { border: 1px solid #e7c8c5; color: var(--danger); background: #fff7f6; }
.wide-btn { width: 100%; height: 42px; margin-top: 2px; }
.form-error { min-height: 15px; color: var(--danger); font-size: 10px; }
.demo-account { margin-top: 20px; padding: 12px; border-radius: 10px; color: var(--muted); background: var(--surface-2); font-size: 9px; line-height: 1.7; }

.app-shell { min-height: 100vh; background: var(--bg); }
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(280px, 1fr); align-items: center; gap: 18px;
  min-height: 68px; padding: 0 22px; border-bottom: 1px solid var(--border); background: rgb(255 254 250 / 96%); backdrop-filter: blur(12px);
}
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-brand strong { display: block; font-size: 14px; font-weight: 600; }
.header-brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.date-nav { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 11px; background: #f8f6f1; }
.date-nav button { height: 29px; padding: 0 9px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 11px; }
.date-nav button:hover { color: var(--text); background: var(--surface-2); }
.date-nav .date-label { min-width: 122px; color: var(--text); font-weight: 500; }
.header-user { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.user-copy { text-align: right; }
.user-copy strong { display: block; font-size: 11px; font-weight: 500; }
.user-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.sync-status { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
.sync-status::before { width: 6px; height: 6px; border-radius: 50%; background: #48a87e; content: ""; }
.sync-status.offline::before { background: var(--danger); }

.app-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar { display: flex; flex-direction: column; padding: 19px 12px 14px; border-right: 1px solid var(--border); background: #f0eee8; }
.nav-label { padding: 0 10px 8px; color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.main-nav { display: grid; gap: 3px; margin-bottom: 16px; }
.main-nav button, .nav-secondary {
  display: flex; width: 100%; height: 38px; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 11px; text-align: left;
}
.main-nav button:hover, .nav-secondary:hover { color: var(--text); background: var(--surface-2); }
.main-nav button.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.main-nav button.nav-sub { height: 32px; padding-left: 28px; font-size: 10px; }
.main-nav button span { display: grid; min-width: 20px; height: 20px; place-items: center; padding: 0 5px; border-radius: 99px; background: var(--surface-2); font-size: 8px; }
.main-nav button.active span { background: rgb(40 95 78 / 10%); }
.nav-secondary { margin-top: auto; }
.sidebar-summary { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.sidebar-summary span { display: block; color: var(--muted); font-size: 8px; }
.sidebar-summary strong { display: block; margin: 5px 0; font-size: 22px; font-weight: 600; }
.sidebar-summary b { color: var(--text); font-weight: 500; }

.main-content { min-width: 0; padding: 20px 22px 28px; }
.view-panel { max-width: 1600px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.view-head h1 { margin: 0; font-size: 25px; font-weight: 600; letter-spacing: -.025em; }
.view-head p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.view-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-box { position: relative; width: 250px; }
.search-box::before { position: absolute; top: 50%; left: 12px; color: var(--muted); content: "⌕"; transform: translateY(-52%); font-size: 17px; }
.search-box input { padding-left: 32px; }
.filter-select { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); font-size: 11px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.summary-card { padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.summary-card span { display: block; color: var(--muted); font-size: 9px; }
.summary-card strong { display: block; margin-top: 7px; font-size: 22px; font-weight: 600; }
.main-note-card { margin-bottom: 14px; padding: 14px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.main-note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.main-note-head strong { font-size: 12px; font-weight: 600; }
.main-note-head span { color: var(--muted); font-size: 8px; }
.main-note-card textarea { width: 100%; min-height: 78px; margin-top: 9px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; outline: 0; color: var(--text); background: #fbfaf6; font: inherit; font-size: 10px; line-height: 1.6; resize: vertical; }
.main-note-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(40 95 78 / 10%); }

.manager-section { margin-top: 15px; }
.manager-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; padding: 0 2px; }
.manager-heading strong { font-size: 11px; font-weight: 500; }
.manager-heading span { color: var(--muted); font-size: 9px; }
.project-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.project-card { min-width: 0; padding: 10px 11px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.project-card.pinned { border-color: rgb(40 95 78 / 38%); background: #fbfdf9; }
.project-card-head { display: flex; align-items: flex-start; gap: 7px; }
.project-name { flex: 1; min-width: 0; overflow: hidden; font-size: 10px; font-weight: 500; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.project-actions { display: flex; flex: none; gap: 2px; }
.mini-btn { display: grid; width: 24px; height: 24px; place-items: center; padding: 0; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 12px; }
.mini-btn:hover { color: var(--text); background: var(--surface-2); }
.mini-btn.active { color: var(--accent); background: var(--accent-soft); }
.task-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 8px; }
.task-btn { display: inline-flex; min-width: 0; height: 28px; align-items: center; justify-content: center; gap: 3px; padding: 0 4px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); background: transparent; font-size: 8px; white-space: nowrap; }
.task-btn.done { border-color: rgb(40 95 78 / 35%); color: var(--accent); background: var(--accent-soft); }
.card-footer { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.note-input { flex: 1; min-width: 0; height: 25px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px; outline: 0; color: var(--muted); background: transparent; font-size: 8px; }
.note-input:focus { border-color: var(--border); color: var(--text); background: #fbfaf6; }
.complete-btn { display: inline-flex; flex: none; height: 25px; align-items: center; gap: 4px; padding: 0 7px; border: 1px solid rgb(40 95 78 / 32%); border-radius: 6px; color: var(--accent); background: var(--accent-soft); font-size: 8px; font-weight: 500; }
.status-pill { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 99px; color: var(--muted); background: var(--surface-2); font-size: 8px; }
.status-pill.done { color: var(--accent); background: var(--accent-soft); }
.status-pill.warn { color: var(--warning); background: var(--warning-soft); }
.group-badge { display: inline-flex; flex: none; padding: 3px 7px; border-radius: 99px; color: var(--accent); background: var(--accent-soft); font-size: 8px; }
.group-summary { display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 8px; }
.group-track { height: 5px; margin-top: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.group-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.region-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.region-list span { padding: 2px 6px; border-radius: 99px; color: var(--muted); background: var(--surface-2); font-size: 8px; }
.open-group-btn { display: inline-flex; height: 26px; align-items: center; margin-top: 8px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface); font-size: 8px; }
.claim-btn { width: 100%; height: 28px; margin-top: 9px; border: 1px solid var(--accent); border-radius: 7px; color: var(--accent); background: var(--accent-soft); font-size: 9px; font-weight: 500; }
.owner-line { margin-top: 8px; color: var(--muted); font-size: 8px; }
.project-note { margin-top: 7px; padding: 6px 8px; border-radius: 7px; color: var(--warning); background: var(--warning-soft); font-size: 8px; line-height: 1.45; overflow-wrap: anywhere; }
.empty-state { display: grid; min-height: 180px; place-items: center; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: 11px; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.pagination span { color: var(--muted); font-size: 9px; }
.pagination-actions { display: flex; gap: 5px; }
.page-btn { min-height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); background: var(--surface); font-size: 9px; }
.page-btn:disabled { cursor: not-allowed; opacity: .4; }

.user-table { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.user-table th, .user-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 10px; text-align: left; }
.user-table th { color: var(--muted); background: #f8f6f1; font-size: 9px; font-weight: 500; }
.user-table tr:last-child td { border-bottom: 0; }
.role-tag { padding: 3px 7px; border-radius: 99px; color: var(--accent); background: var(--accent-soft); font-size: 8px; }
.role-tag.lead { color: #6751a5; background: #eee9fb; }
.role-tag.member { color: var(--muted); background: var(--surface-2); }
.account-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 8px; align-items: end; margin-bottom: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.account-form h3 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 13px; font-weight: 600; }
.form-row { display: grid; gap: 5px; }
.form-row label { font-size: 9px; }
.form-row input, .form-row select { height: 36px; font-size: 10px; }
.progress-groups { display: grid; gap: 12px; }
.progress-account { border: 1px solid var(--border); border-radius: 13px; background: var(--surface); overflow: hidden; }
.progress-account-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: #f8f6f1; }
.progress-account-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: #f7fffb; background: var(--accent); font-size: 12px; font-weight: 600; }
.progress-account-copy { flex: 1; min-width: 0; }
.progress-account-copy strong { display: block; font-size: 12px; font-weight: 600; }
.progress-account-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.progress-total { width: 220px; }
.progress-total-top { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--muted); font-size: 8px; }
.progress-total-top b { color: var(--accent); font-weight: 600; }
.progress-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.progress-table { width: 100%; border-collapse: collapse; }
.progress-table th, .progress-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 9px; text-align: left; }
.progress-table th { color: var(--muted); background: #fbfaf6; font-size: 8px; font-weight: 500; }
.progress-table tr:last-child td { border-bottom: 0; }
.progress-table .num { text-align: center; font-variant-numeric: tabular-nums; }
.manager-progress-name { font-size: 10px; font-weight: 500; }
.manager-progress-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.progress-mini { display: flex; width: 120px; align-items: center; gap: 7px; }
.progress-mini .progress-track { flex: 1; }
.progress-mini span { width: 28px; color: var(--muted); font-size: 8px; text-align: right; }
.progress-unclaimed { opacity: .72; }

.app-dialog { width: min(720px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid var(--border); border-radius: 16px; color: var(--text); background: var(--surface); box-shadow: 0 24px 72px rgb(0 0 0 / 30%); overflow: auto; }
.app-dialog::backdrop { background: rgb(15 24 19 / 50%); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 13px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.icon-btn { display: grid; width: 30px; height: 30px; place-items: center; padding: 0; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 18px; }
.dialog-body { display: grid; gap: 12px; padding: 16px 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.group-dialog { width: min(1000px, calc(100% - 28px)); }
.merge-dialog { width: min(680px, calc(100% - 28px)); }
.group-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.branch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.branch-card { padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fbfaf6; }
.branch-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.branch-region { padding: 3px 7px; border-radius: 99px; color: var(--accent); background: var(--accent-soft); font-size: 8px; }
.branch-name { flex: 1; min-width: 0; overflow: hidden; font-size: 9px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.branch-done { color: var(--muted); font-size: 8px; }
.merge-project-list { display: grid; max-height: 420px; gap: 7px; overflow: auto; padding-right: 3px; }
.merge-option { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fbfaf6; cursor: pointer; }
.merge-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.merge-option input { accent-color: var(--accent); }
.merge-option-copy { min-width: 0; flex: 1; }
.merge-option-copy strong { display: block; overflow: hidden; font-size: 10px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.merge-option-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.manager-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.manager-card { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.manager-card-head { display: flex; align-items: center; gap: 9px; }
.manager-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: #f7fffb; background: var(--accent); font-size: 12px; font-weight: 600; }
.manager-card-copy { min-width: 0; flex: 1; }
.manager-card-copy strong { display: block; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.manager-card-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.manager-claim-btn { width: 100%; height: 32px; margin-top: 13px; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); background: var(--accent-soft); font-size: 9px; font-weight: 500; }
.group-add-btn { height: 26px; margin-top: 8px; margin-left: 5px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); background: var(--surface); font-size: 8px; }
.branch-remove-btn { margin-left: auto; padding: 2px 6px; border: 0; border-radius: 5px; color: var(--danger); background: transparent; font-size: 8px; }
.branch-remove-btn:hover { background: #fff1ef; }
.toast { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: none; max-width: 380px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-size: 10px; }
.toast.show { display: block; }

@media (min-width: 1500px) {
  .project-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .project-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .manager-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .account-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-header { grid-template-columns: 1fr auto; }
  .date-nav { display: none; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .nav-label, .sidebar-summary, .nav-secondary { display: none; }
  .main-nav { display: flex; margin: 0; gap: 4px; }
  .main-nav button { width: auto; white-space: nowrap; }
  .main-content { padding: 14px 12px 24px; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manager-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .branch-grid { grid-template-columns: 1fr; }
  .progress-account-head { align-items: flex-start; flex-direction: column; }
  .progress-total { width: 100%; }
  .progress-table { min-width: 760px; }
  .progress-account { overflow-x: auto; }
}

@media (max-width: 560px) {
  .auth-card { padding: 24px 20px; }
  .header-user .sync-status, .user-copy { display: none; }
  .view-head { align-items: flex-start; flex-direction: column; }
  .search-box { width: 100%; }
  .project-grid { grid-template-columns: 1fr; }
  .manager-grid { grid-template-columns: 1fr; }
  .account-form { grid-template-columns: 1fr; }
}
