:root {
  --blue: #00529b;
  --deep: #092f57;
  --sky: #dff0fb;
  --ink: #172532;
  --muted: #617486;
  --line: #c9d8e4;
  --bg: #eef5f9;
  --panel: #ffffff;
  --ok: #16794c;
  --warn: #a36b00;
  --bad: #aa3131;
  --shadow: 0 12px 32px rgba(9, 47, 87, .10);
  --gold: #f6a623;
  --green: #1f7a54;
}

:root[data-theme="dark"] {
  --blue: #49a7ff;
  --deep: #d8ecff;
  --sky: #0d385e;
  --ink: #edf6ff;
  --muted: #9fb6c8;
  --line: #254b68;
  --bg: #071522;
  --panel: #0d2132;
  --shadow: 0 14px 36px rgba(0,0,0,.32);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(0, 82, 155, .10), transparent 26%),
    linear-gradient(180deg, #f8fbfd 0%, var(--bg) 34%, #f7fafc 100%);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: auto -90px -130px auto;
  width: 320px;
  height: 320px;
  border: 28px solid rgba(0, 82, 155, .055);
  border-radius: 50%;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  left: -80px;
  top: 120px;
  width: 210px;
  height: 210px;
  background:
    linear-gradient(90deg, transparent 48%, rgba(0,82,155,.09) 49%, rgba(0,82,155,.09) 51%, transparent 52%),
    linear-gradient(0deg, transparent 48%, rgba(0,82,155,.09) 49%, rgba(0,82,155,.09) 51%, transparent 52%);
  transform: rotate(18deg);
  pointer-events: none;
}

