:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #eef5f2;
  --ink: #17211d;
  --muted: #65736d;
  --line: #d8e2dd;
  --brand: #0d7c66;
  --brand-dark: #095c4b;
  --accent: #d96d2b;
  --warn: #b54b2f;
  --ok: #23785a;
  --info: #286f9f;
  --shadow: 0 12px 30px rgba(26, 44, 38, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }

.pre-line { white-space: pre-wrap; }
button { cursor: pointer; }
.hidden { display: none !important; }

.portal {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(13, 124, 102, .92), rgba(23, 33, 29, .72)),
    url("data:image/svg+xml,%3Csvg width='1200' height='760' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1200' height='760' fill='%23e7efeb'/%3E%3Cpath d='M0 560 C 250 460 420 610 660 520 S 1030 450 1200 540 L1200 760 L0 760Z' fill='%23c7d9d2'/%3E%3Cpath d='M90 470 L1120 470' stroke='%238aa197' stroke-width='18'/%3E%3Cpath d='M160 410 h180 v60 h-180zM420 370h240v100H420zM730 420h260v50H730z' fill='%23ffffff' opacity='.72'/%3E%3Cpath d='M220 280h54v190h-54zM480 250h64v220h-64zM850 290h54v180h-54z' fill='%23a9bdb5'/%3E%3C/svg%3E") center/cover no-repeat;
}
.portal-shell { width: min(1120px, 92vw); margin: 0 auto; padding: 8vh 0; }
.portal-hero {
  min-height: 76vh;
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  align-items: center;
  gap: 48px;
  color: #fff;
}
.eyebrow { margin: 0 0 14px; color: #d7f2e9; font-weight: 700; }
.portal h1 { max-width: 820px; margin: 0; font-size: clamp(34px, 6vw, 64px); line-height: 1.1; }
.lead { max-width: 620px; font-size: 20px; line-height: 1.7; color: #eef9f5; }
.portal-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 28px; }
.primary-btn, .ghost-btn, .small-btn, .danger-btn {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
}
.primary-btn { background: var(--brand); color: #fff; }
.primary-btn:hover { background: var(--brand-dark); }
.ghost-btn { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.55); }
.small-btn { background: var(--panel-soft); color: var(--brand-dark); }
.danger-btn { background: #fff1ec; color: var(--warn); }
.danger-btn:disabled { cursor: not-allowed; opacity: .6; }
.hazard-danger-zone {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #efc8bc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.hazard-danger-zone strong { color: var(--warn); }
.hazard-danger-zone p { margin: 5px 0 0; }
.hazard-delete-btn { flex: 0 0 auto; border: 1px solid #df9c88; }
.hazard-delete-btn:hover { background: #fbe1d8; }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-picker {
  cursor: pointer;
}
.login-card {
  background: rgba(255,255,255,.92);
  color: var(--ink);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.phone-shell {
  width: min(430px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  background: #ededed;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.mobile-body { background: #d8dfdc; }
.app-icon { width: 22px; height: 22px; display: block; }
.mobile-app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 58px;
  padding: 9px 14px;
  background: rgba(247, 247, 247, .96);
  border-bottom: 1px solid #d5d5d5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mobile-app-bar h1 { margin: 0; font-size: 18px; letter-spacing: 0; }
.mobile-app-bar p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.mobile-app-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: #e6e6e6; }
.mobile-content { padding: 12px 0 88px; display: grid; gap: 12px; }
.mobile-content > .card { margin: 0 12px; }
#hazardForm { padding: 0 12px; }
.mobile-tabbar {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100vw);
  min-height: 64px;
  padding: 5px 8px max(5px, env(safe-area-inset-bottom));
  border-top: 1px solid #d4d4d4;
  background: rgba(248, 248, 248, .98);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.mobile-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: #666;
  min-width: 0;
  min-height: 52px;
  padding: 3px 2px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  font-size: 11px;
}
.mobile-tab.active { color: var(--brand); }
.mobile-tab-icon { position: relative; display: block; }
.mobile-tab-icon .app-icon { width: 24px; height: 24px; }
.tab-badge {
  position: absolute;
  left: 17px;
  top: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #d7443e;
  color: #fff;
  border: 2px solid #f8f8f8;
  font-size: 10px;
  line-height: 14px;
  font-weight: 700;
}
.notification-toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 78px;
  transform: translate(-50%, 12px);
  width: min(390px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: #1f3f3a;
  color: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 4px;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.notification-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.notification-toast strong {
  font-size: 14px;
  line-height: 1.25;
}
.notification-toast span {
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.82);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-list-section { background: #fff; }
.hazard-avatar, .message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  color: #fff;
  display: grid;
  place-items: center;
}
.todo-switch {
  margin: 10px 14px;
  padding: 3px;
  border-radius: 8px;
  background: #ededed;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}
.todo-switch button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 6px;
}
.todo-switch button.active {
  background: #fff;
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.section-heading {
  min-height: 46px;
  padding: 8px 14px;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.section-heading h2 { margin: 0; font-size: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 3px 14px rgba(30, 46, 40, .05);
}
.card h2, .card h3 { margin: 0 0 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric {
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 12px;
}
.metric strong { display: block; font-size: 24px; color: var(--brand-dark); }
.default-notify-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.default-person {
  min-width: 0;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 5px;
}
.default-person span { color: var(--muted); font-size: 12px; }
.default-person strong { font-size: 14px; overflow-wrap: anywhere; }
.form-grid { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: 13px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 11px;
  min-height: 42px;
}
.field textarea { resize: vertical; min-height: 76px; }
.location-inputs {
  display: grid;
  grid-template-columns: minmax(110px, .9fr) minmax(0, 1.35fr);
  gap: 8px;
}
.check-list {
  display: grid;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: var(--ink);
}
.check-item input {
  width: 18px;
  height: 18px;
}

.legal-basis-list {
  display: grid;
  gap: 10px;
}

.legal-basis-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.legal-basis-item p {
  margin: 8px 0 0;
  line-height: 1.65;
}

.legal-basis-compact .row {
  flex-wrap: wrap;
}

.legal-basis-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.legal-modal-list {
  display: grid;
  gap: 14px;
}

.legal-basis-modal {
  width: min(760px, 100%);
}

.legal-basis-modal h3,
.legal-basis-modal h4 {
  margin: 0 0 8px;
}

.legal-basis-modal h4 {
  margin-top: 20px;
}

.legal-dialog-text {
  padding: 12px;
  border-radius: 8px;
  background: #f7faf9;
  line-height: 1.75;
}

.legal-parent {
  margin-top: 10px;
  color: var(--muted);
}

.legal-parent summary {
  cursor: pointer;
  color: var(--primary);
}

.legal-confirm-check {
  align-items: flex-start;
}

.legal-confirmed {
  color: #027a48;
  font-size: 13px;
}
.upload-box {
  border: 1px dashed #9bb4aa;
  background: #f5faf8;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.preview {
  width: 100%;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #e3eeea, #f8fbfa);
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
}
.preview img { width: 100%; height: 100%; object-fit: cover; }
.rectification-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.rectification-gallery .preview { aspect-ratio: 4/3; }
.cc-read-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.cc-read-row > strong { flex: 0 0 auto; }
.cc-read-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.cc-read-person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.cc-read-indicator {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 17px;
  box-sizing: border-box;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.cc-read-indicator.is-read {
  color: #fff;
  background: #22a06b;
}
.cc-read-indicator.is-unread {
  background: #d7dce1;
  border: 1px solid #c6ccd2;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.hazard-list-item {
  width: 100%;
  min-height: 78px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid #ececec;
  background: #fff;
  color: var(--ink);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
}
.hazard-list-item:last-child { border-bottom: 0; }
.hazard-list-item.unread { background: #fffdf9; }
.hazard-avatar { background: #e29b46; }
.hazard-avatar.major { background: var(--warn); }
.hazard-avatar .app-icon { width: 22px; height: 22px; }
.hazard-copy { min-width: 0; display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.hazard-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); }
.hazard-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hazard-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hazard-side { display: grid; justify-items: end; gap: 7px; color: #aaa; }
.hazard-side .app-icon { width: 17px; }
.message-center { display: grid; gap: 12px; }
.message-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 0 14px;
}
.message-head h2, .message-head p { margin: 0; }
.message-head p { margin-top: 5px; }
.message-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.message-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e6e6e6;
  border-bottom: 1px solid #e6e6e6;
}
.message-filters label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.message-filter-select {
  width: min(220px, 100%);
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}
.message-list { display: grid; gap: 10px; }
.message-section { display: grid; background: #fff; }
.message-section h3 {
  margin: 0;
  padding: 7px 14px;
  background: #ededed;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.notification-item {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid #ececec;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.notification-item:last-child { border-bottom: 0; }
.notification-item.unread { background: #fff; }
.message-avatar { width: 44px; height: 44px; background: #4d8fb1; }
.message-avatar.review { background: var(--brand); }
.message-avatar.overdue { background: var(--warn); }
.message-avatar .app-icon { width: 23px; height: 23px; }
.notification-body { min-width: 0; display: grid; gap: 4px; }
.conversation-title { min-width: 0; display: flex; align-items: center; gap: 7px; }
.conversation-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.conversation-title .status { flex: 0 0 auto; }
.conversation-summary, .conversation-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-summary { color: #666; font-size: 13px; }
.conversation-label { color: #999; font-size: 11px; }
.conversation-meta { align-self: stretch; display: grid; justify-items: end; align-content: space-between; color: #999; }
.conversation-meta time, .conversation-meta small { font-size: 11px; white-space: nowrap; }
.conversation-meta .app-icon { width: 16px; height: 16px; }
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  background: #eaf2f8;
  color: var(--info);
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--warn);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.status.closed { background: #e8f5ef; color: var(--ok); }
.status.overdue { background: #fff0ea; color: var(--warn); }
.level { color: var(--accent); font-weight: 700; }
.muted { color: var(--muted); }

.login-screen {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 22px;
}
.login-screen h1 { margin: 0; font-size: 28px; }
.login-screen .card { box-shadow: var(--shadow); }

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  background: #17332d;
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { font-size: 18px; font-weight: 700; margin-bottom: 22px; line-height: 1.45; }
.nav-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8eee7;
  padding: 12px;
  text-align: left;
  margin-bottom: 6px;
}
.nav-btn.active, .nav-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.admin-main { padding: 24px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.admin-header h1 { margin: 0; }
.section-filter {
  min-width: 150px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}
.section-management {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.section-config {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  align-content: start;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
}
.content-grid {
  display: grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 14px;
  margin-top: 14px;
}
.hazard-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}
.hazard-filters label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.hazard-filters input,
.hazard-filters select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.filter-keyword {
  min-width: 220px;
}
.hazard-selection-cell {
  width: 42px;
  min-width: 42px;
  text-align: center;
}
.hazard-selection-cell input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}
tr.hazard-row-selected td { background: #eef8f4; }
#batchDeleteHazards:disabled {
  cursor: not-allowed;
  opacity: .5;
}
.grid-roster-summary {
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  margin-bottom: 14px;
}
.grid-roster-card {
  display: grid;
  gap: 16px;
}
.grid-roster-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.grid-roster-head h2 {
  margin: 0 0 6px;
}
.grid-roster-toolbar {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}
.grid-roster-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.grid-roster-toolbar select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.grid-roster-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.grid-roster-context div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.grid-roster-context span {
  color: var(--muted);
  font-size: 12px;
}
.grid-roster-warning {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #f2c94c;
  border-radius: 8px;
  background: #fffaeb;
  color: #92400e;
  font-weight: 700;
}
.grid-roster-action {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 310px;
}
.grid-roster-action select {
  min-width: 230px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.grid-management-summary {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  margin-bottom: 14px;
}
.grid-management-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.grid-management-nav {
  position: sticky;
  top: 20px;
  padding: 16px;
}
.grid-management-nav h2,
.grid-management-detail h2 { margin: 0 0 5px; }
.grid-management-nav p { margin: 0; }
.grid-nav-scroll {
  max-height: calc(100vh - 270px);
  margin-top: 14px;
  overflow: auto;
  display: grid;
  gap: 16px;
}
.grid-nav-section { display: grid; gap: 9px; }
.grid-nav-section > strong {
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.grid-nav-level2 { display: grid; gap: 5px; }
.grid-nav-level2 > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.grid-nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.grid-nav-item:hover { background: var(--panel-soft); }
.grid-nav-item.active { background: var(--brand); color: #fff; }
.grid-nav-item small { color: var(--warn); font-weight: 700; }
.grid-nav-item.active small { color: #ffe4dc; }
.grid-context-menu {
  position: fixed;
  z-index: 120;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 38, 35, 0.18);
}
.grid-context-menu button {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 9px 12px;
  background: transparent;
  color: var(--warn);
  font: inherit;
  font-weight: 700;
  text-align: left;
}
.grid-context-menu button:hover,
.grid-context-menu button:focus-visible { background: #fff0ec; }
.grid-management-detail { display: grid; gap: 14px; min-width: 0; }
.grid-info-form { padding: 18px; }
.grid-info-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid-info-wide { grid-column: 1 / -1; }
.grid-info-form input:disabled {
  background: #f2f5f4;
  color: var(--muted);
}
#optionalCcForm,
#autoCcForm { padding: 18px; }
.optional-cc-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
}
.optional-cc-toolbar input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
.optional-cc-toolbar span { color: var(--muted); font-weight: 700; white-space: nowrap; }
.optional-cc-list { max-height: 420px; gap: 14px; }
.optional-cc-group { display: grid; gap: 8px; }
.optional-cc-group > strong {
  position: sticky;
  top: -10px;
  z-index: 1;
  padding: 8px 0;
  background: #fff;
  color: var(--brand-dark);
}
.optional-cc-group > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}
.optional-cc-person {
  padding: 5px 7px;
  border-radius: 6px;
}
.optional-cc-person:hover { background: var(--panel-soft); }
.optional-cc-person[hidden], .optional-cc-group[hidden] { display: none; }
.user-toolbar {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}
.user-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.user-toolbar input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.legal-library-summary { margin-bottom: 16px; }
.legal-library-summary .metric strong { font-size: clamp(20px, 2vw, 30px); word-break: break-word; }
.legal-task-card { margin-bottom: 16px; }
.legal-list-head h2 { margin: 0 0 6px; }
.legal-list-head p { margin: 0; }
.legal-job-inline {
  padding: 7px 10px;
  border-radius: 8px;
  background: #eef6fb;
  color: var(--info);
  font-weight: 700;
}
.legal-list-head { margin-bottom: 14px; }
.legal-add-btn span { font-size: 21px; line-height: 1; }
.legal-library-toolbar {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 160px auto;
  gap: 10px;
  align-items: center;
}
.legal-library-toolbar input,
.legal-library-toolbar select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}
.legal-library-toolbar span { color: var(--muted); font-weight: 700; white-space: nowrap; }
.legal-library-table td { min-width: 130px; }
.legal-library-table td:first-child { min-width: 260px; }
.legal-library-table small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.45; }
.legal-file-link {
  max-width: 420px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand-dark);
  font: inherit;
  font-weight: 700;
  line-height: 1.5;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: #9bc8bb;
  text-underline-offset: 3px;
}
.legal-file-link:hover,
.legal-file-link:focus-visible { color: var(--brand); text-decoration-color: currentColor; }
.legal-source {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.legal-source.builtin { background: #edf1ef; color: var(--muted); }
.legal-source.uploaded { background: #e8f3fa; color: var(--info); }
.legal-status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.legal-status.pending { background: #edf1ef; color: var(--muted); }
.legal-status.processing { background: #e8f3fa; color: var(--info); }
.legal-status.ready { background: #fff3d7; color: #8a5a00; }
.legal-status.active { background: #e3f4ec; color: var(--ok); }
.legal-status.disabled { background: #edf1ef; color: var(--muted); }
.legal-status.error { background: #fff0ec; color: var(--warn); }
.legal-library-table .error-text { max-width: 260px; color: var(--warn); }
.legal-action { min-height: 34px; padding: 7px 11px; white-space: nowrap; }
.legal-upload-dialog {
  width: min(620px, 100%);
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
.legal-upload-dialog-body { padding: 20px; display: grid; gap: 18px; }
.legal-upload-dialog-body p { margin: 0; line-height: 1.65; }
.legal-file-field { display: grid; gap: 8px; font-weight: 700; }
.legal-file-field input {
  width: 100%;
  padding: 12px;
  border: 1px dashed #9eb9ae;
  border-radius: 8px;
  background: #f7faf9;
}
.legal-upload-actions { justify-content: flex-end; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 11px;
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-size: 13px; background: #f7faf9; }
.table-scroll { overflow-x: auto; }
.detail-panel { position: sticky; top: 20px; }
.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  padding: 24px;
  background: rgba(15, 28, 24, .44);
  display: grid;
  place-items: center;
}
.hazard-modal {
  width: min(820px, 100%);
  max-height: min(86vh, 820px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
.modal-head {
  min-height: 58px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h2 {
  margin: 0;
}
.modal-body {
  overflow: auto;
  padding: 16px;
}
.modal-body > h2:first-child {
  margin-top: 0;
}
.empty { padding: 28px; color: var(--muted); text-align: center; }

@media (max-width: 860px) {
  .portal-hero, .admin-layout, .content-grid, .section-management, .grid-management-shell { grid-template-columns: 1fr; }
  .grid-roster-context { grid-template-columns: 1fr; }
  .grid-management-nav { position: static; }
  .grid-nav-scroll { max-height: 360px; }
  .optional-cc-toolbar { grid-template-columns: 1fr 1fr; }
  .legal-library-toolbar { grid-template-columns: 1fr 1fr; }
  .legal-library-toolbar input { grid-column: 1 / -1; }
  .hazard-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-keyword { min-width: 0; }
  .sidebar { position: static; height: auto; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .message-head { display: grid; }
  .message-actions { justify-content: flex-start; }
  .notification-item { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .hazard-filters { grid-template-columns: 1fr; }
  .grid-management-summary, .grid-info-fields { grid-template-columns: 1fr; }
  .grid-info-wide { grid-column: auto; }
  .grid-roster-action { min-width: 250px; }
  .grid-roster-action select { min-width: 170px; }
  .optional-cc-toolbar, .optional-cc-group > div { grid-template-columns: 1fr; }
  .legal-library-toolbar { grid-template-columns: 1fr; }
  .legal-library-toolbar input { grid-column: auto; }
  .modal-backdrop { padding: 12px; }
}
