/* Ivan Platform Design — a shared operating system for every workspace module. */
:root {
  --ivan-canvas: #e0ddda;
  --ivan-surface: #f6f4ef;
  --ivan-surface-raised: #fffefa;
  --ivan-ink: #24251f;
  --ivan-ink-muted: #5d6057;
  --ivan-border: #c8c5be;
  --ivan-lemon: #f3eb30;
  --ivan-orange: #fb9350;
  --ivan-detail: #242322;
  --ivan-detail-ink: #f7f5ef;
  --ivan-focus: #2456a6;
  --ivan-shadow: 0 3px 12px rgb(36 37 31 / 5%);
  --bg: var(--ivan-canvas);
  --panel: var(--ivan-surface-raised);
  --panel-2: var(--ivan-surface);
  --panel-3: #ebe8e1;
  --border: var(--ivan-border);
  --border-strong: #a6a49c;
  --text: var(--ivan-ink);
  --text-2: var(--ivan-ink-muted);
  --text-3: #64675e;
  --primary: #5b5100;
  --primary-600: #4b4300;
  --primary-weak: #f8f4ae;
  --primary-border: #d8cf56;
  --warn: #8a420c;
  --warn-weak: #fff0df;
  --amber: #795317;
  --amber-weak: #fff1cf;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow-sm: var(--ivan-shadow);
  --shadow: 0 8px 24px rgb(36 37 31 / 9%);
  --sidebar-w: 72px;
  color-scheme: light;
}

