/* 库云策 · FBA 补货雷达 */

:root {
  color-scheme: light;
  --plane:        #f4f5f3;
  --surface:      #fcfcfb;
  --surface-2:    #f7f7f5;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --ink-3:        #898781;
  --line:         #e1e0d9;
  --line-2:       #c9c8c1;
  --brand-1:      #0f4fb5;
  --brand-2:      #1490d8;
  --brand-3:      #20d3b4;
  --series-1:     #2a78d6;
  --series-1-fill: rgba(42, 120, 214, 0.14);
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;
  --good-ink:     #006300;
  --warn-ink:     #8a5a00;
  --serious-ink:  #9a4419;
  --crit-ink:     #a32626;
  --shadow:       0 1px 2px rgba(11,11,11,.06), 0 8px 24px rgba(11,11,11,.05);
  --radius:       10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:      #0d0d0d;
    --surface:    #1a1a19;
    --surface-2:  #232322;
    --ink:        #ffffff;
    --ink-2:      #c3c2b7;
    --ink-3:      #898781;
    --line:       #2c2c2a;
    --line-2:     #383835;
    --series-1:   #3987e5;
    --series-1-fill: rgba(57, 135, 229, 0.18);
    --good-ink:   #0ca30c;
    --warn-ink:   #fab219;
    --serious-ink:#ec835a;
    --crit-ink:   #e06b6b;
    --shadow:     0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --plane:      #0d0d0d;
    --surface:    #1a1a19;
    --surface-2:  #232322;
    --ink:        #ffffff;
    --ink-2:      #c3c2b7;
    --ink-3:      #898781;
    --line:       #2c2c2a;
    --line-2:     #383835;
    --series-1:   #3987e5;
    --series-1-fill: rgba(57, 135, 229, 0.18);
    --good-ink:   #0ca30c;
    --warn-ink:   #fab219;
    --serious-ink:#ec835a;
    --crit-ink:   #e06b6b;
    --shadow:     0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--series-1); }

/* ---------- 登录 ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(20,144,216,.16), transparent 60%),
    radial-gradient(700px 420px at 95% 110%, rgba(32,211,180,.14), transparent 60%),
    var(--plane);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-card .brand img { width: 30px; height: 30px; }
.login-card .brand b { font-size: 17px; letter-spacing: .5px; }
.login-sub { color: var(--ink-3); font-size: 12.5px; margin: 0 0 22px; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; flex: none; }
.topbar .brand img { width: 24px; height: 24px; }
.topbar .brand b { font-size: 15px; }
.topbar .brand span { color: var(--ink-3); font-size: 12px; }

/* min-width:0 不能省：flex 子项默认不会收缩到内容宽度以下，
   窄屏时标签栏会把右上角的头像和退出按钮顶出去 */
nav.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: 0; background: none; cursor: pointer;
  padding: 7px 12px; border-radius: 7px;
  color: var(--ink-2); white-space: nowrap;
}
nav.tabs button:hover { background: var(--surface-2); color: var(--ink); }
nav.tabs button[aria-current="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

.who { position: relative; display: flex; align-items: center; flex: none; color: var(--ink-2); font-size: 13px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-3));
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600;
}

/* ---------- 布局 ---------- */

main { max-width: 1600px; margin: 0 auto; padding: 22px; }
.view > header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.view > header h1 { font-size: 19px; margin: 0; }
.view > header .note { color: var(--ink-3); font-size: 12.5px; }
.spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card > h2 {
  font-size: 14px; margin: 0; padding: 13px 16px;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.card > .body { padding: 16px; }
.cards { display: grid; gap: 16px; }
@media (min-width: 900px) { .cards.two { grid-template-columns: 1fr 1fr; } }

/* ---------- 状态统计 ---------- */

.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; cursor: pointer; text-align: left;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tile:hover { border-color: var(--line-2); }
.tile[aria-pressed="true"] { border-color: var(--series-1); box-shadow: 0 0 0 1px var(--series-1), var(--shadow); }
.tile .k { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12.5px; }
.tile .v { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.crit { background: var(--critical); }
.dot.warn { background: var(--warning); }
.dot.ok   { background: var(--good); }
.dot.over { background: var(--serious); }
.dot.mute { background: var(--ink-3); }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-3); font-weight: 500; font-size: 12.5px; position: sticky; top: 0; background: var(--surface); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
tbody tr.clickable { cursor: pointer; }
/* ---------- 产品图 ---------- */

th.pic, td.pic { width: 52px; padding-right: 4px; }
.pic-img {
  display: block; width: 36px; height: 36px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2);
}
.pic-none {
  display: block; width: 36px; height: 36px;
  border: 1px dashed var(--line-2); border-radius: 6px;
}
tbody tr:hover .pic-img { border-color: var(--line-2); }

