:root {
  --ink: #172033;
  --muted: #62708a;
  --line: #e3e8f0;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --nav: #11203b;
  --nav-soft: #1a3158;
  --brand: #2864dc;
  --brand-dark: #1e51bb;
  --success: #16835d;
  --warning: #b76a00;
  --danger: #c33a42;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(28, 44, 77, .08);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }

.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 28px;
  background: radial-gradient(circle at 15% 10%, #dbe8ff 0, transparent 32%),
    radial-gradient(circle at 90% 95%, #daeede 0, transparent 28%), #f5f7fb;
}
.auth-panel { width: min(100%, 450px); background: var(--surface); border: 1px solid #ebeff6; border-radius: 18px; box-shadow: var(--shadow); padding: 36px; }
.auth-brand { display: flex; gap: 13px; align-items: center; margin-bottom: 30px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #3977ef, #214da5); font-size: 23px; font-weight: 800; box-shadow: 0 6px 14px rgba(37, 92, 205, .22); }
.brand-mark.compact { width: 31px; height: 31px; border-radius: 9px; font-size: 16px; }
.auth-brand h1 { margin: 0; font-size: 20px; }
.auth-brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.form-heading { margin-bottom: 21px; }
.form-heading h2 { margin: 0; font-size: 19px; }
.form-heading p { color: var(--muted); margin: 7px 0 0; }
.auth-form { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: #3b4860; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; color: var(--ink); background: #fff; border: 1px solid #cad3e1; border-radius: 8px; padding: 10px 11px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(40, 100, 220, .13); }
.form-notice { min-height: 20px; margin: 16px 0 0; color: var(--muted); }

.app-shell { min-height: 100vh; }
.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; color: #fff; background: var(--nav); box-shadow: 0 1px 0 rgba(255,255,255,.07); }
.topbar-brand, .topbar-actions, .month-controls, .context-actions, .toolbar, .table-actions, .modal-actions, .record-topline { display: flex; align-items: center; gap: 10px; }
.topbar-brand { font-size: 16px; font-weight: 700; }
.topbar-actions { gap: 12px; }
.current-user { color: #dce7fa; }
.save-status { font-size: 12px; color: #bdd0f0; }
.save-status.is-saving { color: #ffe39e; }
.save-status.is-error { color: #ffb4b8; }
.text-button, .outline-button, .icon-button, .primary-button, .danger-button, .subtle-button {
  border: 0; border-radius: 8px; padding: 9px 12px; transition: background .15s, transform .15s, border-color .15s;
}
.text-button { color: var(--brand); background: transparent; }
.topbar .text-button { color: #dce7fa; }
.text-button:hover { background: #edf3ff; }
.topbar .text-button:hover { background: rgba(255,255,255,.09); }
.outline-button { background: #fff; color: #34435b; border: 1px solid #cad3e1; }
.topbar .outline-button { color: #fff; border-color: rgba(255,255,255,.3); background: transparent; }
.outline-button:hover { border-color: var(--brand); color: var(--brand); }
.primary-button { color: #fff; background: var(--brand); font-weight: 700; }
.primary-button:hover { background: var(--brand-dark); }
.danger-button { color: #fff; background: var(--danger); }
.subtle-button { color: #43516a; background: #eef2f7; }
.icon-button { width: 35px; height: 35px; padding: 0; color: var(--brand); font-size: 20px; background: #edf3ff; }
.wide-button { width: 100%; padding: 12px; }

.workspace { min-height: calc(100vh - 60px); display: grid; grid-template-columns: 214px minmax(0, 1fr); }
.sidebar { padding: 18px 12px; color: #d9e5f9; background: var(--nav); }
.main-nav { display: grid; gap: 4px; }
.nav-item { border: 0; display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border-radius: 8px; padding: 11px 13px; color: #c4d4ed; background: transparent; }
.nav-item span { width: 15px; color: #9ec2ff; text-align: center; font-weight: 800; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active { color: #fff; background: var(--nav-soft); box-shadow: inset 3px 0 0 #66a1ff; }
.sidebar-note { margin: 28px 8px 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.12); color: #91a8ca; font-size: 12px; line-height: 1.65; }
.main-area { min-width: 0; padding: 23px 28px 36px; }
.context-bar { display: flex; justify-content: space-between; gap: 20px; padding: 17px 19px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(31,48,77,.03); }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 12px; }
.month-controls select { min-width: 134px; padding-block: 8px; }
.view-root { margin-top: 20px; }
.view-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.view-heading h1 { margin: 0; font-size: 22px; }
.view-heading p { margin: 6px 0 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(31,48,77,.03); }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric-card { padding: 18px; min-height: 115px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 12px; color: #152548; font-size: 27px; font-weight: 750; letter-spacing: -.5px; }
.metric-help { margin-top: 7px; color: var(--muted); font-size: 12px; }
.dashboard-panels { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); gap: 14px; margin-top: 14px; }
.panel { padding: 19px; }
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.funnel-row { display: grid; grid-template-columns: 106px 1fr 46px; gap: 10px; align-items: center; margin: 11px 0; }
.funnel-bar-wrap { height: 11px; overflow: hidden; border-radius: 999px; background: #edf1f6; }
.funnel-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5e92f4, #2864dc); }
.recent-list { display: grid; gap: 9px; }
.recent-item { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid #edf0f5; }
.recent-item:last-child { border: 0; padding-bottom: 0; }
.muted { color: var(--muted); }

.toolbar { justify-content: space-between; flex-wrap: wrap; padding: 14px; margin-bottom: 14px; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar input { width: min(260px, 58vw); }
.toolbar select { width: auto; min-width: 130px; }
.record-count { color: var(--muted); font-size: 13px; }
.table-card { overflow: hidden; }
.data-table-wrap { overflow: auto; }
.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 12px 13px; color: #58667e; background: #f8fafc; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; font-weight: 700; white-space: nowrap; }
.data-table td { padding: 11px 13px; border-bottom: 1px solid #edf0f5; vertical-align: middle; max-width: 280px; }
.data-table tbody tr:hover { background: #fafcff; }
.data-table td.editable { cursor: text; }
.data-table td.editable:hover { outline: 1px dashed #a7c2f4; outline-offset: -3px; background: #f4f8ff; }
.data-table td .inline-editor { min-width: 115px; padding: 6px 7px; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }
.row-deleted { opacity: .68; background: #fff8f8; }
.cell-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 999px; color: #30568f; background: #eaf2ff; font-size: 12px; white-space: nowrap; }
.status-pill.is-good { color: #117152; background: #e5f6ef; }
.status-pill.is-warning { color: #9a5a00; background: #fff2d8; }
.status-pill.is-danger { color: #a92f36; background: #ffe8ea; }
.table-actions { gap: 4px; white-space: nowrap; }
.table-actions button { padding: 6px 8px; font-size: 12px; }

.public-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.public-card { display: grid; gap: 13px; padding: 18px; }
.public-card h2 { margin: 0; font-size: 16px; }
.public-meta { display: grid; grid-template-columns: 76px 1fr; gap: 7px; color: var(--muted); font-size: 13px; }
.public-meta strong { color: #526079; font-weight: 600; }
.public-card footer { display: flex; justify-content: flex-end; padding-top: 2px; }

.modal-root { position: fixed; z-index: 20; inset: 0; padding: 24px; display: grid; place-items: center; background: rgba(15, 28, 53, .52); }
.modal { width: min(100%, 720px); max-height: calc(100vh - 48px); overflow: auto; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(10, 22, 45, .25); }
.modal.small { width: min(100%, 440px); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 18px 21px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-close { width: 31px; height: 31px; border: 0; border-radius: 8px; color: #5f6b80; background: #edf1f7; font-size: 20px; line-height: 1; }
.modal-body { padding: 21px; }
.modal-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.modal-form .field-wide { grid-column: 1 / -1; }
.modal-actions { justify-content: flex-end; padding: 17px 21px; border-top: 1px solid var(--line); }
.month-list { display: grid; gap: 8px; }
.month-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; }
.conflict-box { padding: 13px; border-radius: 9px; color: #8f2027; background: #fff0f0; border: 1px solid #ffd1d4; line-height: 1.55; }

.memo-board { display: grid; gap: 16px; padding: 20px; }
.legacy-memo-notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; color: #704400; background: #fff8e8; border-color: #f2d49a; }
.memo-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.memo-tabs .active { color: #fff; background: var(--primary); border-color: var(--primary); }
.memo-add-form { display: grid; grid-template-columns: 110px minmax(180px, 1fr) auto; gap: 10px; }
.memo-add-form select, .memo-add-form input { min-height: 40px; }
.memo-count { text-align: right; font-size: 12px; }
.memo-list { display: grid; gap: 9px; }
.memo-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 9px; background: #fff; }
.memo-row.priority-high { border-left-color: #d94149; }
.memo-row.priority-medium { border-left-color: var(--primary); }
.memo-row.priority-low { border-left-color: #28a278; }
.memo-row.done .memo-text { color: var(--muted); text-decoration: line-through; }
.memo-text { overflow-wrap: anywhere; }
.pagination { display: inline-flex; align-items: center; gap: 8px; }

.toast-root { position: fixed; z-index: 40; right: 20px; bottom: 20px; display: grid; gap: 9px; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 12px 15px; color: #fff; border-radius: 9px; box-shadow: 0 9px 22px rgba(20,34,60,.18); background: #34435b; }
.toast.success { background: var(--success); }.toast.warning { background: var(--warning); }.toast.error { background: var(--danger); }

@media (max-width: 940px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { padding: 8px 12px; overflow: auto; }
  .main-nav { display: flex; width: max-content; }
  .nav-item { width: auto; white-space: nowrap; }
  .sidebar-note { display: none; }
  .main-area { padding: 18px; }
  .dashboard-panels { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { height: auto; min-height: 60px; align-items: flex-start; gap: 10px; padding: 12px; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .legacy-memo-notice { align-items: stretch; flex-direction: column; }
  .workspace { min-height: calc(100vh - 112px); }
  .context-bar, .view-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .modal-form { grid-template-columns: 1fr; }
  .modal-form .field-wide { grid-column: auto; }
  .auth-panel { padding: 26px; }
  .memo-add-form { grid-template-columns: 1fr; }
  .memo-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .memo-row .status-pill { display: none; }
}