html, body { background: var(--bg); color: var(--text); font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
::selection { background: var(--ivan-lemon); color: var(--text); }
input, textarea { caret-color: var(--ivan-ink); }
a { color: #645600; text-underline-offset: 3px; }
button, input, select, textarea { font-size: 14px; }
:is(button, a, summary, input, select, textarea, [tabindex]):focus-visible,
.plan-shell :focus-visible, .report-shell :focus-visible, .task-shell :focus-visible,
.news-dialog :focus-visible, .news-reading :focus-visible {
  outline: 2px solid var(--ivan-focus);
  outline-offset: 3px;
}
input::placeholder, textarea::placeholder { color: #66685f; }

/* Navigation: a narrow rail with discoverable, keyboard-accessible flyouts. */
.sidebar { background: #f2efe8; border-color: var(--border); z-index: 30; overflow: visible; }
.brand { height: 76px; padding: 17px 8px; display: grid; place-items: center; }
.brand-mark { justify-content: center; }
.brand-mark > span:last-child, .brand-sub { display: none; }
.brand-dot { width: 40px; height: 40px; border-radius: 12px; background: var(--ivan-detail); color: var(--ivan-lemon); font-size: 13px; }
.nav { padding: 14px 8px; overflow-x: visible; overflow-y: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav > .nav-item, .nav-module-head {
  justify-content: center; width: 52px; min-height: 50px; padding: 0;
  margin: 0 auto 8px; border-radius: 12px; color: var(--text-2);
}
.nav > .nav-item > span:not(.ico), .nav-module-head > span:not(.ico) { display: none; }
.nav > .nav-item .ico, .nav-module-head .ico { width: 22px; height: 22px; font-size: 20px; }
.nav > .nav-item .ico svg, .nav-module-head .ico svg { width: 21px; height: 21px; }
.nav-module { margin: 0; position: relative; }
.nav-module-head:hover, .nav > .nav-item:hover,
.nav-module:has(.nav-item.active) > .nav-module-head {
  background: var(--ivan-lemon); color: var(--text);
}
.nav > .nav-item.active { color: var(--text); font-weight: 700; }
.nav-indicator { border-radius: 12px; background: var(--ivan-lemon); box-shadow: none; transition-duration: 180ms; }
.nav-module-body {
  display: none !important; position: fixed; z-index: 35; left: 62px;
  top: max(72px, min(var(--flyout-top, 80px), calc(100dvh - 500px)));
  width: 252px; max-height: min(560px, calc(100dvh - 88px)); overflow-y: auto;
  margin: 0; padding: 12px; border: 1px solid var(--border);
  border-radius: 16px; background: var(--ivan-surface-raised);
  box-shadow: 0 18px 50px rgb(36 37 31 / 16%);
}
.nav-module:hover > .nav-module-body, .nav-module:focus-within > .nav-module-body { display: block !important; }
.nav-module-body::before {
  content: attr(data-title); display: block; font-size: 15px; font-weight: 700;
  padding: 5px 10px 10px; margin-bottom: 5px; border-bottom: 1px solid var(--border);
}
.nav-module-body .nav-item {
  display: block; width: 100%; min-height: 38px; margin: 1px 0;
  padding: 8px 10px; border-radius: 9px; font-size: 13px; color: var(--text-2);
}
.nav-module-body .nav-item:hover { background: var(--panel-3); }
.nav-module-body .nav-item.active { background: var(--ivan-lemon); color: var(--text); }
.nav-module-body .nav-item:disabled { opacity: .5; }
.side-foot { padding: 10px 8px 14px; }
.side-foot-grid { display: grid; grid-template-columns: 1fr; gap: 4px; }
.side-foot-btn { width: 52px; height: 42px; padding: 0; margin: auto; justify-content: center; border: 0; border-radius: 10px; }
.side-foot-btn > span:last-child, .side-status { display: none; }
.side-foot-btn > span:first-child { font-size: 20px; }

/* Shared page chrome. */
.global-toolbar { height: 68px; background: var(--ivan-canvas); border-bottom: 1px solid var(--border); padding: 0 28px; }
.global-toolbar-left { flex: 1; }
.global-toolbar-center { flex: 1.1; max-width: 420px; }
.global-search { height: 40px; background: var(--ivan-surface-raised); border-color: var(--border); border-radius: 11px; }
.global-search:focus-within { border-color: var(--ivan-focus); box-shadow: 0 0 0 3px rgb(36 86 166 / 15%); }
.global-search-kbd { background: var(--ivan-surface); }
.toolbar-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; }
.toolbar-btn:hover { background: var(--ivan-surface-raised); border-color: var(--border); }
.toolbar-avatar { background: var(--ivan-detail); color: var(--ivan-lemon); }
.toolbar-avatar:hover { background: #45433c; color: var(--ivan-lemon); }
.bc-main, .bc-sub { font-size: 13px; color: var(--text-2); }
.bc-sub { color: var(--text); font-weight: 650; }
.topbar { min-height: 100px; background: transparent; border: 0; padding: 25px 28px 15px; align-items: center; }
.topbar h1 { font-size: clamp(24px, 2vw, 28px); font-weight: 720; letter-spacing: -.035em; }
.topbar .sub { font-size: 13px; color: var(--text-2); }
.content { padding: 12px 28px 48px; max-width: 1920px; margin-inline: auto; }
.erp-mobile-toggle { border-radius: 10px; }

/* Reusable business surfaces. */
.card, .plan-shell, .report-shell, .task-shell, .report-panel, .report-import,
.follow-item, .erp-board-card, .line-card, .plan-form, .plan-detail,
.modal-card, .task-editor, .news-dialog {
  background: var(--ivan-surface-raised); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--ivan-shadow); color: var(--text);
}
.card-head { background: transparent; padding: 17px 20px; }
.card-head h3, .report-panel h3 { font-size: 16px; font-weight: 700; }
.card-body, .card-body.tight { padding: 18px 20px; }
.btn { min-height: 38px; padding: 7px 13px; border-radius: 10px; box-shadow: none; transition: background 160ms, border-color 160ms, transform 160ms; }
.btn-sm { min-height: 34px; }
.btn-primary, .plan-filter-active { background: var(--ivan-lemon) !important; border-color: #c5bd2c !important; color: var(--text) !important; font-weight: 700; }
.btn-primary:hover, .plan-filter-active:hover { background: #e4dc25 !important; border-color: #aaa21c !important; }
.btn-danger { color: #a42621; }
.input, .select, .textarea, .plan-form input, .plan-form select, .plan-form textarea,
.task-editor input, .task-editor select, .task-editor textarea {
  min-height: 38px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--ivan-surface-raised); color: var(--text); font-size: 14px;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--ivan-focus); outline-offset: 2px; box-shadow: none; border-color: var(--ivan-focus); }
.tab { min-height: 40px; font-size: 13px; }
.tab.active { color: var(--text); border-bottom-color: #746b00; }
.tab.active .n { background: var(--ivan-lemon); color: var(--text); }
.tag-primary, .task-controls [aria-pressed=true], .erp-view-switch button[aria-pressed=true], .erp-density[aria-pressed=true] {
  background: var(--ivan-lemon); color: var(--text); border-color: #c5bd2c;
}
.plan-button, .task-list button, .news-reading a { color: #645600; }
.plan-summary, .report-metrics, .task-summary { border-color: var(--border); }
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; border: 0; background: transparent; border-radius: 0; overflow: visible;
}
.kpis > .kpi {
  background: var(--ivan-surface-raised); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--ivan-shadow); padding: 17px 18px;
}
.report-metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  background: transparent; border: 0; border-radius: 0; overflow: visible;
}
.report-metric, .report-metric:last-child, .report-metric:nth-child(2) {
  min-width: 0; background: var(--ivan-surface-raised); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--ivan-shadow); padding: 18px;
}
.report-metric:first-child { background: var(--ivan-lemon); border-color: #d8cf56; }
.report-metric:nth-child(2) { background: var(--ivan-orange); border-color: #df8550; }
.report-metric { background: var(--ivan-surface-raised); }
.report-metric dd, .plan-summary strong, .task-summary strong { font-variant-numeric: tabular-nums; }
.report-filter-panel, .report-filters, .erp-list-tools, .report-table-wrap { background: var(--ivan-surface-raised); border-color: var(--border); }
.report-filters label, .report-metric dt, .report-metric small, .report-panel p,
.report-chart-legend, .report-page, .report-import p { color: var(--text-2); }
.report-filters input, .report-filters select, .plan-table input {
  background: var(--ivan-surface-raised); border-color: var(--border-strong);
  border-radius: 10px; color: var(--text);
}
.plan-shell input, .plan-shell textarea { caret-color: var(--text); }
.plan-shell ::selection { background: var(--ivan-lemon); color: var(--text); }
.plan-form, .plan-empty, .report-empty, .p-empty, .erp-board-column { background: var(--ivan-surface); }
.plan-detail summary { color: var(--text); }
.plan-tag.pending, .task-sync-note { background: #fff0dc; color: #70400d; }
.plan-tag { background: #e0eee3; color: #28563a; }
.task-day.today { background: #fbf7c6; }
.task-event { color: var(--text); border-color: var(--border); }
.task-event:hover, .erp-board-card:hover { border-color: #a99e00; background: #fbf9dd; }
.task-editor-head, .task-editor-foot, .modal-head, .modal-foot, .drawer-head,
.news-dialog-head, .news-dialog-footer { background: var(--ivan-surface); border-color: var(--border); }
.drawer, .task-editor { border-radius: 18px 0 0 18px; }
.modal-card, .news-dialog { border-radius: 18px; }
.command-dialog { background: var(--ivan-surface-raised); color: var(--text); border-color: var(--border); }
.command-heading, .command-caption, .command-footer { color: var(--text-2); }
.command-footer, .command-close { background: var(--ivan-surface); border-color: var(--border); }
.command-search { color: var(--text); border-color: var(--border); }
.command-option[aria-selected=true] { background: var(--ivan-lemon); color: var(--text); border-color: #c5bd2c; }
.command-option mark { background: var(--ivan-orange); color: var(--text); }
.command-dialog::backdrop, .news-dialog::backdrop { background: rgb(36 35 34 / 56%); }

/* Dense, legible tables throughout CRM, ERP, planning and reports. */
.table-wrap, .plan-scroll, .report-table-wrap { max-width: 100%; overflow-x: auto; border-radius: 12px; }
:is(.tbl, .plan-table, .task-list, .report-table) { font-size: 13px; font-variant-numeric: tabular-nums; }
:is(.tbl, .plan-table, .task-list, .report-table) th {
  padding: 12px 14px; background: var(--ivan-surface); color: var(--text-2);
  border-bottom: 1px solid var(--border); font-size: 12px;
}
:is(.tbl, .plan-table, .task-list, .report-table) td {
  min-height: 60px; padding: 14px; border-bottom: 1px solid #e4e1da;
  background: transparent; line-height: 1.5;
}
:is(.tbl, .plan-table, .task-list, .report-table) tbody tr:hover { background: #faf8e6; }
.erp-sort::after { color: var(--text-2); }
.erp-list-tools { padding: 10px 12px; border-radius: 10px; }
.erp-columns[open] > div { background: var(--ivan-surface-raised); border-radius: 12px; }
.erp-view-switch { border-radius: 10px; }
.erp-view-switch button { background: var(--ivan-surface-raised); }
.report-bar, .report-rank-track i, .report-chart-legend i { background: #b4a800; }
.report-bar.target, .report-chart-legend .target { background: #b5b1a7; }
.report-rank-track { background: #e8e4d8; }
.bar-fill, .home-progress-fill, .dp-trend-bar.actual { background: #a79c00; }
.dp-trend-bar.plan { background: #b9b4a5; opacity: 1; }
.home-progress-fill.warn { background: var(--ivan-orange); }

/* The home dashboard has different-sized, purposeful bento modules. */
#view-home .plan-shell.plan-compact { background: var(--ivan-surface); border-radius: 14px; padding: 14px 20px; margin-bottom: 18px; }
.home-header { margin-bottom: 18px; align-items: end; }
.home-header h2 { font-size: 20px; }
.home-date { color: var(--text-2); }
#view-home .kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 16px; border: 0; background: transparent;
  border-radius: 0; overflow: visible;
}
#view-home .kpi {
  min-width: 0; min-height: 146px; padding: 20px; border: 1px solid var(--border);
  border-radius: 18px; background: var(--ivan-surface-raised); box-shadow: var(--ivan-shadow);
  display: flex; flex-direction: column; justify-content: space-between;
}
#view-home .kpi:first-child { grid-column: span 2; background: var(--ivan-lemon); border-color: #d8cf56; }
#view-home .kpi:nth-child(2) { grid-column: span 2; background: var(--ivan-orange); border-color: #df8550; }
#view-home .kpi .label, #view-home .kpi-title { font-size: 13px; color: var(--text-2); }
#view-home .kpi .value, #view-home .kpi-v { font-size: clamp(26px, 2.5vw, 38px); line-height: 1.1; letter-spacing: -.04em; color: var(--text) !important; font-variant-numeric: tabular-nums; }
#view-home .kpi .foot, #view-home .kpi-sub { font-size: 12px; color: var(--text-2); }
#view-home .grid-3 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(240px, .8fr); gap: 16px; }
#view-home .grid-3 > .card:last-child { background: var(--ivan-detail); border-color: var(--ivan-detail); color: var(--ivan-detail-ink); }
#view-home .grid-3 > .card:last-child .card-head { border-color: #484741; }
#view-home .grid-3 > .card:last-child :is(.muted, .home-mini-item .sub) { color: #d2d0c7; }
#view-home .grid-3 > .card:last-child .card-body { color: var(--ivan-detail-ink); }
#view-home .grid-2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; }
#view-home .home-mini-item { background: var(--ivan-surface); border-color: var(--border); border-radius: 10px; min-height: 44px; }
#view-home .home-mini-item:hover { background: #f9f5cb; }
#view-home #homeSales .home-mini-item :is(.num, .label, .sub) { color: #252822; }
#view-home #homeSales .home-mini-item .label { font-weight: 600; }
#dpSales .bar-row :is(.k, .v), .report-rank-row { color: #252822; }
#dpSales .bar-row .v { font-weight: 600; }
#view-home .home-feed-item { border-color: var(--border); }
#view-home .dp-trend { min-height: 184px; height: auto; overflow-x: auto; }

/* Login uses the same language as the authenticated workspace. */
body:has(> .login) { background: var(--ivan-canvas) !important; color: var(--text) !important; align-content: center; }
body:has(> .login) .login { background: var(--ivan-surface-raised); border-color: var(--border); border-radius: 20px; box-shadow: var(--shadow); }
body:has(> .login) .brand { display: block; height: auto; padding: 0; color: var(--text); font-weight: 700; }
body:has(> .login) .login h1 { color: var(--text); }
body:has(> .login) .login p { color: var(--text-2); }
body:has(> .login) .login input { border-radius: 10px; border-color: var(--border-strong); }

@media (max-width: 1200px) {
  :root { --sidebar-w: 208px; }
  .brand { display: block; height: 68px; padding: 12px; }
  .brand-mark { justify-content: flex-start; }
  .brand-mark > span:last-child, .brand-sub { display: inline; }
  .brand-dot { width: 32px; height: 32px; font-size: 11px; }
  .nav { padding: 10px 8px; overflow-y: auto; }
  .nav > .nav-item, .nav-module-head { width: 100%; min-height: 40px; justify-content: flex-start; padding: 8px 10px; margin: 2px 0; }
  .nav > .nav-item > span:not(.ico), .nav-module-head > span:not(.ico) { display: inline; }
  .nav-module-body, .nav-module:hover > .nav-module-body, .nav-module:focus-within > .nav-module-body { display: none !important; }
  .nav-module.expanded > .nav-module-body { display: block !important; position: static; width: auto; max-height: none; padding: 2px 0 6px 16px; margin: 0 0 0 12px; border: 0; border-left: 1px solid var(--border); border-radius: 0; box-shadow: none; background: transparent; }
  .nav-module-body::before { display: none; }
  .side-foot { padding: 10px; }
  .side-foot-grid { grid-template-columns: 1fr 1fr; }
  .side-foot-btn { width: auto; padding: 0 7px; justify-content: flex-start; }
  .side-foot-btn > span:last-child { display: inline; }
  #view-home .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #view-home .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-home .grid-3 > .card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .global-toolbar-left { display: none; }
  .global-toolbar-center { max-width: none; }
  .global-toolbar-right { flex: 0 0 auto; }
  #view-home .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-home .kpi:first-child, #view-home .kpi:nth-child(2) { grid-column: span 1; }
  .report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .content { padding: 12px 16px 36px; }
  .topbar { padding: 18px 16px 10px; }
  .global-toolbar { padding: 0 16px; }
  #view-home .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-home .kpi:first-child, #view-home .kpi:nth-child(2) { grid-column: span 1; }
  #view-home .grid-2, #view-home .grid-3 { grid-template-columns: 1fr; }
  #view-home .grid-3 > .card:last-child { grid-column: auto; }
}
@media (max-width: 760px) {
  :root { --sidebar-w: 260px; }
  .sidebar { z-index: 55; }
  .nav-module.expanded > .nav-module-body { display: block !important; }
  .side-foot-grid { grid-template-columns: 1fr 1fr; }
  .topbar h1 { font-size: 23px; }
  .card-body, .card-body.tight { padding: 16px; }
  .plan-shell, .report-shell, .task-shell { padding: 16px; }
}
@media (max-width: 480px) {
  #view-home .kpis { grid-template-columns: 1fr 1fr; }
  #view-home .kpi { min-height: 124px; padding: 14px; }
  #view-home .kpi .value, #view-home .kpi-v { font-size: 25px; }
  .home-header { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-indicator, .btn { transition: none; }
}

/* Readable synchronization status on every business page. */
.data-freshness{margin-bottom:18px;padding:15px 18px;background:#f9faf7;border:1px solid #d9ddd2;border-radius:16px;color:#252822}
.data-freshness-heading{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap;margin-bottom:12px}
.data-freshness-heading>span,.data-freshness-note{font-size:12px;color:#596151}
.data-freshness-sources{display:flex;flex-wrap:wrap;gap:14px 30px}
.data-freshness-source{display:flex;gap:8px;align-items:flex-start;min-width:210px}
.data-freshness-source strong{font-size:13px;margin-right:10px}
.data-freshness-source span{font-size:12px}
.data-freshness-source small{display:block;color:#596151;font-size:11px;margin-top:4px}
.data-sync-dot{width:7px;height:7px;border-radius:50%;background:#87917a;margin-top:6px;flex:none}
.data-freshness-source[data-state="running"] .data-sync-dot{background:#b77a13}
.data-freshness-source[data-state="failed"] .data-sync-dot,.data-freshness-source[data-state="not_configured"] .data-sync-dot{background:#ba4439}
.data-freshness-note{margin:10px 0 0;line-height:1.5}

/* Monthly sales comparison: full row, readable values without hovering. */
#view-home .home-performance-grid { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); }
#view-home .home-monthly-card { grid-column: 1 / -1; min-width: 0; }
.monthly-legend { display:flex; flex-wrap:wrap; gap:20px; align-items:center; margin-bottom:14px; font-size:12px; color:var(--text-2); }
.monthly-legend span { display:flex; align-items:center; gap:7px; }
.monthly-legend i { width:10px; height:10px; border-radius:2px; }
.monthly-legend .plan { background:#b6b3a3; }
.monthly-legend .actual { background:#a79c00; }
.monthly-scroll { overflow-x:auto; padding-bottom:8px; }
.monthly-chart { display:grid; grid-template-columns:repeat(12,minmax(118px,1fr)); gap:12px; min-width:0; }
.monthly-column { min-width:0; text-align:center; }
.monthly-column .dp-trend-bars { height:170px; justify-content:center; gap:7px; border-bottom:1px solid var(--border); }
.monthly-column .dp-trend-bar { width:18px; max-width:30%; }
.monthly-column .dp-trend-bar.plan { background:#b6b3a3; opacity:1; }
.monthly-month { display:block; margin:10px 0; font-size:13px; }
.monthly-value { display:flex; flex-direction:column; gap:3px; margin-top:8px; font-size:11px; color:var(--text-2); }
.monthly-value b { color:#34342e; font-size:12px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.monthly-value.actual b { color:#625c00; }
@media(max-width:760px){ #view-home .home-performance-grid { grid-template-columns:minmax(0,1fr); } }

.nav-item.module-unavailable{opacity:.5;cursor:not-allowed}.nav-item.module-unavailable::after{content:"暂未开放";font-size:10px;margin-left:auto;white-space:nowrap}