.prod { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.prod-pic { flex: none; display: block; line-height: 0; }
.prod-pic img {
  width: 176px; height: 176px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
}
.prod-kv {
  flex: 1; min-width: 260px; margin: 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px 20px;
}
.prod-kv dt { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.prod-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* 亚马逊的标题动辄一百多个字，截断，鼠标停上去看全名 */
td.name-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--ink-3); }
.strong { font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.pill.crit { color: var(--crit-ink);    background: rgba(208,59,59,.12);  border-color: rgba(208,59,59,.3); }
.pill.warn { color: var(--warn-ink);    background: rgba(250,178,25,.16); border-color: rgba(250,178,25,.4); }
.pill.ok   { color: var(--good-ink);    background: rgba(12,163,12,.12);  border-color: rgba(12,163,12,.28); }
.pill.over { color: var(--serious-ink); background: rgba(236,131,90,.14); border-color: rgba(236,131,90,.34); }
.pill.mute { color: var(--ink-3);       background: var(--surface-2);     border-color: var(--line); }

.empty { padding: 44px 16px; text-align: center; color: var(--ink-3); }

/* 表格下面的口径说明。常驻，不用把鼠标停到表头上才看得到 */
.table-note {
  margin: 0; padding: 11px 16px; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 12.5px; line-height: 1.7;
}
.table-note b { color: var(--ink-2); font-weight: 600; margin-left: 14px; }
.table-note b:first-child { margin-left: 0; }

/* 表格上面那段填写说明 */
.field-help { border-bottom: 1px solid var(--line); }
.field-help p { margin: 0 0 8px; color: var(--ink-2); font-size: 13px; max-width: 78ch; }
.field-help p:last-child { margin-bottom: 0; }
.field-help b { color: var(--ink); }

/* ---------- 控件 ---------- */

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 7px 9px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--series-1); box-shadow: 0 0 0 3px rgba(42,120,214,.15); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 40px; }
.password-toggle { position: absolute; top: 50%; right: 7px; width: 28px; height: 28px; transform: translateY(-50%); display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--ink-3); cursor: pointer; }
.password-toggle:hover { background: var(--surface-2); color: var(--ink); }
.password-toggle:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.eye-icon { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.eye-closed { display: none; }
.password-toggle.is-visible .eye-open { display: none; }
.password-toggle.is-visible .eye-closed { display: block; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
/* 导入那一排字段会随类型增减，不让单个字段拉成整行宽 */
#view-import .row > label.field { max-width: 320px; }

.btn {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  border: 0; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2) 60%, var(--brand-3));
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--crit-ink); border-color: rgba(208,59,59,.4); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.err { color: var(--crit-ink); font-size: 12.5px; min-height: 18px; margin: 8px 0 0; }
.hint { color: var(--ink-3); font-size: 12.5px; }

/* 拖放上传 */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--radius);
  padding: 28px 16px; text-align: center; color: var(--ink-2); cursor: pointer;
  background: var(--surface-2);
}
.drop:hover, .drop.over { border-color: var(--series-1); color: var(--ink); }
.drop b { display: block; margin-bottom: 4px; }

/* ---------- 生产货期 ---------- */

.lead-grid { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1000px) { .lead-grid { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); } }

