:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --paper: #f5f6f8;
  --card: #fff;
  --accent: #0b5cab;
  --accent-soft: #e8f2fb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); }

.shell { display: flex; min-height: 100vh; }

.side {
  width: 220px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand { padding: 4px 10px 18px; }

.brand strong { display: block; font-size: 16px; letter-spacing: 0.02em; }

.brand span { color: var(--muted); font-size: 12px; }

.side nav { display: flex; flex-direction: column; gap: 4px; }

.side nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: #344054;
  text-decoration: none;
}

.side nav a:hover { background: #f8fafc; }

.side nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.side-foot { margin-top: auto; padding: 12px 10px 0; }

.side-foot a { color: var(--muted); text-decoration: none; font-size: 13px; }

.workspace { flex: 1; min-width: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 28px 56px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}

h1 { font-size: 26px; line-height: 1.25; font-weight: 600; margin: 0; }

h2 { font-size: 15px; margin: 0 0 12px; }

.lead { color: var(--muted); margin: 6px 0 0; max-width: 640px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin-bottom: 16px; }

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.metric strong { font-size: 20px; font-weight: 600; }

.metric span { color: var(--muted); font-size: 12px; }

.metric.active { border-color: #b9d6f2; background: var(--accent-soft); }

.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { overflow: auto; }

table { width: 100%; border-collapse: collapse; }

th, td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fafbfc;
}

tr:last-child td { border-bottom: 0; }

tbody tr:hover { background: #fafbfc; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.mono { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.muted { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 36px 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f2f4f7;
  color: #344054;
}

.badge-pending, .badge-generated { background: var(--warn-soft); color: var(--warn); }

.badge-filed, .badge-uploaded { background: var(--accent-soft); color: var(--accent); }

.badge-success, .badge-replied { background: var(--ok-soft); color: var(--ok); }

.badge-failed, .badge-missing { background: var(--danger-soft); color: var(--danger); }

.tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f2f4f7;
  font-size: 12px;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.action-bar.loose {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

form.inline { display: inline; }

.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; }

.field { margin-bottom: 14px; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: #84b5e0; box-shadow: 0 0 0 3px rgba(11, 92, 171, 0.12); }

textarea { resize: vertical; }

input[type="file"] { width: 100%; font-size: 13px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.form-card { padding: 20px 20px 8px; margin-bottom: 16px; }

.form-card h2 { padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.form-actions { display: flex; gap: 8px; padding: 4px 0 16px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button.secondary, .button.secondary { background: #fff; color: #344054; border-color: #d0d5dd; }

button.danger { background: #fff; color: var(--danger); border-color: #f0c7c3; }

button:hover, .button:hover { filter: brightness(0.97); }

.flash { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

.flash.error { border-color: #f5c2c0; background: var(--danger-soft); color: var(--danger); }

.flash.ok { border-color: #abefc6; background: var(--ok-soft); color: var(--ok); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 10% -10%, #e7f1fb, transparent 60%),
    var(--paper);
}

.login-card { width: min(420px, 100%); padding: 28px; }

.login-card h1 { margin-bottom: 6px; }

.login-card .button, .login-card button { width: 100%; margin-top: 8px; }

.narrow { max-width: 560px; }

.reply-name { display: block; margin-top: 2px; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 8px; }
  main { padding: 20px 16px 40px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
