:root {
  color-scheme: light;
  --ink: #24252b;
  --muted: #777984;
  --line: #e9e4dc;
  --paper: #fffdf9;
  --panel: #f5f2ec;
  --brand: #ef5b45;
  --brand-dark: #c33b2d;
  --green: #23875d;
  --blue: #4f6fc5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--panel); font-size: 16px; line-height: 1.5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(79,111,197,.35); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding-bottom: 64px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 40px 0 28px; }
.topbar h1, h2 { margin: 0; letter-spacing: -.02em; }
.topbar h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.05; }
h2 { font-size: 21px; }
.subtitle, .muted, .field-help, .hint { color: var(--muted); }
.subtitle { margin: 9px 0 0; max-width: 650px; }
.eyebrow { margin: 0 0 6px; color: var(--brand-dark); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-chip { padding: 7px 12px; border-radius: 999px; color: #8b493e; background: #ffe8e2; font-size: 13px; white-space: nowrap; }
.button { min-height: 44px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button.primary { color: #fff; background: var(--brand); }
.button.primary:hover:not(:disabled) { background: var(--brand-dark); }
.button.secondary, .button.ghost { color: #555a66; border-color: #d9d3ca; background: var(--paper); }
.button.ghost { min-height: 38px; padding-block: 6px; }
.button.wide { width: 100%; }
.login-card { width: min(430px, 100%); margin: 56px auto 0; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 18px 50px rgba(77, 54, 38, .08); }
.login-card .muted { margin: 10px 0 22px; }
.stack-form, .field { display: grid; gap: 8px; }
.field label { font-weight: 700; }
input[type="password"], textarea { width: 100%; padding: 12px 13px; border: 1px solid #d8d2ca; border-radius: 10px; color: var(--ink); background: #fff; }
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
.password-wrap { display: flex; gap: 8px; }
.password-wrap input { flex: 1; }
.icon-button { min-width: 58px; border: 1px solid #d8d2ca; border-radius: 10px; color: #5c6069; background: #fff; }
.error { min-height: 23px; margin: 4px 0 0; color: #b0362a; font-size: 13px; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.metric { padding: 17px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 4px; font-size: 29px; line-height: 1.1; }
.metric small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.focus-metric { border-color: #efc2bb; background: #fff8f6; }
.layout-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr); gap: 14px; align-items: start; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 8px 28px rgba(77, 54, 38, .035); }
.panel + .panel { margin-top: 14px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.panel-heading .hint { padding-top: 4px; font-size: 12px; text-align: right; }
.field-help { margin: 0; font-size: 12px; }
.file-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 13px 0; }
.file-picker { display: inline-flex; min-height: 38px; align-items: center; padding: 7px 12px; border: 1px dashed #cfc5b7; border-radius: 9px; color: #665e57; background: #fffaf3; cursor: pointer; font-size: 13px; font-weight: 700; }
.file-picker:hover { border-color: var(--brand); color: var(--brand-dark); }
input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.file-name { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-actions, .result-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.account-list { max-height: 270px; margin-top: 18px; overflow: auto; border-top: 1px solid var(--line); }
.account-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0ece6; }
.account-row.priority { padding-inline: 9px; border-left: 3px solid var(--brand-dark); background: #fff3f0; }
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.account-meta { display: flex; flex: 0 0 auto; gap: 5px; align-items: center; }
.source-tag, .count-tag { padding: 2px 7px; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.priority-tag { padding: 2px 7px; border-radius: 999px; color: #a5281d; background: #ffe1dc; font-size: 11px; font-weight: 800; white-space: nowrap; }
.source-tag.extension { color: #3d5aaa; background: #e9eeff; }
.source-tag.manual { color: #8b5c11; background: #fff0c9; }
.source-tag.both { color: #218058; background: #e3f5ea; }
.count-tag { color: var(--muted); background: #f1eee9; }
.account-delete { min-height: 30px; padding: 3px 8px; border: 1px solid #e5c9c3; border-radius: 7px; color: #a33b2f; background: #fff; font-size: 11px; font-weight: 700; }
.account-delete:hover:not(:disabled) { border-color: #c43b2d; color: #fff; background: #c43b2d; }
.account-delete:disabled { cursor: wait; opacity: .55; }
.account-rule { margin: -7px 0 14px; }
.results-panel, .history-panel { margin-top: 14px; }
.results-heading { align-items: end; }
.results-heading .muted { margin: 5px 0 0; font-size: 13px; }
.empty-state { padding: 38px 22px; border: 1px dashed #d4cdc3; border-radius: 12px; color: var(--muted); text-align: center; background: #fffaf4; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 9px; border-bottom: 1px solid #eee9e2; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
td:first-child { min-width: 230px; font-weight: 700; }
.match-account { display: flex; flex-wrap: wrap; gap: 5px; }
.match-account span { padding: 3px 7px; border-radius: 999px; color: #9d392b; background: #ffede8; font-size: 12px; }
.row-note { min-width: 150px; min-height: 37px; padding: 7px 9px; border: 1px solid #ddd7cf; border-radius: 8px; resize: vertical; }
.adopted-cell { white-space: nowrap; }
.adopted-cell input { width: 20px; height: 20px; accent-color: var(--green); vertical-align: middle; }
.duplicate-badge { padding: 3px 8px; border-radius: 999px; color: #916016; background: #fff1d1; font-size: 12px; white-space: nowrap; }
.history-list { display: grid; gap: 8px; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid #eee9e2; border-radius: 10px; background: #fff; }
.history-row button { flex: 1; border: 0; color: var(--ink); background: transparent; text-align: left; }
.history-row button:hover { color: var(--brand-dark); }
.history-count { color: var(--brand-dark); font-weight: 800; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(400px, calc(100% - 48px)); padding: 10px 16px; border-radius: 999px; color: #fff; background: rgba(35,36,42,.92); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 850px) {
  .layout-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1240px); }
  .topbar { padding-top: 24px; }
  .topbar h1 { font-size: 34px; }
  .topbar, .results-heading { flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
  .panel, .login-card { padding: 18px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 24px; }
}
