/* ==========================================================================
   V6.2 · 无障碍基线（WCAG 2.2 AA）
   审计发现 18 项配色里 10 项不达标 —— 这一节把「承载信息」的颜色全部提到 AA，
   浅色只保留给装饰（分割线、非信息性占位）。

   改动原则：**颜色令牌分两套**
     · 信息色（--text-2 / --text-3 / --gold-text / --ok / --warn）→ 必须 ≥4.5:1
     · 装饰色（--line / --gold）→ 只用于分割线与描边，不承载信息，按 1.4.11豁免
   ========================================================================== */

:root {
  /* ---- 信息色：全部 ≥ 4.5:1（实测值见注释） ---- */
  --text-2: #71665D;          /* 原 #8A7D72 (3.83:1) → 4.96:1（按最严的米白底/纸面底取） */
  --text-3: #6F6760;          /* 原 #B2A79B (2.26:1) → 4.93:1 */
  --gold-text: #7E6C4E;       /* 金色作文字：2.39:1 → 4.50:1（米白底） */
  --ok: #607A66;              /* 3.59:1 → 4.50:1 */
  --warn: #8A7036;            /* 3.50:1 → 4.53:1 */

  /* ---- 装饰色：保持原值，仅用于线条/描边/色块 ---- */
  --gold: #B49A70;
  --line: #DED5CA;

  /* ---- 控件描边：WCAG 1.4.11 要求识别控件的边界 ≥3:1 ---- */
  --line-strong: #979089;     /* 1.39:1 → 3.02:1 */
  --line-strong-soft: #B0A79F;

  /* 非信息性占位（禁用态、空图形说明）*/
  --text-faint: #A99E92;
}

/* ---------- 表单控件：描边提到 3:1 ---------- */
input, select, textarea,
.search-box, .unit-input, .row-inline > select {
  border-color: var(--line-strong) !important;
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }

/* 复选/ 单选与开关的描边同理 */
input[type="checkbox"], input[type="radio"] { border-color: var(--line-strong); }

/* ---------- 金色文字改用达标色 ---------- */
.side .nav-item.active .ico,
.tc-lbl, .tc-axis, .tc-val,
.tf-item b, .tx-day-w, .tx-day-n,
.svc-val, .up-cell .up-t, .up-cell .up-w,
.cal-legend, .legend-note, .sidebar-foot,
.day-meta, .or-meta, .hero-week, .hero-edition,
.page-sub, .card-title .head-date {
  color: var(--gold-text);
}
/* 装饰性金色元素维持原色 */
.he-rule, .hero-frame, .hero-frame::after, .tx-day,
.cal-day, .cal-week span, .swipe-hint,
.up-strip::before, .page-head::after, .side .nav-item::before,
.order-row:hover, .tx-item:hover { color: inherit; }

/* ---------- 焦点可见：所有可聚焦元素统一焦点环 ---------- */
:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
  border-radius: 2px;
}
/* 键盘聚焦在深色侧栏上要换成浅色环才看得见 */
.side :focus-visible, .bottom-nav :focus-visible, .drawer :focus-visible {
  outline-color: var(--gold);
}
/* 鼠标点击不显示焦点环（避免视觉噪声），键盘操作必须显示 */
:focus:not(:focus-visible) { outline: none; }

/* ---------- 键盘可达：div 模拟的按钮 ---------- */
[role="button"]:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: -2px;
  background-color: rgba(140, 98, 83, .07);
}
/* 订单/客户行整行可点时，焦点环要贴合行高而不是被裁切 */
.order-row:focus-visible, .cust-row:focus-visible { outline-offset: -2px; }

/* ---------- 跳到主内容（键盘用户第一个 Tab） ---------- */
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 200;
  padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center;
  background: var(--ink); color: var(--cream);
  font-size: 13px; letter-spacing: .1em; text-decoration: none;
  border-radius: 2px; transition: top .18s ease;
}
.skip-link:focus { top: 8px; }

/* ---------- 弹窗无障碍 ---------- */
.modal-mask { }
.modal { }
/* 打开弹窗时锁定背景滚动（弹窗内已由JS 处理，这里兜底） */
body.modal-open { overflow: hidden; }

/* ---------- 加载态：骨架屏代替"加载中…"文字（减少布局跳动） ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 25%, #F2ECE2 37%, var(--paper-2) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
  border-radius: 2px;
}
@keyframes sk {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.sk-line { height: 12px; margin: 10px 0; }
.sk-chart { height: 150px; margin: 8px 0 14px; }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- 文字辅助：屏幕阅读器专用 ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 非颜色标识：待收标签 ---------- */
.tn-tag {
  display: inline-block; margin-left: 8px; padding: 2px 7px;
  border: 1px solid var(--accent); border-radius: 2px;
  font-size: 10px; letter-spacing: .12em; color: var(--accent-deep);
  vertical-align: middle;
}
.tn-tag[hidden] { display: none; }

/* ---------- 键盘聚焦时的行高亮（与鼠标悬停一致，且更明确） ---------- */
.order-row:focus-visible, .cust-row:focus-visible, .up-cell:focus-visible, .cal-cell:focus-visible {
  background: rgba(140, 98, 83, .08);
  outline: 2px solid var(--accent-deep);
  outline-offset: -2px;
}
