:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-muted: #edf1ed;
  --ink: #17211d;
  --muted: #65716b;
  --line: #d8ded9;
  --green: #1f6f55;
  --green-dark: #15533f;
  --green-soft: #dcece4;
  --blue: #2866a6;
  --blue-soft: #e2edf8;
  --amber: #aa6814;
  --amber-soft: #f7ead5;
  --red: #b1453d;
  --red-soft: #f7e4e1;
  --violet: #765391;
  --violet-soft: #eee6f3;
  --shadow: 0 8px 26px rgba(23, 33, 29, 0.08);
  --sidebar-width: 220px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(40, 102, 166, 0.28); outline-offset: 2px; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
.is-hidden { display: none !important; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9eeea; }
.auth-panel { width: min(100%, 390px); padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.brand { min-width: 0; display: flex; align-items: center; gap: 10px; }
.brand img { flex: 0 0 auto; border-radius: 8px; }
.brand div { min-width: 0; display: grid; }
.brand strong { font-size: 16px; line-height: 1.3; }
.brand span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.brand--auth { margin-bottom: 32px; }
.brand--auth strong { font-size: 22px; }
.auth-form { display: grid; gap: 16px; }
.auth-form h1 { margin: 0 0 2px; font-size: 24px; }

label { display: grid; gap: 7px; color: #35413b; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); }
input, select { min-height: 42px; padding: 9px 11px; }
textarea { min-height: 100px; padding: 11px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #929c97; }
input:hover, select:hover, textarea:hover { border-color: #b8c2bc; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar-width); display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 18px; border-right: 1px solid var(--line); background: #fbfcfb; }
.sidebar > .brand { padding: 0 8px; }
.main-nav { display: grid; gap: 3px; }
.nav-button { position: relative; width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 0; border-radius: 5px; background: transparent; color: #445049; text-align: left; }
.nav-button:hover { background: var(--surface-muted); color: var(--ink); }
.nav-button.is-active { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.nav-count { min-width: 22px; height: 22px; display: grid; place-items: center; margin-left: auto; padding: 0 6px; border-radius: 11px; background: var(--red); color: white; font-size: 11px; }
.sidebar-settings { margin-top: auto; }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; top: 0; z-index: 15; height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px clamp(18px, 3vw, 38px); border-bottom: 1px solid var(--line); background: rgba(244, 246, 243, 0.96); backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-size: 23px; line-height: 1.15; }
.kicker { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.production-switches { display: flex; align-items: center; gap: 8px; }
.production-switches label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.production-switches select { min-height: 36px; width: auto; padding: 7px 28px 7px 9px; border-color: #cfd6d1; background-color: #fff; font-size: 13px; font-weight: 600; }
.icon-button { width: 38px; height: 38px; flex: 0 0 38px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: #46534c; }
.icon-button:hover { border-color: #aebbb3; color: var(--green-dark); background: #f9fbf9; }
.icon-button.is-spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view { width: min(100%, 1480px); margin: 0 auto; padding: 24px clamp(18px, 3vw, 38px) 96px; }
.sync-status { margin: 12px clamp(18px, 3vw, 38px) 0; padding: 10px 13px; border: 1px solid #b9d3c6; border-radius: 5px; background: #e8f3ed; color: var(--green-dark); font-size: 13px; }
.section { margin-bottom: 30px; }
.section-header { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.section-header h2 { margin: 0; font-size: 17px; }
.section-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.section-actions { display: flex; align-items: center; gap: 8px; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 26px; }
.stat-tile { min-height: 94px; display: grid; align-content: center; gap: 5px; padding: 15px; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 6px; background: var(--surface); }
.stat-tile:nth-child(2) { border-left-color: var(--blue); }
.stat-tile:nth-child(3) { border-left-color: var(--amber); }
.stat-tile:nth-child(4) { border-left-color: var(--violet); }
.stat-tile:nth-child(5) { border-left-color: var(--red); }
.stat-tile strong { font-size: 26px; line-height: 1; }
.stat-tile span { color: var(--muted); font-size: 12px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.8fr); gap: 24px; }
.stack { display: grid; gap: 10px; }
.event-card, .list-card, .person-card, .product-card, .feedback-card { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.event-card { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; gap: 15px; padding: 15px; }
.event-card:hover, .list-card:hover, .person-card:hover, .product-card:hover { border-color: #b8c2bc; box-shadow: 0 5px 16px rgba(23, 33, 29, 0.05); }
.event-score { width: 56px; height: 56px; display: grid; place-items: center; align-content: center; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); }
.event-score strong { font-size: 20px; line-height: 1; }
.event-score span { margin-top: 2px; font-size: 9px; }
.event-body { min-width: 0; }
.event-body h3, .list-card h3, .person-card h3, .product-card h3, .feedback-card h3 { margin: 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.event-body p { display: -webkit-box; overflow: hidden; margin: 6px 0 9px; color: #59655f; font-size: 12px; line-height: 1.55; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meta-row, .tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.meta-row { color: var(--muted); font-size: 11px; }
.meta-row span { display: inline-flex; align-items: center; gap: 4px; }
.meta-row svg { width: 13px; height: 13px; }
.tag, .score-tag, .status-tag { min-height: 24px; display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.tag { background: var(--surface-muted); color: #4f5b55; }
.score-tag { background: var(--blue-soft); color: #244f79; }
.score-tag--50 { background: var(--amber-soft); color: #7c4a0c; }
.status-tag { background: var(--green-soft); color: var(--green-dark); }
.status-tag--muted { background: #ecefed; color: #68736d; }
.status-tag--risk { background: var(--red-soft); color: var(--red); }
.event-actions { min-width: 118px; display: flex; align-items: flex-start; justify-content: flex-end; gap: 6px; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 5px; font-size: 13px; font-weight: 700; }
.button svg { width: 16px; height: 16px; }
.button--primary { background: var(--green); color: #fff; }
.button--primary:hover { background: var(--green-dark); }
.button--secondary { border-color: #b9d0e5; background: var(--blue-soft); color: #214f79; }
.button--ghost { border-color: var(--line); background: var(--surface); color: #49564f; }
.button--danger { border-color: #e2b8b4; background: var(--red-soft); color: var(--red); }
.button--small { min-height: 32px; padding: 6px 9px; font-size: 12px; }
.button--wide { width: 100%; }
.button[disabled], .icon-button[disabled] { cursor: not-allowed; opacity: 0.55; }

.calendar-list { border-top: 1px solid var(--line); }
.calendar-row { min-height: 72px; display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.calendar-date { display: grid; color: var(--green-dark); }
.calendar-date strong { font-size: 18px; }
.calendar-date span { color: var(--muted); font-size: 11px; }
.calendar-row h3 { margin: 0 0 4px; font-size: 14px; }
.calendar-row p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.list-card { display: grid; gap: 9px; padding: 14px; }
.list-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.list-card__actions { display: flex; gap: 6px; }
.list-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; white-space: pre-line; }
.due { color: var(--red); font-weight: 700; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-box { position: relative; width: min(310px, 100%); }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 34px; }
.segmented { display: inline-flex; min-height: 36px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #e9eeea; }
.segmented button { min-width: 52px; min-height: 28px; padding: 4px 9px; border: 0; border-radius: 4px; background: transparent; color: #59655f; font-size: 12px; }
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(23, 33, 29, 0.08); font-weight: 700; }

.capture-band { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); gap: 20px; margin-bottom: 26px; padding: 18px; border: 1px solid #bfd3c8; border-radius: 6px; background: #e8f2ec; }
.capture-form { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 9px; }
.capture-import { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.upload-label { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 12px; border: 1px solid #b8c9bf; border-radius: 5px; background: var(--surface); color: #435048; font-size: 13px; font-weight: 700; cursor: pointer; }
.upload-label input { display: none; }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { min-width: 240px; }
.kanban-header { display: flex; align-items: center; justify-content: space-between; min-height: 38px; padding: 0 4px; }
.kanban-header h2 { margin: 0; font-size: 14px; }
.kanban-header span { color: var(--muted); font-size: 11px; }
.kanban-column .stack { align-content: start; }
.topic-card { min-height: 170px; display: grid; align-content: start; gap: 9px; padding: 13px; border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: 6px; background: var(--surface); }
.topic-card[data-status="观察"] { border-top-color: var(--blue); }
.topic-card[data-status="已排期"] { border-top-color: var(--amber); }
.topic-card[data-status="制作中"] { border-top-color: var(--violet); }
.topic-card h3 { margin: 0; font-size: 14px; line-height: 1.45; }
.topic-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.topic-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }

.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.person-card, .product-card { min-height: 190px; display: grid; align-content: start; gap: 10px; padding: 15px; }
.entity-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); }
.product-card .entity-icon { border-radius: 6px; background: var(--blue-soft); color: var(--blue); }
.entity-details { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 5px 8px; font-size: 12px; }
.entity-details dt { color: var(--muted); }
.entity-details dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }

.feedback-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(310px, 0.7fr); gap: 22px; }
.baseline-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.baseline-table th, .baseline-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
.baseline-table th { color: var(--muted); font-weight: 700; }
.feedback-card { display: grid; gap: 10px; padding: 14px; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.metric { display: grid; gap: 2px; padding: 8px; background: var(--surface-muted); border-radius: 4px; }
.metric strong { font-size: 15px; }
.metric span { color: var(--muted); font-size: 10px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-section { padding: 18px 0; border-top: 1px solid var(--line); }
.settings-section h2 { margin: 0 0 14px; font-size: 16px; }
.settings-form { display: grid; gap: 12px; }
.source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.source-row h3 { margin: 0 0 4px; font-size: 13px; }
.source-row p { margin: 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.source-row__status { display: grid; justify-items: end; align-content: center; gap: 4px; }
.source-row__status time { color: var(--muted); font-size: 10px; }
.export-row { display: flex; flex-wrap: wrap; gap: 8px; }

.empty-state { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 9px; padding: 30px; border: 1px dashed #bec8c2; border-radius: 6px; color: var(--muted); text-align: center; }
.empty-state svg { width: 30px; height: 30px; }
.empty-state p { margin: 0; font-size: 13px; }
.loading-state { min-height: 240px; display: grid; place-items: center; color: var(--muted); }
.loading-state svg { animation: spin 0.8s linear infinite; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 12px; }

.quick-add { position: fixed; right: 26px; bottom: 26px; z-index: 30; min-width: 100px; height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 16px; border: 0; border-radius: 23px; background: var(--green); color: #fff; box-shadow: 0 8px 24px rgba(21, 83, 63, 0.28); font-weight: 800; }
.quick-add:hover { background: var(--green-dark); }

.modal { width: min(720px, calc(100vw - 28px)); max-height: min(88vh, 850px); padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 24px 70px rgba(23, 33, 29, 0.25); }
.modal::backdrop, .more-sheet::backdrop { background: rgba(15, 23, 19, 0.42); backdrop-filter: blur(2px); }
.modal > form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; max-height: inherit; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 13px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 3px 0 0; font-size: 19px; }
.modal-body { overflow-y: auto; display: grid; gap: 14px; padding: 18px 20px; }
.modal-body .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.modal-body .form-grid .span-2 { grid-column: 1 / -1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 20px 18px; }
.modal .form-error { padding: 0 20px; }

.more-sheet { width: calc(100% - 20px); max-width: 430px; margin: auto auto 8px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.more-sheet header { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 18px; border-bottom: 1px solid var(--line); }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 16px; }
.more-grid button { min-height: 82px; display: grid; place-items: center; align-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.more-grid svg { color: var(--green); }

.toast-region { position: fixed; right: 20px; top: 90px; z-index: 100; width: min(360px, calc(100vw - 40px)); display: grid; gap: 8px; }
.toast { padding: 12px 14px; border: 1px solid #bad0c4; border-radius: 6px; background: #f8fffb; color: var(--green-dark); box-shadow: var(--shadow); font-size: 13px; animation: toast-in 0.18s ease-out; }
.toast.is-error { border-color: #e1b5b1; background: #fff9f8; color: var(--red); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }
.bottom-nav { display: none; }

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .feedback-layout { grid-template-columns: 1fr; }
  .capture-band { grid-template-columns: 1fr; }
  .capture-import { justify-content: flex-start; }
}

@media (max-width: 780px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .topbar { height: 68px; padding: 10px 14px; }
  .topbar h1 { font-size: 20px; }
  .production-switches label > span { display: none; }
  .production-switches select { max-width: 108px; min-height: 34px; padding-left: 7px; font-size: 12px; }
  #user-menu-button { display: none; }
  .view { padding: 18px 14px 118px; }
  .sync-status { margin: 10px 14px 0; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .stat-tile { min-height: 80px; padding: 11px; }
  .stat-tile strong { font-size: 22px; }
  .dashboard-grid { gap: 8px; }
  .event-card { grid-template-columns: 48px minmax(0, 1fr); gap: 11px; padding: 12px; }
  .event-score { width: 46px; height: 46px; }
  .event-score strong { font-size: 17px; }
  .event-actions { grid-column: 1 / -1; justify-content: flex-end; min-width: 0; padding-top: 2px; }
  .calendar-row { grid-template-columns: 76px minmax(0, 1fr); gap: 10px; }
  .calendar-row > .button { grid-column: 2; justify-self: start; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented button { flex: 1 0 auto; }
  .capture-form { grid-template-columns: 1fr; }
  .capture-import { display: grid; grid-template-columns: 1fr 1fr; }
  .library-grid, .settings-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 84vw); scroll-snap-type: x proximity; }
  .kanban-column { scroll-snap-align: start; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 18px); margin: auto 8px 8px; }
  .modal-body .form-grid { grid-template-columns: 1fr; }
  .modal-body .form-grid .span-2 { grid-column: auto; }
  .quick-add { right: 16px; bottom: 82px; width: 48px; min-width: 48px; height: 48px; padding: 0; border-radius: 50%; }
  .quick-add span { display: none; }
  .bottom-nav { position: fixed; inset: auto 0 0; z-index: 25; height: calc(66px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); padding: 5px 5px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.97); backdrop-filter: blur(12px); }
  .bottom-nav button { display: grid; place-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: #69756f; font-size: 10px; }
  .bottom-nav button.is-active { color: var(--green-dark); font-weight: 700; }
  .bottom-nav svg { width: 20px; height: 20px; }
  .toast-region { top: 76px; right: 12px; width: calc(100vw - 24px); }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-actions { gap: 5px; }
  .production-switches { gap: 4px; }
  .production-switches select { max-width: 92px; }
  .section-header { align-items: flex-start; }
  .section-actions { flex-wrap: wrap; justify-content: flex-end; }
  .auth-panel { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