.hidden { display: none !important; }
button, input, select, textarea { font: inherit; }
button, .button-link {
  min-height: 42px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button.secondary {
  background: #fff;
  color: var(--deep);
  border-color: var(--line);
}
button.small { min-height: 34px; font-size: 13px; }
button:disabled { cursor: not-allowed; background: #d8e3eb; border-color: #d8e3eb; color: #728395; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; color: var(--deep); font-size: 28px; letter-spacing: 0; }
h2 { margin-bottom: 0; color: var(--blue); font-size: 22px; letter-spacing: 0; }
h3 { margin-bottom: 12px; color: var(--deep); font-size: 17px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 13px; font-weight: 700; }
.subtitle, .hint, .form-note, .meta { color: var(--muted); }
.hint, .form-note, .meta { font-size: 13px; line-height: 1.6; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}
.login-card {
  width: min(430px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.login-card::after {
  content: "";
  position: absolute;
  right: -50px;
  top: -50px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246,166,35,.26), rgba(246,166,35,0) 66%);
}
.login-logo { width: 72px; height: 72px; object-fit: contain; margin-bottom: 10px; }
.form-error { min-height: 20px; margin: 0; color: var(--bad); }

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}
.topbar {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.90);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -36px;
  width: 220px;
  height: 90px;
  background:
    linear-gradient(135deg, transparent 8px, rgba(0,82,155,.12) 9px, rgba(0,82,155,.12) 12px, transparent 13px),
    linear-gradient(45deg, transparent 8px, rgba(31,122,84,.10) 9px, rgba(31,122,84,.10) 12px, transparent 13px);
  background-size: 34px 34px;
  opacity: .8;
}
.status-card {
  padding: 14px;
  border-left: 4px solid var(--blue);
  background: #f7fbfe;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.status-card span { color: var(--muted); font-size: 13px; }
.status-card strong { margin-top: 6px; color: var(--blue); font-size: 18px; }

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.tab {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  color: var(--deep);
}
.tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.view { display: none; }
.view.active { display: block; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 12px;
}
.section-head select { min-width: 220px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.panel, .card, .list-item, .person-card, .archive-group {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  padding: 14px;
  box-shadow: 0 4px 18px rgba(9,47,87,.04);
}
.panel { position: relative; }
.hero-panel::after {
  content: "PV";
  position: absolute;
  right: 14px;
  top: 12px;
  color: rgba(0,82,155,.10);
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 2px;
}
.hero-panel { border-top: 4px solid var(--blue); }
.notice { margin-bottom: 12px; background: #f7fbfe; }

.timeline { display: grid; gap: 10px; }
.time-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 10px;
  border-left: 4px solid var(--blue);
  background: #f8fbfd;
}
.time-row strong { color: var(--blue); }
.facts {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 10px;
  margin: 0 0 12px;
}
.facts dt { color: var(--blue); font-weight: 700; }
.facts dd { margin: 0; }
.task-box {
  border: 1px solid var(--line);
  background: #f8fbfd;
  padding: 12px;
}
.task-box ul, .notice ul { margin: 8px 0 0; padding-left: 20px; line-height: 1.75; }
.task-card { border-left: 4px solid var(--blue); padding: 10px; background: #fff; margin-top: 8px; }
.task-card strong { color: var(--deep); }

.form { display: grid; gap: 12px; }
.form-row, .filters { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.filters { grid-template-columns: 1fr 1fr 1.2fr; }
label { display: grid; gap: 6px; color: var(--deep); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  color: var(--ink);
  outline-color: var(--blue);
}
textarea { resize: vertical; }
.readonly-date {
  border: 1px dashed var(--line);
  background: #f8fbfd;
  color: var(--blue);
  padding: 10px 12px;
  font-weight: 700;
}
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  border: 1px solid var(--line);
  background: #f8fbfd;
}
.segmented label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-right: 1px solid var(--line);
}
.segmented label:last-child { border-right: 0; }

.list, .card-list, .archive-list { display: grid; gap: 10px; margin-top: 12px; }
.list-item { display: grid; gap: 7px; }
.person-card { display: grid; gap: 8px; }
.person-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.profile-card {
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(0,82,155,.08), transparent 45%),
    var(--panel);
}
.profile-avatar {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, var(--gold), transparent 32%),
    var(--blue);
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.person-card .line { display: grid; gap: 4px; }
.person-card .line span:first-child { color: var(--muted); font-size: 12px; }
.badge {
  display: inline-flex;
  width: fit-content;
  padding: 2px 8px;
  background: var(--sky);
  color: var(--blue);
  border: 1px solid var(--line);
  font-size: 12px;
}
.badge.ok { background: #effaf4; color: var(--ok); border-color: #9ad3b4; }
.badge.warn { background: #fff6dc; color: var(--warn); border-color: #eed28e; }
.badge.bad { background: #fff0f0; color: var(--bad); border-color: #e9b1b1; }

.file-list, .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.vertical { align-items: stretch; flex-direction: column; }
.file-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.file-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
}
.file-button { cursor: pointer; font-family: inherit; }
.file-link:hover, .file-button:hover { border-color: var(--blue); color: var(--blue); }
.file-pill.disabled { color: var(--muted); }

.archive-group { display: grid; gap: 10px; }
.archive-group h3 { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.archive-subtitle { color: var(--muted); font-size: 13px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5,30,58,.52);
}
.modal-card {
  width: min(960px, 100%);
  max-height: 92vh;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(7,35,66,.24);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
}
.preview-body {
  min-height: 260px;
  overflow: auto;
  padding: 14px;
  background: #f8fbfe;
}
.preview-media { width: 100%; max-height: 72vh; object-fit: contain; background: #000; }
.preview-frame { width: 100%; height: 72vh; border: 0; background: #fff; }
.text-preview {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
  line-height: 1.75;
}
.modal-card > .actions { padding: 12px 14px; border-top: 1px solid var(--line); }

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .tab,
:root[data-theme="dark"] .file-pill {
  background: #10283b;
  color: var(--ink);
}

:root[data-theme="dark"] .status-card,
:root[data-theme="dark"] .task-box,
:root[data-theme="dark"] .readonly-date,
:root[data-theme="dark"] .notice,
:root[data-theme="dark"] .time-row,
:root[data-theme="dark"] .task-card {
  background: #10283b;
}

:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .list-item,
:root[data-theme="dark"] .person-card,
:root[data-theme="dark"] .archive-group,
:root[data-theme="dark"] .modal-card {
  background: rgba(13, 33, 50, .96);
}

:root[data-theme="dark"] button.secondary {
  background: #10283b;
  color: var(--ink);
}

:root[data-theme="dark"] .tabs {
  background: rgba(7, 21, 34, .96);
}

@media (max-width: 820px) {
  .app-shell { padding: 10px; padding-bottom: 82px; }
  .topbar { grid-template-columns: 1fr; padding: 14px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 24px rgba(9,47,87,.10);
  }
  .tab { min-width: 72px; min-height: 40px; font-size: 13px; }
  .grid.two, .form-row, .filters { grid-template-columns: 1fr; }
  .section-head { align-items: stretch; flex-direction: column; }
  .section-head select { min-width: 0; }
  .person-card header { display: grid; }
}

@media (max-width: 460px) {
  .login-card { padding: 22px; }
  .facts { grid-template-columns: 1fr; }
  .time-row { grid-template-columns: 1fr; }
  .segmented { grid-template-columns: 1fr; }
  .segmented label { border-right: 0; border-bottom: 1px solid var(--line); }
  .segmented label:last-child { border-bottom: 0; }
}


.map-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.map-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.map-toolbar span {
  color: var(--muted);
  font-size: 13px;
}
.rule-map {
  width: 100%;
  height: 300px;
  background: #eef4f7;
}
@media (max-width: 720px) {
  .map-toolbar { flex-direction: column; align-items: stretch; }
  .rule-map { height: 260px; }
}


.update-helper .update-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.update-helper .update-box p {
  margin: 6px 0 10px;
  color: var(--muted);
  line-height: 1.55;
}


.urgent-update {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(8, 92, 138, .22);
  border-radius: 8px;
  background: #eef8ff;
  color: #073b5c;
}
.urgent-update strong {
  font-size: 15px;
}
.urgent-update span {
  color: #42606f;
  line-height: 1.5;
  font-size: 13px;
}
.urgent-update a {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  background: #0b68a2;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.top-update {
  margin: 0 0 12px;
}