.lead-list { max-height: 560px; overflow-y: auto; }
.lead-item {
  display: flex; align-items: center; gap: 11px; width: 100%; cursor: pointer;
  padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: inherit; text-align: left;
}
.lead-item:last-child { border-bottom: 0; }
.lead-item:hover { background: var(--surface-2); }
.lead-item.on { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--series-1); }
.lead-item img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: none;
  border: 1px solid var(--line); }
.lead-item > div { min-width: 0; }
.lead-item b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-item span { display: block; color: var(--ink-3); font-size: 12.5px; }

.lead-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.lead-head img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line); }
.lead-head b { display: block; font-size: 16px; }
#leadEditor h3.sub { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }

.tier-rows { display: grid; gap: 9px; }
.tier-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tier-row span { color: var(--ink-3); font-size: 13px; }
.tier-row .arrow { margin-left: 10px; }
.tier-row input { width: 104px; }

.lead-preview {
  margin-top: 18px; padding: 14px 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
}
.lead-preview p { margin: 0 0 6px; color: var(--ink-2); font-size: 13px; }
.lead-preview p:last-child { margin-bottom: 0; }
.lead-preview p.big { font-size: 16px; font-weight: 600; color: var(--ink); }

.apply-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.apply-item { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.apply-item input { width: auto; }
.apply-item img { width: 24px; height: 24px; border-radius: 5px; object-fit: cover; flex: none; }
.apply-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 采购订单的分段统计 ---------- */

.band-stats { display: grid; gap: 14px; }
.band { padding: 12px 13px; border: 1px solid var(--line); border-radius: 9px; }
.band-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.band-head b { font-size: 13.5px; }
.band-head em { font-style: normal; color: var(--ink-3); font-size: 12px; }
.band-nums { display: grid; gap: 7px; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
.band-nums span { display: block; color: var(--ink-3); font-size: 11.5px; }
.band-nums i {
  display: block; margin-top: 2px; font-style: normal; font-weight: 600; font-size: 15px;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
/* 该照着备货的那个数，单独标出来 */
.band-nums .safe { color: var(--warn-ink); }
.band-nums .safe i { color: var(--warn-ink); }

/* ---------- 头程物流 ---------- */

.ship-grid { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1100px) { .ship-grid { grid-template-columns: minmax(0, 480px) minmax(0, 1fr); } }
.ship-side { display: grid; gap: 16px; }

.ship-form h3.sub { margin: 20px 0 10px; font-size: 13px; color: var(--ink-2); }
.ship-form .dates-hint { margin: 16px 0 8px; }
/* 日期框窄了会把 年/月/日 挤掉，固定两列，每格留够宽度 */
.ship-form .row.dates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ship-form .field em { display: block; margin-top: 5px; font-style: normal; }

.sp-items { display: grid; gap: 8px; }
.sp-item { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto; gap: 8px; align-items: center; }
.sp-item select { min-width: 0; }

.leg-stats { display: grid; gap: 11px; }
.leg-stats > div { display: flex; align-items: baseline; gap: 10px; }
.leg-stats span { flex: 1; color: var(--ink-2); font-size: 13px; }
.leg-stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.leg-stats em { font-style: normal; color: var(--ink-3); font-size: 12px; width: 52px; text-align: right; }

.sp-card { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.sp-card:last-child { border-bottom: 0; }
.sp-card.done { opacity: .62; }
.sp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-code { font-size: 15px; letter-spacing: .3px; }
.sp-total { font-weight: 600; font-variant-numeric: tabular-nums; }

/* 四个节点排成一条线，填过的点亮 */
.sp-steps { display: flex; gap: 0; margin: 14px 0 12px; flex-wrap: wrap; }
.sp-step { display: flex; align-items: center; gap: 7px; padding-right: 26px; position: relative; }
.sp-step::after {
  content: ''; position: absolute; right: 9px; top: 50%; width: 12px; height: 1px;
  background: var(--line-2);
}
.sp-step:last-child { padding-right: 0; }
.sp-step:last-child::after { display: none; }
.sp-step i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none; }
.sp-step.on i { background: var(--series-1); }
.sp-step b { font-weight: 500; color: var(--ink-3); font-size: 13px; }
.sp-step span { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sp-step.on b { color: var(--ink); font-weight: 600; }
.sp-step.on span { color: var(--ink-2); }

.sp-goods { display: flex; gap: 8px; flex-wrap: wrap; }
.sp-good {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); font-size: 12.5px;
}
.sp-good img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.sp-good b { font-weight: 500; }
.sp-good em { font-style: normal; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sp-foot { margin-top: 11px; color: var(--ink-3); font-size: 12.5px; }

/* ---------- 抽屉 ---------- */

.drawer-scrim {
  position: fixed; inset: 0; background: rgba(11,11,11,.35); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; inset: 0; width: 100%;
  background: var(--surface); z-index: 51;
  transform: translateX(100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer > header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.drawer > header h2 { font-size: 17px; margin: 0; }
.drawer > header .inner { display: flex; align-items: center; gap: 12px; width: 100%;
  max-width: 1180px; margin: 0 auto; }
.drawer > .body { padding: 22px; overflow-y: auto; flex: 1; }
/* 图放开了能占满整屏，但正文不能跟着拉到两米宽，字距会散 */
.drawer > .body > .inner { max-width: 1180px; margin: 0 auto; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kv > div > span { display: block; color: var(--ink-3); font-size: 12.5px; }
.kv > div > b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 图表 ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-2); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .lbl  { fill: var(--ink-2); font-size: 12.5px; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1-fill); }
.chart .bar  { fill: var(--series-1); }
.chart .mark-crit { stroke: var(--critical); stroke-width: 2; stroke-dasharray: 4 3; }
.chart .mark-warn { stroke: var(--warning);  stroke-width: 2; stroke-dasharray: 4 3; }
.chart .mark-serious { stroke: var(--serious); stroke-width: 2; stroke-dasharray: 4 3; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .hot { fill: transparent; }

.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px;
  box-shadow: var(--shadow); padding: 7px 10px; font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, -110%);
}
.tip .t { color: var(--ink-3); font-size: 11.5px; }
.tip .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* ---------- 提示条 ---------- */

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--plane); padding: 9px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: all .18s; z-index: 90; font-size: 13px;
}
#toast.show { opacity: 1; transform: translateX(-50%); }


/* ---------- 品牌按钮：点它回首页 ---------- */

.topbar .brand-home {
  border: 0; background: none; cursor: pointer; color: inherit;
  padding: 5px 9px 5px 5px; margin-left: -5px; border-radius: 8px;
}
.topbar .brand-home:hover { background: var(--surface-2); }
.topbar .brand-home:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }

/* ---------- 顶栏的「设置」 ---------- */

.setwrap { position: relative; flex: none; }
.setbtn {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  border: 0; background: none; color: var(--ink-2);
  padding: 7px 10px; border-radius: 7px; white-space: nowrap;
}
.setbtn:hover { background: var(--surface-2); color: var(--ink); }
.setbtn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
.setbtn[aria-current="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.setbtn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.setbtn .caret { width: 9px; height: 6px; flex: none; color: var(--ink-3); }
.setbtn[aria-expanded="true"] .caret { transform: rotate(180deg); }

.set-menu {
  position: absolute; top: calc(100% + 9px); right: 0; z-index: 40; width: 186px;
  padding: 7px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.set-hint {
  margin: 2px 8px 8px; font-size: 11.5px; line-height: 1.45; color: var(--ink-3);
}
.set-group { margin: 10px 8px 4px; font-size: 11.5px; color: var(--ink-3); }
.set-row { display: flex; align-items: center; gap: 2px; }
.set-go {
  flex: 1; min-width: 0; text-align: left; cursor: pointer;
  border: 0; background: none; color: var(--ink-2);
  padding: 7px 8px; border-radius: 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-go:hover { background: var(--surface-2); color: var(--ink); }
.set-go[aria-current="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* 钉子。钉住了是品牌色立着，没钉住是淡灰躺着 */
.set-pin {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 7px; cursor: pointer;
  color: var(--ink-3); opacity: .5;
}
.set-pin svg { width: 13px; height: 13px; transform: rotate(38deg); transition: transform .12s; }
.set-pin:hover { background: var(--surface-2); opacity: 1; }
.set-pin[aria-pressed="true"] { color: var(--series-1); opacity: 1; }
.set-pin[aria-pressed="true"] svg { transform: none; }
.set-pin:focus-visible { outline: 2px solid var(--series-1); outline-offset: -1px; }

.set-reset {
  display: block; width: 100%; margin-top: 8px; cursor: pointer;
  border: 0; border-top: 1px solid var(--line); background: none;
  color: var(--ink-3); font-size: 12.5px; padding: 9px 8px 4px; text-align: left;
}
.set-reset:hover { color: var(--ink); }

/* 拖动中的标签 */
nav.tabs button { user-select: none; }
nav.tabs button.dragging { opacity: .4; }

/* ---------- 右上角用户菜单 ---------- */

.who-btn {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--ink-2);
  padding: 4px 9px 4px 5px; border-radius: 999px;
}
.who-btn:hover { background: var(--surface-2); border-color: var(--line); }
.who-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--line-2); }
.who-btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.who-btn .caret { width: 9px; height: 6px; flex: none; color: var(--ink-3); }
.who-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }

.user-menu {
  position: absolute; top: calc(100% + 9px); right: 0; z-index: 40; width: 246px;
  padding: 15px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.um-head { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar.lg { width: 38px; height: 38px; font-size: 15px; }
.um-id { min-width: 0; }
.um-id b { display: block; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.um-id span { display: block; font-size: 12px; color: var(--ink-3); }
.um-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0;
  padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.um-meta span { display: block; font-size: 11.5px; color: var(--ink-3); }
.um-meta b { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.um-acts { display: grid; gap: 7px; }

/* 主题三选一 */
.um-theme { margin-bottom: 14px; }
.um-theme > span { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 6px; }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1; border: 0; background: none; color: var(--ink-2); cursor: pointer;
  padding: 6px 4px; font-size: 12px; white-space: nowrap;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button[aria-pressed="true"] {
  background: var(--surface-2); color: var(--ink); font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--series-1);
}
.seg button:focus-visible { outline: 2px solid var(--series-1); outline-offset: -2px; }

/* ---------- 首页 ---------- */

.hero { display: grid; grid-template-columns: 1fr; overflow: hidden; margin-bottom: 16px; }
@media (min-width: 880px) { .hero { grid-template-columns: minmax(0, 1fr) 268px; } }
.hero-main { padding: 16px; min-width: 0; }
.hero-side { padding: 16px; background: var(--surface-2); border-top: 1px solid var(--line); }
@media (min-width: 880px) { .hero-side { border-top: 0; border-left: 1px solid var(--line); } }
.hero-eyebrow { margin: 0 0 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }

.todo-list { display: grid; gap: 8px; }
.todo {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px;
}
.todo .t { flex: 1; min-width: 180px; }
.todo .t b { display: block; font-weight: 600; }
.todo .t span { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.todo .btn { margin-left: auto; }
.todo.crit { border-color: rgba(208,59,59,.32); background: rgba(208,59,59,.05); }
.todo.warn { border-color: rgba(250,178,25,.42); background: rgba(250,178,25,.06); }
.todo.over { border-color: rgba(236,131,90,.34); background: rgba(236,131,90,.05); }
.todo.ok   { border-color: rgba(12,163,12,.28);  background: rgba(12,163,12,.05); }

.quick {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line);
}

.fresh { display: grid; gap: 13px; }
.fresh > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.fresh .k { color: var(--ink-3); font-size: 12.5px; }
.fresh .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.fresh .v i { display: block; font-style: normal; font-weight: 400; font-size: 11.5px; color: var(--ink-3); }
.fresh .v i.late { color: var(--warn-ink); }

.home-lists .card > .body { padding: 6px 16px 10px; }
.feed { display: grid; }
.feed > div { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed > div:last-child { border-bottom: 0; }
.feed time { flex: none; width: 78px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed .w { flex: none; color: var(--ink-2); }
.feed .d { flex: 1; min-width: 0; color: var(--ink-3); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 登录页的切换提示 ---------- */

.login-note {
  margin: -12px 0 18px; padding: 8px 10px; font-size: 12.5px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px;
}

/* ---------- 小屏 ---------- */

@media (max-width: 640px) {
  main { padding: 14px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .brand span, .topbar .brand b { display: none; }   /* 只留图标，把宽度让给标签栏 */
  .who .name { display: none; }
  .user-menu { position: fixed; top: 62px; right: 12px; left: auto; width: min(246px, calc(100vw - 24px)); }
  .set-menu { position: fixed; top: 62px; right: 12px; left: auto; width: min(186px, calc(100vw - 24px)); }
}

/* ---------- 每日填数 ---------- */

/* 两个日期挨着放，说明跟在后面，别各占一整行 */
.daily-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.daily-head label.field { flex: none; width: 170px; margin-bottom: 0; }
.daily-head .hint { flex: 1; min-width: 260px; margin: 0; line-height: 1.7; }
#dailyTable input { text-align: right; }
#dailyTable input::placeholder { color: var(--ink-3); opacity: .6; }
/* 只标这一次改过的格子。带出来的旧数不标，不然一屏全是蓝框，等于没标 */
#dailyTable input.on { border-color: var(--series-1); font-weight: 600; }

/* ---------- 搜索 ---------- */

.findbtn {
  display: flex; align-items: center; gap: 7px; flex: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3);
  padding: 5px 10px; border-radius: 999px;
}
.findbtn:hover { border-color: var(--line-2); color: var(--ink-2); }
.findbtn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.findbtn svg { width: 14px; height: 14px; flex: none; }
.findbtn span { font-size: 12.5px; }
.findbtn kbd {
  font: inherit; font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; background: var(--surface);
}

.find-scrim { position: fixed; inset: 0; background: rgba(11,11,11,.35); z-index: 60; }
.find {
  position: fixed; z-index: 61; top: 11vh; left: 50%; transform: translateX(-50%);
  width: min(660px, calc(100vw - 28px)); max-height: 74vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 14px; box-shadow: var(--shadow);
}
.find-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-bottom: 1px solid var(--line);
}
.find-bar svg { width: 17px; height: 17px; flex: none; color: var(--ink-3); }
.find-bar input { flex: 1; min-width: 0; border: 0; background: none; padding: 0; font-size: 15px; }
.find-bar input:focus { box-shadow: none; }

.find-list { overflow-y: auto; padding: 6px; }
.find-group { margin: 10px 9px 3px; font-size: 11.5px; color: var(--ink-3); }
.find-row {
  display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer;
  border: 0; background: none; color: inherit; text-align: left;
  padding: 8px 9px; border-radius: 8px;
}
.find-row:hover { background: var(--surface-2); }
.find-row[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--series-1); }
.find-row img, .find-row .pic-none {
  width: 30px; height: 30px; border-radius: 6px; flex: none;
  object-fit: cover; border: 1px solid var(--line);
}
.find-t { flex: 1; min-width: 0; }
.find-t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find-t > span {
  display: block; color: var(--ink-3); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.find-row mark { background: rgba(250,178,25,.34); color: inherit; border-radius: 3px; padding: 0 1px; }
.find-row .pill { flex: none; }
.find .empty { padding: 34px 16px; }
.find-foot {
  display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px;
  border-top: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-3); font-size: 12px;
}

/* 搜索跳过去之后，把那一条点亮一下再褪掉，省得人在一屏里找自己刚点的是哪条 */
@keyframes flash-fade { from { background: rgba(42,120,214,.22); } to { background: transparent; } }
.flash { animation: flash-fade 2.2s ease-out; }

@media (max-width: 640px) {
  .findbtn span, .findbtn kbd { display: none; }   /* 窄屏只留放大镜 */
  .find { top: 7vh; width: calc(100vw - 20px); max-height: 82vh; }
}
