:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #6b7a90;
  --line: #e3e8f0;
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --side: #0e2438;
  --side-2: #0b1c2c;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --gray: #6b7280;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 24px; letter-spacing: .2px; }
h2 { font-size: 15px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.small { font-size: 12px; }
.autosave-state { font-size: 12px; color: #64748b; margin-right: 8px; white-space: nowrap; }
.autosave-state.saving { color: #d97706; }
.autosave-state.saved { color: #16a34a; }
.autosave-state.error { color: #dc2626; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(37, 99, 235, .18), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(14, 165, 233, .16), transparent 60%),
    #0b1c2c;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: #fff;
  border-radius: 18px;
  padding: 34px 32px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.brand-badge {
  width: 48px; height: 48px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .3);
}
.brand-badge.small { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }
.brand-photo {
  object-fit: cover;
  object-position: center 30%;
  box-sizing: border-box;
  padding: 0;
  background: #fff;
  border: 2px solid rgba(255, 255, 255, .9);
  box-shadow: 0 8px 18px rgba(2, 6, 23, .28);
}
.login-card .brand-photo { width: 96px; height: 96px; border-radius: 20px; }
.side-brand .brand-photo { width: 68px; height: 68px; border-radius: 16px; }
.login-card h1 { margin-top: 16px; font-size: 22px; }
.login-card .muted { margin: 4px 0 22px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: #334155; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
  background: #f8fafc;
}
.login-card input:focus { outline: 2px solid rgba(37, 99, 235, .18); border-color: var(--brand); background: #fff; }
.login-check {
  display: flex !important; align-items: center; gap: 8px;
  margin: 2px 0 16px !important; font-size: 13px; color: #475569;
  cursor: pointer;
}
.login-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.form-check {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 0 10px; font-size: 13px; color: #334155;
  cursor: pointer;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.login-hint { margin: 14px 0 0; font-size: 12px; color: #94a3b8; text-align: center; }
.form-error { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 8px; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; display: flex; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: linear-gradient(180deg, var(--side), var(--side-2));
  color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.side-brand b { font-size: 14px; display: block; letter-spacing: .5px; }
.side-brand small { font-size: 11px; color: #94a3b8; display: block; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  color: #cbd5e1; padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; text-decoration: none;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(37, 99, 235, .22); color: #fff; border-left-color: #38bdf8; }
.nav svg { width: 17px; height: 17px; opacity: .9; }
.nav-group { margin: 2px 0 4px; }
.nav-parent {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; color: #94a3b8; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-parent svg { width: 17px; height: 17px; opacity: .8; }
.nav a.nav-sub { padding-left: 42px; font-size: 13px; }
.side-foot { margin-top: auto; padding: 12px 8px 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-chip { margin-bottom: 8px; }
.user-chip span { display: block; color: #fff; font-size: 13px; }
.user-chip small { color: #94a3b8; font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px; background: rgba(255, 255, 255, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.crumb { font-size: 13px; color: var(--muted); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.menu-btn { display: none !important; }
.page { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ---------- common ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head p { margin: 5px 0 0; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { font-size: 12px; color: var(--muted); display: inline-block; margin-bottom: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 13px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13px; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(15, 23, 42, .05); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .count { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head-row h2 { margin-bottom: 0; }
.editor-table td { padding: 6px; }
.editor-table .cell-input {
  width: 100%; min-width: 72px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 12px; font-family: inherit; background: #fff; color: var(--ink);
}
.editor-table .cell-input:focus { outline: 2px solid rgba(37, 99, 235, .15); border-color: var(--brand); }
.editor-table input[type="number"] { text-align: right; }
.editor-table th:last-child,
.editor-table td:last-child {
  position: sticky; right: 0; background: #fff; z-index: 2;
  box-shadow: -6px 0 10px rgba(15, 23, 42, .04);
}
.editor-table th:last-child { background: #f8fafc; z-index: 3; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-num { font-size: 27px; font-weight: 800; margin-top: 5px; letter-spacing: .3px; }
.stat-num.dual { font-size: clamp(19px, 2.1vw, 27px); white-space: nowrap; letter-spacing: 0; }
.stat-num .slash { color: #94a3b8; font-weight: 500; margin: 0 5px; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f8fafc; color: #475569; font-size: 12px; font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8fbff; }
.table tr.clickable { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }

/* ---------- 基本数据：井身结构 / 靶点 ---------- */
#sections-table,
#targets-table,
#personnel-table { font-size: 14px; }
#sections-table th,
#targets-table th,
#personnel-table th {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  text-align: center !important;
  background: #f2f6fc;
}
#sections-table td,
#targets-table td,
#personnel-table td,
#sections-table td.num,
#targets-table td.num,
#personnel-table td.num {
  text-align: center !important;
  font-size: 14px;
  padding: 8px 10px;
  vertical-align: middle;
}
#sections-table .cell-input,
#targets-table .cell-input,
#personnel-table .cell-input {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  padding: 8px 10px;
  border-color: #d5deeb;
}
#sections-table input[type="number"],
#targets-table input[type="number"],
#personnel-table input[type="number"] { text-align: center; }
#personnel-table input[type="date"] { font-size: 14px; }

/* ---------- instrument table ---------- */
.instrument-table-wrap { max-width: 1180px; }
.instrument-table { table-layout: fixed; min-width: 1000px; font-size: 16px; }
.instrument-table th,
.instrument-table td { padding: 14px 16px; text-align: center; }
.instrument-table th {
  font-size: 16px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: .02em;
}
.instrument-table td { font-size: 16px; font-weight: 500; color: #1f2937; }
.instrument-table th:nth-child(1), .instrument-table td:nth-child(1) { width: 17%; }
.instrument-table th:nth-child(2), .instrument-table td:nth-child(2) { width: 10%; }
.instrument-table th:nth-child(3), .instrument-table td:nth-child(3) { width: 16%; }
.instrument-table th:nth-child(4), .instrument-table td:nth-child(4) { width: 10%; }
.instrument-table th:nth-child(5), .instrument-table td:nth-child(5) { width: 13%; }
.instrument-table th:nth-child(6), .instrument-table td:nth-child(6) { width: 14%; }
.instrument-table th:nth-child(7), .instrument-table td:nth-child(7) { width: 20%; text-align: center; }
.instrument-table .code { font-size: 16px; font-weight: 600; color: #0f172a; }
.instrument-table .badge { font-size: 16px; font-weight: 500; padding: 4px 10px; }
.instrument-table td:nth-child(6) { font-variant-numeric: tabular-nums; }
.instrument-table td:nth-child(6) .small { margin-top: 3px; font-size: 14px; color: #94a3b8; }
.missing-inspection { font-size: inherit; font-weight: inherit; color: var(--red); white-space: normal; }
.instrument-table .btn-sm { padding: 6px 12px; font-size: 16px; }
.report-actions { white-space: nowrap; }
.report-actions .btn-sm { padding: 6px 10px; margin: 0 2px; }

/* ---------- instrument list ---------- */
.inst-save-state { font-size: 12px; color: #64748b; margin-left: 12px; white-space: nowrap; }
.inst-save-state.saving { color: #d97706; }
.inst-save-state.saved { color: #16a34a; }
.inst-save-state.error { color: #dc2626; }
.inst-list .table th,
.inst-list .table td,
.inst-list .table .num {
  text-align: center !important;
}
.inst-list .table { font-size: 14px; }
.inst-list .table th {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  background: #f2f6fc;
}
.inst-list .table td {
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
}
.inst-list .editor-table .cell-input {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  padding: 8px 10px;
  border-color: #d5deeb;
}
.inst-list .editor-table .cell-input[readonly] {
  background: #f4f7fc;
  color: #334155;
  font-weight: 600;
}
.inst-list .editor-table input[type="number"] { text-align: center; }
.inst-list .card-head-row h2 { font-size: 16px; color: #0f172a; }
.inst-list .card.form label { font-size: 15px; font-weight: 700; color: #0f172a; }
.inst-list .card.form input, .inst-list .card.form select { font-size: 14px; font-weight: 500; color: #0f172a; }
.inst-list .btn-sm { font-weight: 600; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: #eef2f7; color: #475569;
}
.badge-green { background: #e7f7ee; color: #15803d; }
.badge-red { background: #fdecec; color: #b91c1c; }
.badge-yellow { background: #fff4e5; color: #b45309; }
.badge-blue { background: #e8f0fe; color: #1d4ed8; }
.badge-gray { background: #eef2f7; color: #475569; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* ---------- forms ---------- */
.form label { display: block; margin-bottom: 12px; font-size: 12px; color: #475569; font-weight: 600; }
.form input, .form select, .form textarea {
  width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .15); border-color: var(--brand);
}
.form textarea { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-note { font-size: 11px; color: var(--muted); margin-top: -4px; margin-bottom: 12px; }
input[type="file"] { padding: 7px; background: #f8fafc; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 10px 14px; font-size: 13px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.tab .n { color: #94a3b8; font-size: 11px; margin-left: 4px; }

/* ---------- well ---------- */
.well-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.well-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.progress-strip {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 16px; margin-bottom: 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
}
.progress-strip .label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.progress { flex: 1; height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #0ea5e9); border-radius: 99px; }
.progress-strip .pct { font-size: 13px; font-weight: 700; min-width: 42px; text-align: right; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.kv .row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #edf1f7; font-size: 13px; }
.kv .row:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-weight: 600; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { background: #f1f5f9; color: #334155; border-radius: 6px; padding: 2px 7px; font-size: 11px; }
.chip b { font-weight: 700; }
.empty {
  text-align: center; padding: 40px 16px; color: var(--muted);
  border: 1px dashed #d7deea; border-radius: 12px; background: #fbfcfe;
}
.empty strong { display: block; color: #334155; margin-bottom: 6px; font-size: 14px; }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .46);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 100; overflow-y: auto;
}
.modal {
  width: 620px; max-width: 100%; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3); overflow: hidden;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(6px); opacity: .7; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-close { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 18px 20px 20px; }
.modal-wide { width: 820px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 200;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }

/* ---------- misc ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="search"] {
  width: 260px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.toolbar .spacer { flex: 1; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #edf1f7; font-size: 13px; }
.alert-row:last-child { border-bottom: 0; }
.alert-row .when { margin-left: auto; white-space: nowrap; }
.due-red { color: var(--red); font-weight: 700; }
.due-yellow { color: var(--amber); font-weight: 700; }
.stat-inline { display: flex; gap: 8px; align-items: baseline; }
.stat-inline b { font-size: 18px; }
.section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 18px 0 8px; }
.code { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }

@media (max-width: 980px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .app.side-open .sidebar { transform: none; }
  .app.side-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 50;
  }
  .menu-btn { display: inline-flex !important; }
  .page { padding: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
