:root {
  --navy: #1f3a5f;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e3e7ee;
  --bg: #f4f6f9;
  --red: #c0392b;
  --red-bg: #fdf4f3;
  --amber: #b7791f;
  --amber-bg: #fdf9ef;
  --green: #1e8449;
  --green-bg: #f4faf6;
  --blue: #2b6cb0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 22px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { color: #fff; font-weight: 700; font-size: 15px; display: flex; gap: 9px; align-items: center; letter-spacing: .3px; }
.brand:hover { text-decoration: none; }
.logo { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center;
        background: rgba(255,255,255,.16); border-radius: 6px; font-size: 13px; }
.topbar nav a { color: rgba(255,255,255,.78); margin-left: 22px; font-size: 13.5px; padding: 6px 2px; }
.topbar nav a.on, .topbar nav a:hover { color: #fff; text-decoration: none; border-bottom: 2px solid #fff; }

main.wrap { padding-top: 26px; padding-bottom: 40px; min-height: calc(100vh - 120px); }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; padding: 14px 0 22px; }

/* ---------- common ---------- */
h1, h2, h3 { color: #16233a; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card h2 { font-size: 15px; margin: 0 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; align-items: start; }
@media (max-width: 880px) { .grid2 { grid-template-columns: 1fr; } }
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 18px; border-radius: 8px; font-size: 13.5px; cursor: pointer; line-height: 1.2;
  font-family: inherit; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: #c9d2de; background: #fafbfd; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: #16294a; }
.btn.ghost { background: #fff; }
.btn.danger-ghost { color: var(--red); border-color: #efd5d1; background: #fff; }
.btn:disabled { opacity: .6; cursor: default; }
.link { color: var(--blue); font-size: 13px; }
.muted { color: var(--muted); font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.center { text-align: center; }
.flash { background: #fff8e6; border: 1px solid #f2dfae; color: #7a5b12; padding: 10px 14px;
         border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

/* ---------- index ---------- */
.hero { margin: 8px 0 22px; }
.hero h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: .2px; }
.hero p { color: var(--muted); margin: 0; max-width: 780px; font-size: 13.5px; }
.upload label { display: block; font-size: 13px; color: #374151; margin: 12px 0 0; }
.upload input[type=text] {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13.5px; font-family: inherit; outline: none;
}
.upload input[type=text]:focus { border-color: #93b4d8; box-shadow: 0 0 0 3px rgba(43,108,176,.08); }
.drop {
  margin-top: 8px; border: 1.5px dashed #c3cedd; border-radius: 12px; background: #fafcff;
  padding: 26px 16px; text-align: center; cursor: pointer; transition: .15s;
}
.drop.over, .drop:hover { border-color: #7fa6cf; background: #f3f8ff; }
.drop-icon { font-size: 26px; color: #7fa6cf; line-height: 1; margin-bottom: 6px; }
.drop p { margin: 4px 0; font-size: 13.5px; }
.drop .hint { font-size: 12px; }
.filelist { list-style: none; padding: 0; margin: 12px 0 0; }
.filelist li {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 6px; font-size: 13px; background: #fff;
}
.fi { background: #eef2f8; color: var(--navy); font-size: 10.5px; padding: 2px 6px; border-radius: 4px; font-weight: 700; }
.fn { flex: 1; word-break: break-all; }
.fs { color: var(--muted); font-size: 12px; }
.upload .btn.primary { width: 100%; margin-top: 16px; padding: 11px; font-size: 14px; }

table.rules { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
table.rules th { width: 42px; color: var(--navy); text-align: left; font-weight: 700; }
table.rules td { padding: 6px 0; border-bottom: 1px dashed #edf0f4; }
table.rules td.th { text-align: right; color: #374151; }
.decision-legend { font-size: 12.5px; color: #374151; border-top: 1px solid var(--line); padding-top: 12px; }
.decision-legend div { margin: 6px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); } .dot.green { background: var(--green); }
.statline { display: flex; gap: 18px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.statline > div { display: flex; flex-direction: column; }
.statline .num { font-size: 20px; font-weight: 700; }
.statline .lab { font-size: 11.5px; color: var(--muted); }
.num.red { color: var(--red); } .num.amber { color: var(--amber); } .num.green { color: var(--green); }

/* ---------- tables ---------- */
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; white-space: nowrap;
  border-bottom: 1px solid var(--line); padding: 8px 10px; background: #fafbfd;
}
table.list td { padding: 11px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list.small td, table.list.small th { padding: 7px 8px; font-size: 12.5px; }
table.list tbody tr:hover { background: #fbfcfe; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.reject { background: var(--red-bg); color: var(--red); }
.pill.manual { background: var(--amber-bg); color: var(--amber); }
.pill.pass { background: var(--green-bg); color: var(--green); }
.pill.small { padding: 1px 8px; font-size: 11.5px; }

/* ---------- case ---------- */
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.banner {
  display: flex; justify-content: space-between; gap: 24px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-left: 6px solid #999;
  border-radius: 12px; padding: 20px 24px; margin-bottom: 14px;
}
.banner.reject { border-left-color: var(--red); background: var(--red-bg); }
.banner.manual { border-left-color: var(--amber); background: var(--amber-bg); }
.banner.pass { border-left-color: var(--green); background: var(--green-bg); }
.banner h1 { font-size: 21px; margin: 6px 0 4px; }
.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: #fff; }
.banner.reject .badge { color: var(--red); border: 1px solid #e8bcb6; }
.banner.manual .badge { color: var(--amber); border: 1px solid #e6d3a8; }
.banner.pass .badge { color: var(--green); border: 1px solid #bcdcc8; }
.banner .reason { margin: 4px 0 0; font-size: 13.5px; color: #374151; max-width: 660px; }
.banner .advice { margin: 6px 0 0; font-size: 12.5px; color: #5b6472; max-width: 660px; }
.banner-side { font-size: 12.5px; color: #4b5563; text-align: right; line-height: 1.9; white-space: nowrap; }
@media (max-width: 760px) { .banner { flex-direction: column; } .banner-side { text-align: left; white-space: normal; } }
.actions { display: flex; gap: 10px; align-items: center; margin-bottom: 22px; }
.actions form { margin: 0; }
.sec { font-size: 15px; margin: 26px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 1000px) { .cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.mcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.mcard.hit { border-color: #edc9c4; background: #fffafa; }
.mcard.miss { border-color: #cfe6d8; }
.mhead { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mid { font-size: 11.5px; color: var(--muted); }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: #eef2f8; color: #4b5563; white-space: nowrap; }
.mcard.hit .tag { background: #fbe3e0; color: var(--red); }
.mcard.miss .tag { background: #e8f5ec; color: var(--green); }
.mval { font-size: 19px; font-weight: 700; margin-top: 8px; letter-spacing: .2px; }
.mth { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

table.detail { width: 100%; border-collapse: collapse; font-size: 13px; }
table.detail th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
                  border-bottom: 1px solid var(--line); padding: 8px; background: #fafbfd; }
table.detail td { padding: 12px 8px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
table.detail tr.rowhit td { background: #fffafa; }
table.detail td.th { color: #b45309; font-weight: 600; white-space: nowrap; }
table.detail .exp { color: #4a5560; font-size: 12.5px; line-height: 1.7; }
.bench { color: #8a93a0; font-size: 11.5px; margin-top: 4px; }
.note { font-size: 12.5px; color: #4b5563; margin: 12px 0 0; }
.warnbox { background: #fff8e6; border: 1px solid #f2dfae; padding: 8px 12px; border-radius: 8px; color: #7a5b12; }

table.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
table.kv td { padding: 7px 0; border-bottom: 1px dashed #edf0f4; }
table.kv td:first-child { color: var(--muted); width: 42%; }
table.kv td:last-child { text-align: right; font-weight: 600; }
.ok { color: var(--green); font-size: 12px; }
.warn { color: #b45309; font-size: 12px; }

.reviewed { font-size: 13.5px; }
.reviewed b.pass { color: var(--green); } .reviewed b.reject { color: var(--red); }
.reviewform { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.reviewform select, .reviewform input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: inherit;
}
.reviewform input { flex: 1; min-width: 220px; }

/* ---------- history ---------- */
.page-title { font-size: 21px; margin: 6px 0 16px; }
.stats-strip { display: flex; gap: 12px; margin-bottom: 16px; }
.stats-strip .s { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 22px; display: flex; flex-direction: column; }
.stats-strip .num { font-size: 20px; font-weight: 700; }
.stats-strip .lab { font-size: 11.5px; color: var(--muted); }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fff;
}
.filters input { min-width: 260px; }
.empty { text-align: center; padding: 46px 0; color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* ---------- settings ---------- */
.page-desc { color: var(--muted); font-size: 13px; margin: -6px 0 18px; max-width: 900px; }
.setgrid { display: grid; grid-template-columns: 1.12fr .88fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .setgrid { grid-template-columns: 1fr; } }
table.fields { width: 100%; border-collapse: collapse; font-size: 13px; }
table.fields th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
                  padding: 8px 6px; border-bottom: 1px solid var(--line); background: #fafbfd; }
table.fields td { padding: 9px 6px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
table.fields input { width: 96px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px;
                     font-size: 13.5px; font-family: inherit; text-align: right; }
table.fields input:focus { outline: none; border-color: #93b4d8; box-shadow: 0 0 0 3px rgba(43,108,176,.08); }
.logic { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
@media (max-width: 640px) { .logic { grid-template-columns: 1fr; } }
.logic label { display: flex; flex-direction: column; font-size: 13px; color: #374151; gap: 6px; }
.logic select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px;
                font-family: inherit; background: #fff; }
.logic .hint { margin: 0; }
.savebar { display: flex; gap: 10px; margin-top: 20px; align-items: center; }
.savebar input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
                 font-size: 13.5px; font-family: inherit; }
.rep-bars { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 12px; }
.rep-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.rep-row .lab { width: 86px; color: var(--muted); }
.rep-row .bar { flex: 1; height: 10px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.rep-row .fill { display: block; height: 100%; border-radius: 999px; }
.fill.red { background: var(--red); } .fill.amber { background: #d99b1f; } .fill.green { background: var(--green); }
.rep-row b { width: 118px; text-align: right; font-size: 12.5px; white-space: nowrap; }
.rep-note { font-size: 12.5px; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; }
.rep-note.ok { background: var(--green-bg); color: #1e6b3f; }
.rep-note.warn { background: var(--amber-bg); color: #7a5b12; }
.rep-note.bad { background: var(--red-bg); color: #a33; }
.rep-sub { font-size: 12.5px; color: #374151; border-top: 1px solid var(--line); padding-top: 10px; }
.rep-sub b.green { color: var(--green); } .rep-sub b.amber { color: #b7791f; } .rep-sub b.red { color: var(--red); }

table.fields td.inline { font-size: 13px; color: #374151; }
table.fields td.inline input { margin: 0 4px; }

table.fields td.inline .nw { white-space: nowrap; }
table.fields td.inline .nw + .nw { margin-left: 10px; }

/* ---------- language switch ---------- */
.topbar nav a.lang {
  margin-left: 18px; padding: 3px 12px; font-size: 12px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 999px;
  color: rgba(255,255,255,.9);
}
.topbar nav a.lang:hover { background: rgba(255,255,255,.12); border-color: #fff; color: #fff; text-decoration: none; }

/* ---------- auth ---------- */
.auth-body { background: #eef2f7; }
.auth-wrap { max-width: 430px; margin: 7vh auto 40px; padding: 0 20px; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 700; margin-bottom: 16px; }
.auth-brand .logo { background: var(--navy); color: #fff; width: 24px; height: 24px; border-radius: 7px;
                    display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.auth-brand .lang { margin-left: auto; font-size: 12px; color: #4a5568; text-decoration: none;
                    border: 1px solid #cbd5e1; padding: 3px 11px; border-radius: 999px; background: #fff; }
.auth-card { padding: 26px 26px 22px; }
.auth-card h1 { font-size: 20px; margin: 0 0 2px; }
.auth-card label { display: block; margin-top: 14px; font-size: 13px; color: #374151; }
.auth-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
                   border-radius: 8px; font-size: 14px; font-family: inherit; }
.auth-card input:focus { outline: none; border-color: #93b4d8; box-shadow: 0 0 0 3px rgba(43,108,176,.08); }
.auth-card .btn { width: 100%; margin-top: 20px; padding: 11px; font-size: 14px; }
.auth-err { background: var(--red-bg); color: var(--red); border: 1px solid #f0cfca; padding: 9px 12px;
            border-radius: 8px; font-size: 13px; margin-top: 12px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 11px; margin-top: 18px; line-height: 1.6; }

/* ---------- nav user ---------- */
.navlogout { display: inline-flex; align-items: center; gap: 10px; margin-left: 16px; }
.userchip { color: rgba(255,255,255,.85); font-size: 12.5px; }
.linkbtn { background: none; border: none; color: rgba(255,255,255,.68); font-size: 12.5px;
           cursor: pointer; font-family: inherit; padding: 0; }
.linkbtn:hover { color: #fff; text-decoration: underline; }

/* ---------- admin tables ---------- */
table.list select, table.list input[type=text] {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; font-family: inherit;
}
.inline-form { display: inline-flex; gap: 6px; margin: 2px 4px 2px 0; align-items: center; }
.inline-form input[type=text] { width: 110px; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger-ghost.small { padding: 5px 10px; }
.chk { font-size: 12px; display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.checkrow { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #374151; }
.checkrow input { margin-top: 3px; }
table.users td { vertical-align: middle; }

/* ---------- user admin layout ---------- */
.usergrid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .usergrid { grid-template-columns: 1fr; } }
.usergrid .fields td { padding: 8px 4px; }
.usergrid .fields input, .usergrid .fields select { width: 100%; text-align: left; }
table.users { table-layout: auto; }
table.users td { vertical-align: middle; white-space: nowrap; }
table.users td:first-child { white-space: normal; }
table.users .muted { font-weight: 400; }
table.users select { min-width: 104px; }
.badge-self { font-size: 11px; color: var(--muted); white-space: nowrap; }
