    :root {
      --bg: #f6f7f9;
      --panel: #fff;
      --ink: #1f2933;
      --muted: #667085;
      --line: #d7dce2;
      --head: #e8eef1;
      --accent: #176c62;
      --warn: #9a5b00;
      --bad: #b42318;
      --soft: #edf7f5;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--ink);
      font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    }
    header {
      background: #123c3a;
      color: #fff;
      padding: 18px 26px;
    }
    h1 { margin: 0; font-size: 22px; letter-spacing: 0; }
    main {
      display: grid;
      grid-template-columns: minmax(360px, 440px) 1fr;
      gap: 18px;
      padding: 18px;
      align-items: start;
    }
    main.view { display: none; }
    main.view.active { display: grid; }
    .tabs {
      display: flex;
      gap: 8px;
      padding: 10px 18px 0;
      background: var(--bg);
    }
    .tab-btn {
      background: #fff;
      color: var(--accent);
      border-color: #b7d9d4;
      font-weight: 700;
    }
    .tab-btn.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    main.quick-tools-page.active {
      display: block;
    }
    .quick-tool-panel {
      min-height: calc(100vh - 150px);
    }
    .quick-tools-body {
      display: grid;
      gap: 14px;
    }
    .tool-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 12px;
    }
    .tool-card {
      display: flex;
      align-items: center;
      gap: 12px;
      min-height: 72px;
      padding: 12px 14px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      color: var(--ink);
      text-align: left;
      box-shadow: none;
    }
    .tool-card:hover {
      border-color: #9fc9c3;
      background: #f8fcfb;
    }
    .tool-card.active {
      border-color: var(--accent);
      background: var(--soft);
      color: var(--ink);
    }
    .tool-card strong {
      display: block;
      font-size: 16px;
      color: #143f3c;
    }
    .tool-card small {
      display: block;
      margin-top: 3px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.35;
    }
    .tool-drawer {
      display: none;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      overflow: hidden;
    }
    .tool-drawer.active {
      display: block;
    }
    .tool-drawer.collapsed > :not(.tool-drawer-head) {
      display: none;
    }
    .tool-drawer-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      background: #fbfcfd;
      min-width: 0;
    }
    .tool-drawer-head h3 {
      margin: 0 0 4px;
      font-size: 18px;
      color: #143f3c;
      letter-spacing: 0;
    }
    .tool-actions {
      display: flex;
      gap: 8px;
      align-items: center;
    }
    .quick-tool-icon {
      width: 42px;
      height: 42px;
      border-radius: 50%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
      background: #fff4f2;
      border: 1px solid #ffd5cf;
      font-size: 24px;
    }
    .inventory-icon {
      background: #eef8f5;
      border-color: #c7e4dd;
    }
    .hormone-icon {
      background: #fff7e8;
      border-color: #efd49e;
      color: #805300;
      font-size: 16px;
      font-weight: 800;
    }
    .control-icon {
      background: var(--soft);
      border-color: #b7d9d4;
      color: var(--accent);
      font-size: 16px;
      font-weight: 800;
    }
    .tool-open-btn {
      min-height: 34px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--accent);
      border-radius: 6px;
      color: var(--accent);
      background: #fff;
      padding: 7px 12px;
      font-weight: 700;
      text-decoration: none;
      white-space: nowrap;
    }
    .quick-tool-frame {
      display: block;
      width: 100%;
      min-height: min(860px, calc(100vh - 250px));
      height: 860px;
      border: 0;
      background: #fff;
    }
    .control-tool-body {
      padding: 16px;
      background: #f7f9fa;
    }
    .control-session-gate {
      display: grid;
      gap: 14px;
      max-width: 920px;
      padding: 16px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .control-session-gate[hidden],
    .control-line-tabs[hidden] {
      display: none;
    }
    .control-session-gate h4,
    .control-workbench h4 {
      margin: 0;
      color: #143f3c;
      font-size: 16px;
    }
    .control-session-gate p {
      margin: 0;
      color: var(--muted);
    }
    .control-auth-heading {
      display: grid;
      gap: 5px;
    }
    .control-auth-options {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      border-top: 1px solid var(--line);
    }
    .control-auth-option {
      display: grid;
      align-content: start;
      gap: 10px;
      min-width: 0;
      padding: 16px 16px 2px 0;
    }
    .control-auth-option + .control-auth-option {
      padding-right: 0;
      padding-left: 16px;
      border-left: 1px solid var(--line);
    }
    .control-auth-option button {
      justify-self: start;
      min-height: 36px;
    }
    .control-admin-field {
      display: grid;
      gap: 5px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .control-admin-field input {
      width: 100%;
      min-height: 38px;
    }
    .control-admin-message {
      min-height: 18px;
      color: var(--muted);
      font-size: 12px;
    }
    .control-admin-message.error {
      color: var(--bad);
    }
    .control-admin-message.success {
      color: var(--good);
    }
    .control-admin-logout[hidden] {
      display: none;
    }
    .control-workbench {
      display: grid;
      grid-template-columns: 174px minmax(0, 1fr);
      grid-template-areas:
        "head head"
        "search search"
        "categories list"
        "tabs list"
        "message message";
      gap: 12px;
      padding: 16px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .control-workbench[hidden] {
      display: none;
    }
    .control-inline-view {
      display: grid;
      gap: 12px;
      min-width: 0;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .control-inline-view[hidden] {
      display: none;
    }
    .control-inline-head {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }
    .control-inline-head > div {
      min-width: 0;
    }
    .control-inline-head h4 {
      margin: 0;
      color: #143f3c;
      font-size: 16px;
      overflow-wrap: anywhere;
    }
    .control-inline-message {
      min-height: 18px;
      color: var(--muted);
      font-size: 12px;
    }
    .control-inline-message.error {
      color: var(--bad);
    }
    .control-inline-frame {
      width: 100%;
      height: min(760px, calc(100dvh - 180px));
      min-height: 620px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
    }
    .control-workbench-head {
      grid-area: head;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-width: 0;
    }
    .control-workbench-head > div {
      min-width: 0;
    }
    .control-workbench-head button {
      flex: 0 0 auto;
      min-height: 36px;
    }
    .control-workbench-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      flex: 0 0 auto;
    }
    .control-search-field {
      grid-area: search;
      display: grid;
      gap: 5px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .control-search-field input {
      width: 100%;
      min-height: 38px;
    }
    .control-category-nav {
      grid-area: categories;
      display: grid;
      align-content: start;
      gap: 6px;
      min-width: 0;
    }
    .control-category-nav button,
    .control-line-tabs button {
      min-height: 36px;
      border: 1px solid #b7d9d4;
      border-radius: 6px;
      background: #fff;
      color: var(--accent);
      box-shadow: none;
      font-weight: 700;
      white-space: normal;
    }
    .control-category-nav button.active,
    .control-line-tabs button.active {
      border-color: var(--accent);
      background: var(--accent);
      color: #fff;
    }
    .control-line-tabs {
      grid-area: tabs;
      display: flex;
      flex-wrap: wrap;
      align-content: start;
      gap: 6px;
      min-width: 0;
    }
    .control-device-list {
      grid-area: list;
      display: grid;
      align-content: start;
      gap: 8px;
      min-width: 0;
      min-height: 240px;
    }
    .control-device-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto auto;
      align-items: center;
      gap: 10px;
      min-height: 64px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fbfcfd;
    }
    .control-device-copy {
      display: grid;
      gap: 4px;
      min-width: 0;
    }
    .control-device-name {
      min-width: 0;
      overflow-wrap: anywhere;
      font-weight: 700;
    }
    .control-device-kind {
      display: block;
      color: var(--muted);
      line-height: 1.4;
      font-size: 12px;
      overflow-wrap: anywhere;
    }
    .control-device-status {
      color: var(--muted);
      white-space: nowrap;
      font-size: 12px;
    }
    .control-device-row button {
      min-width: 64px;
      min-height: 36px;
      white-space: nowrap;
    }
    .control-message {
      grid-area: message;
      min-height: 20px;
      color: var(--muted);
      font-size: 12px;
    }
    .hormone-tool-body {
      display: grid;
      gap: 16px;
      padding: 16px;
      background: #f7f9fa;
    }
    .hormone-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
    .hormone-toolbar .segmented-control button.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    .hormone-source-status,
    .hormone-section,
    .hormone-issues {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .hormone-source-status {
      padding: 12px 14px;
    }
    .hormone-source-list {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px 14px;
      color: var(--muted);
      font-size: 12px;
    }
    .hormone-source-list span {
      min-width: 0;
      overflow-wrap: anywhere;
    }
    .hormone-source-list strong {
      color: var(--ink);
    }
    .hormone-warning,
    .hormone-error {
      margin-top: 10px;
      padding: 9px 10px;
      border-radius: 6px;
    }
    .hormone-warning {
      border: 1px solid #ebcb8b;
      background: #fff8e7;
      color: #714b00;
    }
    .hormone-error {
      border: 1px solid #f1b7b2;
      background: #fff1f0;
      color: var(--bad);
    }
    .hormone-empty-state,
    .hormone-empty-inline {
      padding: 14px;
      color: var(--muted);
    }
    .hormone-section {
      padding: 14px;
    }
    .hormone-section h4 {
      margin: 0 0 12px;
      color: #143f3c;
      font-size: 15px;
    }
    .hormone-kpi-grid {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 9px;
    }
    .hormone-kpi {
      display: grid;
      min-width: 0;
      min-height: 94px;
      padding: 10px 11px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      color: var(--ink);
      text-align: left;
      box-shadow: none;
    }
    .hormone-kpi:hover {
      border-color: #8cbdb6;
      background: var(--soft);
    }
    .hormone-kpi span,
    .hormone-kpi small {
      color: var(--muted);
      font-size: 12px;
    }
    .hormone-kpi strong {
      align-self: center;
      color: var(--accent);
      font-size: 24px;
    }
    .hormone-kpi-alert {
      border-color: #e4c27e;
      background: #fffaf0;
    }
    .hormone-kpi-alert strong {
      color: #8a5900;
    }
    .hormone-cohort-list {
      display: grid;
      gap: 10px;
    }
    .hormone-cohort-card {
      display: grid;
      grid-template-columns: minmax(360px, 1.2fr) minmax(360px, 1fr);
      gap: 12px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .hormone-cohort-main {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 8px;
    }
    .hormone-cohort-main > div {
      display: grid;
      gap: 4px;
      min-width: 0;
      padding: 8px 9px;
      border-left: 3px solid #b7d9d4;
      background: #f8fbfa;
    }
    .hormone-cohort-main span,
    .hormone-stage-grid span,
    .hormone-stage-grid small {
      color: var(--muted);
      font-size: 11px;
    }
    .hormone-cohort-main strong {
      overflow-wrap: anywhere;
      font-size: 16px;
    }
    .hormone-stage-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }
    .hormone-stage-grid button {
      display: grid;
      gap: 2px;
      min-width: 0;
      min-height: 64px;
      padding: 7px 8px;
      border: 1px solid #c5dcd8;
      border-radius: 8px;
      background: #f5faf9;
      color: var(--ink);
      box-shadow: none;
      text-align: left;
    }
    .hormone-stage-grid button:hover {
      border-color: var(--accent);
      background: var(--soft);
    }
    .hormone-stage-grid strong {
      color: var(--accent);
      font-size: 18px;
    }
    .hormone-details {
      grid-column: 1 / -1;
      margin-top: 2px;
      padding: 10px;
      border: 1px solid #cddbd9;
      border-radius: 8px;
      background: #fbfdfd;
    }
    .hormone-details-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 8px;
    }
    .hormone-member-list {
      display: grid;
      gap: 5px;
    }
    .hormone-member-row {
      display: grid;
      grid-template-columns: minmax(110px, 1.1fr) repeat(4, minmax(100px, 1fr)) minmax(140px, 1.5fr);
      gap: 8px;
      align-items: center;
      min-width: 0;
      padding: 7px 8px;
      border-bottom: 1px solid #e5e9ec;
    }
    .hormone-member-row:last-child {
      border-bottom: 0;
    }
    .hormone-member-row > * {
      min-width: 0;
      overflow-wrap: anywhere;
    }
    .hormone-member-row span {
      color: #4d5965;
      font-size: 12px;
    }
    .hormone-flags {
      color: #8a5900 !important;
    }
    .hormone-issues {
      overflow: hidden;
    }
    .hormone-issues summary {
      padding: 12px 14px;
      cursor: pointer;
      color: #143f3c;
      font-weight: 700;
    }
    .hormone-issues[open] summary {
      border-bottom: 1px solid var(--line);
    }
    .hormone-issue-head,
    .hormone-issue-row {
      display: grid;
      grid-template-columns: minmax(120px, 1fr) minmax(100px, .8fr) minmax(180px, 2fr);
      gap: 10px;
      padding: 8px 14px;
    }
    .hormone-issue-head {
      display: block;
      background: #fff8e7;
      color: #714b00;
      font-weight: 700;
    }
    .hormone-issue-row {
      border-top: 1px solid #eceff1;
    }
    .inventory-status {
      margin: 14px 16px 0;
      padding: 10px 12px;
      border: 1px solid #c7d7ee;
      border-radius: 8px;
      background: #f4f8ff;
      color: #31526f;
      font-weight: 700;
    }
    .inventory-status.error {
      border-color: #f3b1aa;
      background: #fff5f4;
      color: var(--bad);
    }
    .inventory-status.ok {
      border-color: #a9d9c0;
      background: #f0fbf4;
      color: #166534;
    }
    .inventory-setup-grid {
      display: grid;
      grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
      gap: 14px;
      padding: 14px 16px 0;
    }
    .inventory-box {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 13px;
      background: #fff;
      margin: 0;
    }
    .inventory-box h3,
    .inventory-section-title {
      margin: 0 0 10px;
      font-size: 16px;
      color: #143f3c;
    }
    .inventory-form-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .inventory-source-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      align-items: end;
    }
    .inventory-active {
      margin: 14px 16px 16px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      overflow: hidden;
    }
    .inventory-active-head {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      padding: 14px;
      border-bottom: 1px solid var(--line);
      background: #fbfcfd;
    }
    .inventory-active-head h3 {
      margin: 0 0 4px;
      font-size: 17px;
      color: #143f3c;
    }
    .inventory-summary {
      display: grid;
      grid-template-columns: repeat(4, minmax(86px, 1fr));
      gap: 8px;
      min-width: 420px;
    }
    .inventory-summary-item {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 8px 10px;
      background: #fff;
    }
    .inventory-summary-item strong {
      display: block;
      color: var(--accent);
      font-size: 20px;
      line-height: 1.1;
    }
    .inventory-summary-item span {
      display: block;
      margin-top: 3px;
      color: var(--muted);
      font-size: 12px;
    }
    .inventory-scan-row {
      display: grid;
      grid-template-columns: minmax(180px, 1fr) minmax(150px, .7fr) auto;
      gap: 10px;
      align-items: end;
      padding: 14px;
    }
    .inventory-task-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 12px 14px 0;
    }
    .inventory-task-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .inventory-row-filter {
      flex: 0 0 auto;
    }
    #inventoryScanMessage {
      padding: 0 14px 12px;
    }
    .inventory-visible-summary {
      padding: 0 14px 10px;
      color: #475467;
    }
    .inventory-table-wrap {
      overflow-x: auto;
      border-top: 1px solid var(--line);
      max-height: 62vh;
      overflow-y: auto;
    }
    .inventory-table {
      width: 100%;
      border-collapse: collapse;
      min-width: 860px;
    }
    .inventory-table th,
    .inventory-table td {
      border-bottom: 1px solid var(--line);
      padding: 9px 10px;
      text-align: left;
      white-space: nowrap;
      vertical-align: middle;
    }
    .inventory-table th {
      background: #f2f4f7;
      color: #475467;
      font-weight: 700;
      position: sticky;
      top: 0;
      z-index: 1;
    }
    .inventory-table tr.inventory-row-current {
      outline: 2px solid #88bdf7;
      outline-offset: -2px;
      background: #f4f9ff;
    }
    .inventory-table tr.inventory-row-checked td:first-child {
      color: #166534;
      font-weight: 700;
    }
    .inventory-table tr.inventory-exception-row {
      background: #fff7cf;
    }
    .inventory-pen-input {
      width: 110px;
      min-height: 32px;
    }
    .inventory-load-more {
      display: flex;
      justify-content: center;
      padding: 10px 14px;
      border-top: 1px solid var(--line);
    }
    .inventory-load-more button {
      min-width: 140px;
    }
    .inventory-section-title {
      margin: 14px;
    }
    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 10px 30px rgba(31,41,51,.08);
      overflow: hidden;
    }
    .panel h2 {
      margin: 0;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      background: #fbfcfd;
      font-size: 16px;
    }
    .body { padding: 14px 16px 16px; }
    .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
    label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
    input, button, select { font: inherit; }
    input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="file"] {
      width: 100%;
      min-height: 34px;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 6px 8px;
      background: #fff;
      color: var(--ink);
    }
    input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
    .checkline {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 34px;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 6px 8px;
      background: #fff;
    }
    button {
      min-height: 34px;
      border: 1px solid var(--accent);
      border-radius: 6px;
      background: var(--accent);
      color: #fff;
      padding: 7px 12px;
      cursor: pointer;
    }
    button.secondary { background: #fff; color: var(--accent); }
    button.muted { background: #f9fafb; color: var(--ink); border-color: var(--line); }
    button.danger { background: #fff; color: #c2410c; border-color: #c2410c; }
    button.toggle-active { background: #edf7f5; color: var(--accent); border-color: #76b7ad; }
    button:disabled { opacity: .55; cursor: not-allowed; }
    .divider { border-top: 1px solid var(--line); margin: 15px 0; }
    .btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
    .plan-toolbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 12px;
    }
    .plan-toolbar .btn-row { margin-top: 0; }
    .segmented-control {
      display: inline-flex;
      gap: 4px;
      padding: 3px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .segmented-control button {
      min-height: 30px;
      border-color: transparent;
      background: transparent;
      color: var(--muted);
      padding: 5px 10px;
    }
    .segmented-control button.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .units-tools { display: grid; grid-template-columns: 1fr 90px 90px; gap: 8px; margin-bottom: 10px; }
    .table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-height: 380px; }
    table { width: 100%; border-collapse: collapse; }
    th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
    th { position: sticky; top: 0; z-index: 1; background: var(--head); color: #344054; font-size: 12px; }
    td input[type="text"], td input[type="number"], td input[type="date"] { min-height: 30px; min-width: 88px; padding: 4px 6px; }
    .unit-name { min-width: 82px; }
    .stats { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
    .stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fbfcfd; }
    .stat .num { color: var(--accent); font-weight: 780; font-size: 22px; line-height: 1.1; }
    .stat .label { margin-top: 4px; color: var(--muted); font-size: 12px; }
    .warnings { display: none; border: 1px solid #f1c27d; background: #fff8ec; color: var(--warn); border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; }
    .sentence { font-weight: 740; color: #143f3c; }
    .small { color: var(--muted); font-size: 12px; line-height: 1.45; }
    .sync-status {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfd;
      color: var(--muted);
      padding: 8px 10px;
      margin-bottom: 12px;
      font-size: 12px;
      line-height: 1.45;
    }
    .sync-status.ok { border-color: #9ed7c3; background: #eefaf6; color: #176c62; }
    .sync-status.warn { border-color: #f1c27d; background: #fff8ec; color: #9a5b12; }
    .sync-status.error { border-color: #f4b0a1; background: #fff1ee; color: #b42318; }
    .auto-sync-row {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      margin: 0 0 12px;
    }
    .auto-sync-row button {
      margin: 0;
      min-width: 118px;
    }
    .auto-sync-status.ok { color: #176c62; font-weight: 680; }
    .auto-sync-status.warn { color: #9a5b12; font-weight: 680; }
    .auto-sync-status.error { color: #b42318; font-weight: 680; }
    .pill { display: inline-flex; align-items: center; min-height: 22px; border-radius: 999px; padding: 1px 8px; background: var(--soft); color: #0f766e; border: 1px solid #b7d9d4; font-size: 12px; white-space: nowrap; }
    .pill.bad { color: var(--bad); background: #fff1f0; border-color: #ffc9c2; }
    .pill.warn { color: var(--warn); background: #fff8ec; border-color: #f1c27d; }
    .empty { padding: 34px 12px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 8px; background: #fbfcfd; }
    .detail-box { background: #fbfcfd; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 320px; overflow: auto; }
    .detail-box table th { position: static; }
    .modal.wean-modal {
      width: min(1120px, calc(100vw - 32px));
    }
    .plan-wean-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 14px;
    }
    .plan-wean-section {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      overflow: hidden;
    }
    .plan-wean-section h4 {
      margin: 0;
      padding: 11px 12px;
      border-bottom: 1px solid var(--line);
      color: #143f3c;
      font-size: 14px;
    }
    .plan-wean-table-wrap {
      max-height: min(62vh, 620px);
      overflow: auto;
    }
    .plan-wean-table th,
    .plan-wean-table td {
      white-space: nowrap;
      font-size: 12px;
    }
    .plan-wean-table .rank-cell {
      width: 38px;
      color: var(--muted);
      font-weight: 760;
    }
    .plan-wean-table .unit-cell {
      font-weight: 800;
      color: #143f3c;
    }
    .plan-wean-table .soon { color: var(--warn); font-weight: 800; }
    .plan-wean-table .overdue { color: var(--bad); font-weight: 800; }
    .plan-wean-table .missing { color: var(--muted); }
    main.rate-page.active {
      grid-template-columns: 1fr;
    }
    .rate-filter-bar {
      display: grid;
      grid-template-columns: 180px 150px repeat(2, minmax(140px, 170px));
      gap: 10px;
      align-items: end;
      margin-bottom: 14px;
    }
    .unit-rate-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
      gap: 10px;
      margin: 14px 0;
    }
    .unit-rate-card {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: rgba(255,255,255,.78);
      padding: 12px;
      min-height: 132px;
      box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
    }
    .unit-rate-card.good { border-color: #94d1c8; background: #f0fbf8; }
    .unit-rate-card.mid { border-color: #d7dce2; background: #fbfcfd; }
    .unit-rate-card.low { border-color: #f1c27d; background: #fff8ec; }
    .unit-rate-card.small-sample { border-color: #f1c27d; background: #fff8ec; }
    .unit-rate-card.empty { color: var(--muted); background: #f8fafc; }
    .unit-rate-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: baseline;
      margin-bottom: 8px;
      font-weight: 800;
      color: #143f3c;
    }
    .unit-rate-head span {
      color: var(--muted);
      font-size: 12px;
      font-weight: 650;
    }
    .unit-rate-main {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .unit-rate-main strong {
      display: block;
      color: #007aff;
      font-size: 24px;
      line-height: 1.05;
    }
    .unit-rate-main span {
      color: var(--muted);
      font-size: 12px;
    }
    .unit-rate-meta {
      margin-top: 9px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.5;
    }
    .sample-note {
      display: inline-flex;
      align-items: center;
      width: fit-content;
      border: 1px solid #f1c27d;
      border-radius: 999px;
      background: rgba(255, 248, 236, .95);
      color: var(--warn);
      padding: 2px 8px;
      margin-top: 7px;
      font-size: 12px;
      font-weight: 750;
    }
    .rate-table-wrap {
      max-height: 620px;
    }
    .rate-table-wrap th,
    .rate-table-wrap td {
      white-space: nowrap;
    }
    .rate-badge {
      display: inline-flex;
      align-items: center;
      min-height: 22px;
      padding: 1px 8px;
      border-radius: 999px;
      border: 1px solid #b7d9d4;
      background: #edf7f5;
      color: var(--accent);
      font-size: 12px;
      font-weight: 750;
    }
    .rate-badge.warn { border-color: #f1c27d; background: #fff8ec; color: var(--warn); }
    .rate-badge.bad { border-color: #ffc9c2; background: #fff1f0; color: var(--bad); }
    main.report-page.active {
      grid-template-columns: 1fr;
    }
    .report-filter-bar {
      display: grid;
      grid-template-columns: repeat(2, 150px) repeat(3, minmax(150px, 180px));
      gap: 10px;
      align-items: end;
      margin-bottom: 14px;
    }
    .report-section-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(360px, 1fr));
      gap: 14px;
    }
    .report-card {
      border: 1px solid var(--line);
      border-radius: 12px;
      background: rgba(255,255,255,.82);
      box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
      overflow: hidden;
    }
    .report-card-wide {
      grid-column: 1 / -1;
    }
    .report-card h3 {
      margin: 0;
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      color: #143f3c;
      font-size: 16px;
    }
    .report-card-body {
      padding: 12px 14px 14px;
    }
    .report-metrics {
      display: grid;
      grid-template-columns: repeat(3, minmax(100px, 1fr));
      gap: 8px;
      margin-bottom: 10px;
    }
    .report-metric {
      border: 1px solid #dce6ea;
      border-radius: 10px;
      background: #fbfcfd;
      padding: 8px 10px;
      min-height: 66px;
    }
    .report-metric strong {
      display: block;
      color: #0f766e;
      font-size: 22px;
      line-height: 1.1;
    }
    .report-metric span {
      color: var(--muted);
      font-size: 12px;
    }
    .report-table {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
      margin-top: 8px;
    }
    .report-table table th,
    .report-table table td {
      font-size: 12px;
      white-space: nowrap;
    }
    main.pig-archive-page.active {
      grid-template-columns: minmax(320px, 420px) 1fr;
    }
    .pig-login-grid,
    .pig-query-grid {
      display: grid;
      gap: 10px;
    }
    .pig-query-grid {
      grid-template-columns: 1fr auto;
      align-items: end;
    }
    .pig-session-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 12px;
    }
    .pig-session-row .pill {
      flex-shrink: 0;
    }
    .pig-captcha-box[hidden] {
      display: none;
    }
    .pig-captcha-row {
      display: grid;
      grid-template-columns: minmax(90px, 1fr) 112px auto;
      gap: 8px;
      align-items: center;
    }
    .pig-captcha-row img {
      width: 112px;
      height: 42px;
      border: 1px solid var(--line);
      border-radius: 8px;
      object-fit: cover;
      background: #fff;
    }
    .pig-captcha-row button {
      min-height: 42px;
      white-space: nowrap;
    }
    .pig-archive-hero {
      display: grid;
      grid-template-columns: repeat(5, minmax(130px, 1fr));
      gap: 10px;
      margin-bottom: 12px;
    }
    .pig-archive-stat {
      min-height: 76px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #fbfcfd;
      padding: 10px 12px;
    }
    .pig-archive-stat strong {
      display: block;
      color: #0f766e;
      font-size: 20px;
      line-height: 1.15;
      word-break: break-word;
    }
    .pig-archive-stat span {
      display: block;
      margin-top: 5px;
      color: var(--muted);
      font-size: 12px;
    }
    .pig-archive-tabs {
      display: inline-flex;
      gap: 4px;
      padding: 3px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      margin-bottom: 12px;
    }
    .pig-archive-tabs button {
      min-height: 30px;
      border-color: transparent;
      background: transparent;
      color: var(--muted);
      padding: 5px 10px;
      box-shadow: none;
    }
    .pig-archive-tabs button.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    .pig-archive-fields {
      display: grid;
      grid-template-columns: repeat(3, minmax(180px, 1fr));
      gap: 10px;
    }
    .pig-field {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(255,255,255,.76);
      padding: 9px 10px;
      min-height: 62px;
    }
    .pig-field span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 4px;
    }
    .pig-field strong {
      display: block;
      color: var(--ink);
      font-size: 14px;
      word-break: break-word;
    }
    .pig-archive-table {
      max-height: 420px;
    }
    .pig-archive-table td,
    .pig-archive-table th {
      white-space: nowrap;
    }
    .pig-archive-note {
      color: var(--muted);
      font-size: 12px;
      margin: 8px 0;
    }
    .pig-archive-detail-title {
      color: #143f3c;
      font-size: 13px;
      font-weight: 800;
      margin: 12px 0 6px;
    }
    .report-trend-details {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #fff;
      margin-top: 10px;
      overflow: hidden;
    }
    .report-trend-details summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      cursor: pointer;
      padding: 10px 12px;
      color: #143f3c;
      font-size: 13px;
      font-weight: 800;
      list-style: none;
    }
    .report-trend-details summary::-webkit-details-marker {
      display: none;
    }
    .report-trend-details summary::after {
      content: "展开";
      color: #0f766e;
      font-size: 12px;
      font-weight: 750;
    }
    .report-trend-details[open] summary {
      border-bottom: 1px solid var(--line);
    }
    .report-trend-details[open] summary::after {
      content: "收起";
    }
    .report-trend-body {
      display: grid;
      gap: 10px;
      padding: 10px 12px 12px;
    }
    .report-chart {
      min-height: 220px;
      border: 1px solid #dce6ea;
      border-radius: 10px;
      background: #fbfcfd;
      padding: 8px;
      overflow-x: auto;
    }
    .report-chart svg {
      display: block;
      width: 100%;
      min-width: 540px;
      height: 220px;
    }
    .report-chart-title {
      color: var(--muted);
      font-size: 12px;
      margin: 0 0 4px;
    }
    .report-note {
      border: 1px solid #f1c27d;
      background: #fff8ec;
      color: var(--warn);
      border-radius: 10px;
      padding: 9px 11px;
      margin-top: 10px;
      line-height: 1.55;
    }
    .report-note.ok {
      border-color: #94d1c8;
      background: #f0fbf8;
      color: var(--accent);
    }
    .missing-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 10px;
      margin-top: 12px;
    }
    .missing-item {
      border: 1px dashed #d7dce2;
      border-radius: 10px;
      padding: 10px 12px;
      background: #fbfcfd;
      color: var(--muted);
    }
    .missing-item strong {
      display: block;
      color: var(--ink);
      margin-bottom: 4px;
    }
    .layout-view {
      grid-template-columns: minmax(320px, 380px) minmax(960px, 1fr);
      transition: grid-template-columns .18s ease;
      overflow-x: auto;
    }
    .layout-view.sources-collapsed {
      grid-template-columns: 64px minmax(960px, 1fr);
    }
    .source-settings-panel {
      align-self: start;
      min-width: 0;
    }
    .collapsible-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--line);
      background: #fbfcfd;
    }
    .collapsible-head h2 {
      padding: 0;
      border: 0;
      background: transparent;
      flex: 1;
    }
    .collapse-toggle {
      min-height: 30px;
      padding: 5px 10px;
      white-space: nowrap;
    }
    .source-settings-panel.collapsed .collapsible-body {
      display: none;
    }
    .source-settings-panel.collapsed .collapsible-head {
      min-height: 170px;
      padding: 10px 6px;
      display: grid;
      place-items: center;
      align-content: start;
      gap: 10px;
    }
    .source-settings-panel.collapsed .collapsible-head h2 {
      writing-mode: vertical-rl;
      text-orientation: mixed;
      white-space: nowrap;
      font-size: 14px;
      line-height: 1.1;
    }
    .source-settings-panel.collapsed .collapse-toggle {
      width: 46px;
      min-width: 0;
      padding: 4px 5px;
      font-size: 12px;
    }
    .source-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .source-card {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 10px;
      background: #fbfcfd;
    }
    .source-card strong { display: block; margin-bottom: 8px; color: #143f3c; }
    .source-card label {
      display: flex;
      align-items: center;
      gap: 7px;
      margin: 7px 0;
      color: var(--ink);
      font-size: 13px;
    }
    .farm-map {
      min-height: 760px;
      padding: 22px;
      background:
        repeating-linear-gradient(90deg, rgba(31,41,51,.05) 0 1px, transparent 1px 64px),
        linear-gradient(#fff, #f7faf9);
      border-top: 1px solid var(--line);
      overflow: auto;
    }
    .map-grid {
      min-width: 1260px;
      display: grid;
      grid-template-columns: 310px 270px 270px 310px 150px;
      gap: 24px;
      align-items: stretch;
    }
    .barn {
      border: 2px solid #46615d;
      background: rgba(255,255,255,.84);
      border-radius: 8px;
      min-height: 360px;
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      color: #31504c;
      font-size: 22px;
      font-weight: 780;
      writing-mode: vertical-rl;
      letter-spacing: 0;
    }
    .barn.placeholder {
      color: #98a2b3;
      border-style: dashed;
      background: rgba(255,255,255,.55);
    }
    .barn.breeding-barn {
      writing-mode: horizontal-tb;
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-start;
      padding: 16px;
      gap: 12px;
      text-align: left;
      font-size: 14px;
      font-weight: 400;
    }
    .barn-title {
      color: #143f3c;
      font-size: 24px;
      font-weight: 850;
      text-align: center;
      white-space: nowrap;
      padding-bottom: 10px;
      border-bottom: 1px solid #c8d5d2;
    }
    .breeding-summary {
      display: grid;
      gap: 9px;
    }
    .plan-field {
      display: grid;
      gap: 5px;
    }
    .plan-field label {
      margin: 0;
      color: var(--muted);
      font-size: 12px;
    }
    .plan-warning {
      display: none;
      border: 1px solid #f1c27d;
      border-radius: 8px;
      background: #fff8ec;
      color: var(--warn);
      padding: 8px 10px;
      font-size: 12px;
      line-height: 1.45;
      text-align: left;
      white-space: normal;
      word-break: break-word;
    }
    .plan-warning.ok {
      border-color: #b7d9d4;
      background: #edf7f5;
      color: #0f766e;
    }
    .plan-warning.active { display: block; }
    .summary-main {
      border: 1px solid #b7d9d4;
      border-radius: 8px;
      background: #edf7f5;
      padding: 10px;
      text-align: center;
    }
    .summary-main .num {
      display: block;
      color: var(--accent);
      font-size: 30px;
      font-weight: 850;
      line-height: 1.1;
    }
    .summary-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      border-bottom: 1px solid #e4ebe9;
      padding: 5px 0;
      color: var(--muted);
      font-size: 12px;
    }
    .summary-row strong {
      color: #143f3c;
      font-size: 13px;
    }
    .pregnancy-panel {
      margin-top: 6px;
      border-top: 1px solid #d8e3e0;
      padding-top: 10px;
      display: grid;
      gap: 8px;
    }
    .wean-breed-panel {
      margin-top: 6px;
      border-top: 1px solid #d8e3e0;
      padding-top: 10px;
      display: grid;
      gap: 8px;
    }
    .wean-breed-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      color: #143f3c;
      font-weight: 800;
      font-size: 13px;
    }
    .wean-breed-title span {
      color: var(--muted);
      font-size: 11px;
      font-weight: 650;
    }
    .wean-breed-controls {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }
    .wean-breed-controls select,
    .wean-breed-controls input {
      min-height: 32px;
      padding: 5px 7px;
      font-size: 12px;
    }
    .wean-breed-controls .wide { grid-column: 1 / -1; }
    .wean-breed-kpis {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }
    .wean-breed-kpi {
      min-width: 0;
      border: 1px solid #d4e3df;
      border-radius: 8px;
      background: rgba(255,255,255,.72);
      padding: 9px 8px;
      text-align: center;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
    }
    .wean-breed-kpi strong {
      display: block;
      color: var(--accent);
      font-size: 22px;
      line-height: 1.05;
      font-weight: 850;
      white-space: nowrap;
    }
    .wean-breed-kpi span {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.25;
    }
    .wean-breed-foot {
      display: grid;
      gap: 4px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.35;
      text-align: left;
    }
    .wean-breed-foot strong { color: #143f3c; }
    .pregnancy-title {
      color: #143f3c;
      font-weight: 800;
      font-size: 13px;
    }
    .pregnancy-controls {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }
    .pregnancy-controls select,
    .pregnancy-controls input {
      min-height: 32px;
      padding: 5px 7px;
      font-size: 12px;
    }
    .pregnancy-controls .wide { grid-column: 1 / -1; }
    .pregnancy-kpis {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
    }
    .pregnancy-kpi {
      border: 1px solid #d8e3e0;
      border-radius: 8px;
      background: #fff;
      padding: 7px 6px;
      text-align: center;
      min-width: 0;
    }
    .pregnancy-kpi strong {
      display: block;
      color: #143f3c;
      font-size: 18px;
      line-height: 1.15;
    }
    .pregnancy-kpi span {
      display: block;
      color: var(--muted);
      font-size: 11px;
      margin-top: 2px;
    }
    .pregnancy-details {
      margin-top: 2px;
      background: #fff;
    }
    .pregnancy-details summary {
      min-height: 34px;
      padding: 7px 9px;
      font-size: 12px;
    }
    .pregnancy-chart-tools {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
      align-items: center;
      margin-bottom: 8px;
    }
    .pregnancy-chart-tools select {
      min-height: 30px;
      padding: 5px 7px;
      font-size: 12px;
    }
    .pregnancy-chart {
      min-height: 220px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      padding: 8px;
      overflow: hidden;
    }
    .pregnancy-chart.zoomable {
      cursor: zoom-in;
    }
    .pregnancy-chart svg {
      width: 100%;
      height: 220px;
      display: block;
    }
    .pregnancy-chart-scroll {
      overflow-x: auto;
      overflow-y: hidden;
      padding-bottom: 6px;
      scrollbar-gutter: stable;
      overscroll-behavior-x: contain;
      scrollbar-color: #8fb9b3 #edf4f2;
      scrollbar-width: thin;
    }
    .pregnancy-chart-scroll svg {
      max-width: none;
    }
    .pregnancy-chart-scroll::-webkit-scrollbar {
      height: 10px;
    }
    .pregnancy-chart-scroll::-webkit-scrollbar-track {
      background: #edf4f2;
      border-radius: 999px;
    }
    .pregnancy-chart-scroll::-webkit-scrollbar-thumb {
      background: #8fb9b3;
      border-radius: 999px;
      border: 2px solid #edf4f2;
    }
    .pregnancy-zoom-btn {
      min-height: 28px;
      padding: 4px 10px;
      border-color: #b7d9d4;
      background: #fff;
      color: var(--accent);
      font-size: 12px;
    }
    .modal.chart-modal {
      width: min(1120px, calc(100vw - 32px));
    }
    .chart-modal .modal-body {
      padding: 16px;
    }
    .chart-subtitle {
      color: var(--muted);
      font-size: 12px;
      margin-top: 3px;
    }
    .pregnancy-chart-large {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      padding: 12px;
      min-height: 420px;
      overflow: hidden;
    }
    .pregnancy-chart-large svg {
      width: 100%;
      height: min(62vh, 460px);
      display: block;
    }
    .pregnancy-rank-details {
      margin-top: 8px;
      background: #fff;
    }
    .pregnancy-rank-list {
      display: grid;
      gap: 9px;
    }
    .rank-row {
      display: grid;
      gap: 5px;
    }
    .rank-head {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      font-size: 12px;
      color: var(--muted);
    }
    .rank-head strong {
      color: #143f3c;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .rank-bar-track {
      height: 16px;
      border-radius: 999px;
      background: #eef2f6;
      overflow: hidden;
      border: 1px solid #d8e3e0;
    }
    .rank-bar-fill {
      height: 100%;
      display: flex;
      min-width: 2px;
      border-radius: inherit;
      overflow: hidden;
    }
    .rank-segment {
      height: 100%;
      min-width: 2px;
    }
    .rank-counts {
      display: flex;
      gap: 7px;
      flex-wrap: wrap;
      color: var(--muted);
      font-size: 11px;
    }
    .pregnancy-legend {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      color: var(--muted);
      font-size: 11px;
      margin-bottom: 6px;
    }
    .legend-dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      display: inline-block;
      margin-right: 4px;
      vertical-align: middle;
    }
    .summary-empty {
      margin-top: 24px;
      color: var(--muted);
      text-align: center;
      font-size: 13px;
      line-height: 1.55;
    }
    .farrowing-block {
      display: grid;
      grid-template-columns: 132px 132px;
      gap: 10px 16px;
      align-content: start;
      justify-content: center;
      border: 2px solid #314d49;
      border-radius: 8px;
      padding: 16px 14px;
      background: rgba(255,255,255,.9);
      position: relative;
    }
    .farrowing-title {
      grid-column: 1 / -1;
      text-align: center;
      font-weight: 800;
      color: #143f3c;
      margin-bottom: 4px;
    }
    .aisle {
      grid-column: 1 / -1;
      min-height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--muted);
      border-top: 1px dashed #aab7b4;
      border-bottom: 1px dashed #aab7b4;
      margin: 2px 0;
      font-size: 12px;
    }
    .unit-tile {
      min-height: 112px;
      border: 1px solid #8aa6a1;
      border-radius: 6px;
      background: #fff;
      color: #1f2933;
      cursor: pointer;
      padding: 8px;
      text-align: left;
    }
    .unit-tile:hover { outline: 3px solid rgba(23,108,98,.18); }
    .unit-tile .unit-no { font-weight: 850; font-size: 20px; color: #143f3c; }
    .unit-tile .unit-meta { display: grid; gap: 3px; font-size: 12px; color: #344054; line-height: 1.25; margin-top: 5px; }
    .unit-tile .unit-line { display: flex; justify-content: space-between; gap: 6px; }
    .unit-tile .unit-line span:first-child { color: #667085; }
    .unit-tile .unit-line strong { color: #143f3c; font-weight: 750; }
    .unit-tile.ready { background: #eefaf6; border-color: #5bb696; }
    .unit-tile.future { background: #fff8ec; border-color: #f1c27d; }
    .unit-tile.missing { background: #f8fafc; border-color: #cbd5e1; }
    .unit-tile.wean-far { background: #fff9e8; border-color: #f4d695; }
    .unit-tile.wean-14 { background: #ffedbd; border-color: #edc96f; }
    .unit-tile.wean-7 { background: #ffd889; border-color: #e8a837; }
    .unit-tile.wean-3 { background: #f8b85f; border-color: #d88418; }
    .unit-tile.wean-today,
    .unit-tile.wean-overdue { background: #9f4512; border-color: #78350f; color: #fff; }
    .unit-tile.wean-today .unit-no,
    .unit-tile.wean-overdue .unit-no,
    .unit-tile.wean-today .unit-line span,
    .unit-tile.wean-overdue .unit-line span,
    .unit-tile.wean-today .unit-line strong,
    .unit-tile.wean-overdue .unit-line strong { color: #fff; }
    .unit-tile.disabled {
      background: #e5e7eb;
      border-color: #9ca3af;
      color: #667085;
      opacity: .86;
    }
    .unit-tile.disabled-window {
      background: #eef2f6;
      border-color: #94a3b8;
      box-shadow: inset 0 0 0 2px rgba(100,116,139,.18);
    }
    .unit-tile.disabled .unit-no,
    .unit-tile.disabled .unit-line span,
    .unit-tile.disabled .unit-line strong { color: #667085; }
    .unit-tile.foster { box-shadow: inset 0 0 0 2px #d92d20; }
    .map-note {
      margin-top: 10px;
      color: var(--muted);
      font-size: 12px;
    }
    .wean-sequence-panel {
      min-width: 1260px;
      margin-top: 16px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(255,255,255,.86);
      overflow: hidden;
    }
    .wean-sequence-panel > summary {
      cursor: pointer;
      padding: 13px 16px;
      font-weight: 800;
      color: #143f3c;
      border-bottom: 1px solid var(--line);
    }
    .wean-sequence-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 14px;
      padding: 14px;
    }
    .wean-sequence-card h3 {
      margin: 0 0 8px;
      font-size: 15px;
      color: #143f3c;
    }
    .wean-seq-list {
      display: grid;
      gap: 6px;
      max-height: 430px;
      overflow: auto;
      padding-right: 4px;
    }
    .wean-seq-row {
      display: grid;
      grid-template-columns: 34px 62px 78px 84px 76px 88px;
      gap: 8px;
      align-items: center;
      min-height: 38px;
      padding: 7px 8px;
      border: 1px solid rgba(203,213,225,.72);
      border-radius: 8px;
      background: rgba(248,250,252,.86);
      font-size: 12px;
    }
    .wean-seq-row strong { color: #143f3c; }
    .wean-seq-row .rank {
      width: 24px;
      height: 24px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: #e8f5f2;
      color: #176c62;
      font-weight: 850;
    }
    .wean-seq-row.soon {
      background: #fff8e5;
      border-color: #f4c66f;
    }
    .wean-seq-row.overdue {
      background: #fff1f0;
      border-color: #ffb4a8;
    }
    .wean-seq-row.missing {
      color: var(--muted);
      background: rgba(242,244,247,.78);
    }
    .wean-seq-empty {
      padding: 18px;
      color: var(--muted);
      border: 1px dashed var(--line);
      border-radius: 8px;
      font-size: 13px;
    }
    .modal-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(15,23,42,.38);
      align-items: flex-start;
      justify-content: center;
      padding: 16px;
      overflow: auto;
      z-index: 50;
    }
    .modal-backdrop.active { display: flex; }
    .modal {
      width: min(760px, calc(100vw - 32px));
      max-height: calc(100vh - 32px);
      background: #fff;
      border-radius: 8px;
      border: 1px solid var(--line);
      box-shadow: 0 20px 60px rgba(15,23,42,.24);
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }
    .modal-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 13px 16px;
      border-bottom: 1px solid var(--line);
      background: #fbfcfd;
    }
    .modal-head h3 { margin: 0; font-size: 16px; }
    .modal-body {
      padding: 14px 16px 16px;
      overflow: auto;
      overscroll-behavior: contain;
    }
    .modal-actions {
      position: sticky;
      bottom: -16px;
      display: flex;
      gap: 8px;
      justify-content: flex-end;
      margin: 14px -16px -16px;
      padding: 12px 16px 16px;
      background: #fff;
      border-top: 1px solid var(--line);
    }
    .advanced-details {
      margin-top: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfd;
      overflow: hidden;
    }
    .advanced-details summary {
      min-height: 40px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 9px 12px;
      color: #143f3c;
      font-weight: 760;
      list-style: none;
    }
    .advanced-details summary::-webkit-details-marker { display: none; }
    .advanced-details summary::after {
      content: "展开";
      color: var(--accent);
      font-weight: 700;
      font-size: 12px;
      white-space: nowrap;
    }
    .advanced-details[open] summary::after { content: "收起"; }
    .advanced-details[open] summary {
      border-bottom: 1px solid var(--line);
    }
    .advanced-body { padding: 12px; }
    .planning-parameters-heading {
      display: grid;
      gap: 3px;
      min-width: 0;
    }
    .planning-parameters-summary {
      color: var(--muted);
      font-size: 12px;
      font-weight: 600;
      line-height: 1.45;
      overflow-wrap: anywhere;
    }
    .planning-parameters-body {
      min-width: 0;
      max-width: 100%;
    }
    .history-planning-controls,
    .history-metric-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    .history-planning-controls > div,
    .history-metric-grid > section {
      min-width: 0;
    }
    .history-planning-controls select {
      width: 100%;
      max-width: 100%;
      padding: 6px 28px 6px 8px;
    }
    .history-planning-status {
      min-width: 0;
      margin: 10px 0;
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 8px 10px;
      background: #fff;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.5;
      overflow-wrap: anywhere;
    }
    .history-planning-status.is-available {
      border-color: #9ed7c3;
      background: #eefaf6;
      color: #176c62;
    }
    .history-planning-status.is-partial,
    .history-planning-status.is-fallback,
    .history-planning-status.is-missing {
      border-color: #f1c27d;
      background: #fff8ec;
      color: var(--warn);
    }
    .history-planning-status.is-stale {
      border-color: #f4b0a1;
      background: #fff1ee;
      color: var(--bad);
    }
    .history-metric-card {
      min-width: 0;
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 12px;
      background: rgba(255,255,255,.72);
    }
    .history-metric-card-head,
    .history-metric-row-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      min-width: 0;
    }
    .history-metric-card-head {
      color: #143f3c;
    }
    .history-readonly-badge,
    .history-source-badge {
      display: inline-flex;
      align-items: center;
      min-height: 22px;
      border: 1px solid #b7d9d4;
      border-radius: 999px;
      padding: 1px 7px;
      background: var(--soft);
      color: #0f766e;
      font-size: 11px;
      font-weight: 700;
      white-space: nowrap;
    }
    .history-source-badge.is-fallback {
      border-color: #f1c27d;
      background: #fff8ec;
      color: var(--warn);
    }
    .history-metric-overall {
      display: flex;
      flex-wrap: wrap;
      gap: 4px 10px;
      margin-top: 8px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.45;
    }
    .history-metric-rows {
      display: grid;
      gap: 8px;
      margin-top: 10px;
    }
    .history-metric-row {
      min-width: 0;
      border-top: 1px solid var(--line);
      padding-top: 8px;
    }
    .history-metric-row-head strong,
    .history-metric-used,
    .history-metric-evidence,
    .history-metric-coverage,
    .history-metric-reason {
      overflow-wrap: anywhere;
    }
    .history-metric-row-head strong {
      font-size: 12px;
    }
    .history-metric-used {
      margin-top: 5px;
      color: var(--accent);
      font-size: 14px;
      font-weight: 760;
    }
    .history-metric-evidence,
    .history-metric-coverage,
    .history-metric-reason {
      margin-top: 3px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.45;
    }
    .history-metric-reason {
      color: var(--warn);
    }
    .history-fallback-field label::after {
      content: " · 样本不足时备用";
      color: var(--warn);
    }
    .advanced-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }
    .death-summary {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
      margin-bottom: 10px;
    }
    .death-kpi {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      padding: 8px 10px;
      min-width: 0;
    }
    .death-kpi strong {
      display: block;
      color: var(--accent);
      font-size: 18px;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .death-kpi span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      margin-top: 3px;
    }
    .death-reason-tabs {
      display: flex;
      gap: 6px;
      overflow-x: auto;
      padding-bottom: 4px;
      margin: 4px 0 10px;
    }
    .death-reason-tabs button {
      min-height: 28px;
      padding: 4px 9px;
      border-color: #b7d9d4;
      background: #fff;
      color: var(--accent);
      white-space: nowrap;
      font-size: 12px;
    }
    .death-reason-tabs button.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    .death-chart {
      min-height: 210px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      padding: 8px;
      margin-bottom: 10px;
      overflow: hidden;
    }
    .death-chart svg {
      width: 100%;
      height: 210px;
      display: block;
    }
    .death-table-wrap {
      max-height: 240px;
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
    }
    .death-table-wrap table th {
      position: sticky;
      top: 0;
    }

    :root {
      --bg: #f5f5f7;
      --panel: rgba(255,255,255,.82);
      --ink: #1d1d1f;
      --muted: #6e6e73;
      --line: rgba(60,60,67,.16);
      --head: rgba(242,242,247,.92);
      --accent: #007aff;
      --warn: #b25a00;
      --bad: #d70015;
      --soft: #eef6ff;
      --apple-green: #248a6b;
      --shadow: 0 18px 45px rgba(0,0,0,.08);
      --shadow-soft: 0 8px 24px rgba(0,0,0,.06);
    }
    html {
      background: var(--bg);
    }
    body {
      min-height: 100vh;
      background:
        radial-gradient(circle at 16% 0%, rgba(0,122,255,.08), transparent 26%),
        radial-gradient(circle at 92% 14%, rgba(52,199,89,.08), transparent 28%),
        linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 42%, #f2f2f7 100%);
      color: var(--ink);
      font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
      -webkit-font-smoothing: antialiased;
    }
    header {
      position: sticky;
      top: 0;
      z-index: 20;
      background: rgba(255,255,255,.74);
      color: var(--ink);
      border-bottom: 1px solid var(--line);
      box-shadow: none;
      backdrop-filter: saturate(180%) blur(18px);
      -webkit-backdrop-filter: saturate(180%) blur(18px);
      padding: 16px 28px;
    }
    h1 {
      font-size: 24px;
      font-weight: 760;
      letter-spacing: 0;
    }
    main {
      gap: 20px;
      padding: 18px 22px 24px;
    }
    .tabs {
      position: sticky;
      top: 61px;
      z-index: 19;
      gap: 8px;
      padding: 12px 22px;
      background: rgba(245,245,247,.78);
      border-bottom: 1px solid rgba(60,60,67,.1);
      backdrop-filter: saturate(180%) blur(18px);
      -webkit-backdrop-filter: saturate(180%) blur(18px);
    }
    .tab-btn,
    button {
      border-radius: 8px;
      border-color: rgba(0,122,255,.26);
      background: var(--accent);
      color: #fff;
      font-weight: 650;
      box-shadow: 0 1px 2px rgba(0,0,0,.06);
      transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
    }
    button:hover {
      transform: translateY(-1px);
      box-shadow: 0 8px 18px rgba(0,122,255,.14);
    }
    button:active {
      transform: translateY(0);
      box-shadow: 0 1px 2px rgba(0,0,0,.08);
    }
    button:focus {
      outline: none;
    }
    button:focus-visible,
    summary:focus-visible {
      outline: none;
      box-shadow: 0 0 0 4px rgba(0,122,255,.16);
    }
    .tab-btn {
      background: rgba(255,255,255,.82);
      color: var(--accent);
      border-color: rgba(0,122,255,.22);
      min-height: 36px;
      padding: 7px 14px;
    }
    .tab-btn.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    button.secondary,
    .pregnancy-zoom-btn,
    .death-reason-tabs button {
      background: rgba(255,255,255,.78);
      color: var(--accent);
      border-color: rgba(0,122,255,.28);
    }
    button.secondary:hover,
    .pregnancy-zoom-btn:hover,
    .death-reason-tabs button:hover {
      background: rgba(0,122,255,.08);
    }
    button.muted {
      background: rgba(242,242,247,.88);
      color: var(--ink);
      border-color: var(--line);
    }
    button.danger {
      background: rgba(255,255,255,.82);
      color: var(--bad);
      border-color: rgba(215,0,21,.35);
    }
    button.toggle-active {
      background: rgba(0,122,255,.1);
      color: var(--accent);
      border-color: rgba(0,122,255,.32);
    }
    .panel,
    .source-card,
    .stat,
    .segmented-control,
    .plan-wean-section,
    .advanced-details,
    .table-wrap,
    .detail-box,
    .death-chart,
    .death-kpi,
    .death-table-wrap,
    .pregnancy-chart,
    .pregnancy-chart-large,
    .pregnancy-kpi,
    .summary-main,
    .barn,
    .farrowing-block,
    .unit-tile,
    .modal {
      border-color: var(--line);
      border-radius: 8px;
    }
    .panel {
      background: var(--panel);
      box-shadow: var(--shadow);
      backdrop-filter: saturate(180%) blur(18px);
      -webkit-backdrop-filter: saturate(180%) blur(18px);
    }
    .panel h2,
    .collapsible-head,
    .modal-head {
      background: rgba(255,255,255,.48);
      border-bottom-color: var(--line);
    }
    .panel h2 {
      padding: 16px 18px;
      font-size: 17px;
      font-weight: 760;
    }
    .body {
      padding: 16px 18px 18px;
    }
    label,
    .small,
    .stat .label,
    .summary-row,
    .plan-field label {
      color: var(--muted);
    }
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="file"],
    select,
    .checkline {
      min-height: 38px;
      border-color: rgba(60,60,67,.18);
      border-radius: 8px;
      background: rgba(255,255,255,.78);
      color: var(--ink);
      box-shadow: inset 0 1px 1px rgba(0,0,0,.03);
      transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
    }
    input[type="text"]:focus,
    input[type="password"]:focus,
    input[type="number"]:focus,
    input[type="date"]:focus,
    input[type="file"]:focus,
    select:focus {
      outline: none;
      border-color: rgba(0,122,255,.72);
      background: #fff;
      box-shadow: 0 0 0 4px rgba(0,122,255,.12);
    }
    input[type="checkbox"] {
      accent-color: var(--accent);
    }
    .divider,
    th,
    td,
    .summary-row,
    .pregnancy-panel,
    .advanced-details[open] summary,
    .modal-actions {
      border-color: rgba(60,60,67,.14);
    }
    .sync-status,
    .empty {
      background: rgba(255,255,255,.58);
      border-color: var(--line);
    }
    .sync-status.ok {
      border-color: rgba(52,199,89,.3);
      background: rgba(52,199,89,.1);
      color: #1f7a45;
    }
    .sync-status.warn,
    .warnings,
    .plan-warning {
      border-color: rgba(255,149,0,.34);
      background: rgba(255,149,0,.1);
      color: var(--warn);
    }
    .sync-status.error {
      border-color: rgba(255,59,48,.34);
      background: rgba(255,59,48,.1);
      color: var(--bad);
    }
    .stats {
      gap: 12px;
    }
    .stat {
      background: rgba(255,255,255,.68);
      box-shadow: var(--shadow-soft);
      padding: 13px 14px;
    }
    .stat .num {
      color: var(--accent);
      font-size: 24px;
      font-weight: 760;
    }
    .table-wrap,
    .death-table-wrap {
      background: rgba(255,255,255,.72);
      box-shadow: var(--shadow-soft);
    }
    table {
      border-collapse: separate;
      border-spacing: 0;
    }
    th {
      background: rgba(242,242,247,.95);
      color: #515154;
      font-weight: 720;
    }
    td {
      background: rgba(255,255,255,.62);
    }
    tbody tr:hover td {
      background: rgba(0,122,255,.045);
    }
    .sentence,
    .source-card strong,
    .barn-title,
    .farrowing-title,
    .pregnancy-title,
    .rank-head strong,
    .summary-row strong {
      color: var(--ink);
    }
    .pill {
      background: rgba(0,122,255,.08);
      color: var(--accent);
      border-color: rgba(0,122,255,.22);
    }
    .pill.warn {
      color: var(--warn);
      background: rgba(255,149,0,.1);
      border-color: rgba(255,149,0,.28);
    }
    .pill.bad {
      color: var(--bad);
      background: rgba(255,59,48,.1);
      border-color: rgba(255,59,48,.25);
    }
    .farm-map {
      background:
        linear-gradient(rgba(255,255,255,.58), rgba(255,255,255,.58)),
        linear-gradient(90deg, rgba(60,60,67,.055) 1px, transparent 1px),
        linear-gradient(180deg, rgba(60,60,67,.045) 1px, transparent 1px);
      background-size: auto, 64px 64px, 64px 64px;
      border-top-color: var(--line);
    }
    .barn,
    .farrowing-block {
      background: rgba(255,255,255,.72);
      border-color: rgba(60,60,67,.24);
      box-shadow: var(--shadow-soft);
    }
    .barn.placeholder {
      background: rgba(255,255,255,.38);
      border-color: rgba(60,60,67,.28);
      color: #8e8e93;
    }
    .summary-main {
      background: linear-gradient(180deg, rgba(0,122,255,.1), rgba(255,255,255,.72));
      border-color: rgba(0,122,255,.2);
    }
    .summary-main .num {
      color: var(--accent);
    }
    .unit-tile {
      background: rgba(255,255,255,.68);
      border-color: rgba(60,60,67,.2);
      box-shadow: 0 1px 2px rgba(0,0,0,.04);
    }
    .unit-tile:hover {
      outline: none;
      border-color: rgba(0,122,255,.42);
      box-shadow: 0 10px 22px rgba(0,122,255,.12);
    }
    .unit-tile .unit-no,
    .unit-tile .unit-line strong {
      color: #1d1d1f;
    }
    .unit-tile .unit-line span:first-child {
      color: var(--muted);
    }
    .unit-tile.ready {
      background: rgba(52,199,89,.12);
      border-color: rgba(52,199,89,.32);
    }
    .unit-tile.future,
    .unit-tile.wean-far {
      background: rgba(255,204,0,.13);
      border-color: rgba(255,204,0,.36);
    }
    .unit-tile.wean-14 {
      background: rgba(255,204,0,.22);
      border-color: rgba(255,179,64,.42);
    }
    .unit-tile.wean-7 {
      background: rgba(255,159,10,.26);
      border-color: rgba(255,149,0,.5);
    }
    .unit-tile.wean-3 {
      background: rgba(255,149,0,.42);
      border-color: rgba(191,90,0,.46);
    }
    .unit-tile.wean-today,
    .unit-tile.wean-overdue {
      background: linear-gradient(180deg, #ff9f0a, #c65f00);
      border-color: rgba(191,90,0,.62);
      color: #fff;
    }
    .unit-tile.disabled,
    .unit-tile.disabled-window {
      background: rgba(142,142,147,.16);
      border-color: rgba(142,142,147,.28);
      color: #8e8e93;
      box-shadow: none;
    }
    .unit-tile.foster {
      box-shadow: inset 0 0 0 2px rgba(255,59,48,.54), 0 1px 2px rgba(0,0,0,.04);
    }
    .modal-backdrop {
      background: rgba(28,28,30,.38);
      backdrop-filter: blur(18px);
      -webkit-backdrop-filter: blur(18px);
    }
    .modal {
      background: rgba(255,255,255,.88);
      border-color: rgba(255,255,255,.62);
      box-shadow: 0 26px 80px rgba(0,0,0,.22);
    }
    .modal-actions {
      background: rgba(255,255,255,.8);
      backdrop-filter: saturate(180%) blur(16px);
      -webkit-backdrop-filter: saturate(180%) blur(16px);
    }
    .advanced-details,
    .source-card,
    .pregnancy-kpi,
    .death-kpi,
    .pregnancy-chart,
    .pregnancy-chart-large,
    .death-chart {
      background: rgba(255,255,255,.64);
      box-shadow: none;
    }
    .advanced-details summary {
      color: var(--ink);
    }
    .advanced-details summary::after {
      color: var(--accent);
    }
    .death-reason-tabs button.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .pregnancy-chart-scroll {
      scrollbar-color: rgba(0,122,255,.38) rgba(242,242,247,.8);
    }
    .pregnancy-chart-scroll::-webkit-scrollbar-track {
      background: rgba(242,242,247,.8);
    }
    .pregnancy-chart-scroll::-webkit-scrollbar-thumb {
      background: rgba(0,122,255,.36);
      border-color: rgba(242,242,247,.8);
    }
    .segmented-control {
      background: rgba(255,255,255,.62);
    }
    .segmented-control button.active {
      background: var(--accent);
      color: #fff;
    }
    .plan-wean-section {
      background: rgba(255,255,255,.64);
      box-shadow: none;
    }
    @keyframes listItemIn {
      from {
        opacity: 0;
        transform: translateY(10px) scale(.992);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }
    .fx-spotlight {
      position: relative;
      overflow: hidden;
      isolation: isolate;
    }
    .fx-spotlight::before {
      content: "";
      position: absolute;
      inset: 0;
      background:
        radial-gradient(240px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(0, 122, 255, .13), transparent 64%),
        radial-gradient(180px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(255, 255, 255, .45), transparent 68%);
      opacity: 0;
      pointer-events: none;
      transition: opacity .18s ease;
      z-index: 0;
    }
    .fx-spotlight:hover::before,
    .fx-spotlight:focus-within::before {
      opacity: 1;
    }
    .fx-spotlight > * {
      position: relative;
      z-index: 1;
    }
    .unit-tile.fx-spotlight::before {
      background:
        radial-gradient(170px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(255, 255, 255, .58), transparent 62%),
        radial-gradient(220px circle at var(--spot-x, 50%) var(--spot-y, 50%), rgba(0, 122, 255, .18), transparent 68%);
    }
    .table-wrap.effect-fade {
      position: relative;
      border-radius: var(--radius-md);
    }
    .table-wrap.effect-fade::before,
    .table-wrap.effect-fade::after {
      content: "";
      position: sticky;
      left: 0;
      display: block;
      height: 18px;
      margin-bottom: -18px;
      pointer-events: none;
      z-index: 5;
    }
    .table-wrap.effect-fade::before {
      top: 0;
      background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,255,255,0));
    }
    .table-wrap.effect-fade::after {
      bottom: 0;
      margin-top: -18px;
      background: linear-gradient(0deg, rgba(255,255,255,.94), rgba(255,255,255,0));
    }
    .plan-row.animated-list-item td {
      animation: listItemIn .42s cubic-bezier(.22, 1, .36, 1) both;
      animation-delay: calc(var(--item-index, 0) * 34ms);
    }
    .plan-row td {
      transition: background-color .18s ease, box-shadow .18s ease;
    }
    .plan-row:hover td {
      background: rgba(0, 122, 255, .055);
    }
    .plan-row.is-open td {
      background: rgba(0, 122, 255, .085);
    }
    .plan-row td:first-child {
      position: relative;
    }
    .plan-row.is-open td:first-child::before {
      content: "";
      position: absolute;
      left: 0;
      top: 12px;
      bottom: 12px;
      width: 4px;
      border-radius: 999px;
      background: var(--accent);
      box-shadow: 0 0 18px rgba(0, 122, 255, .34);
    }
    .detail-row .detail-box {
      animation: listItemIn .28s cubic-bezier(.22, 1, .36, 1) both;
    }
    main.parity-analysis-page.active {
      display: block;
    }
    .parity-analysis-page {
      min-width: 0;
    }
    .parity-page {
      min-height: calc(100vh - 150px);
      overflow: hidden;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #f5f7fa;
    }
    .parity-page-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
      padding: 18px 20px;
      border-bottom: 1px solid var(--line);
      background: #fff;
      color: var(--ink);
    }
    .parity-page-head > div {
      min-width: 0;
    }
    .parity-page-head h2 {
      margin: 0;
      font-size: 20px;
    }
    .parity-page-head p {
      margin: 4px 0 0;
      color: var(--muted);
    }
    .parity-workspace-tabs {
      display: flex;
      gap: 6px;
      padding: 12px 20px 0;
      border-bottom: 1px solid var(--line);
      background: #fff;
    }
    .parity-workspace-tabs button {
      min-height: 40px;
      margin-bottom: -1px;
      padding: 8px 14px;
      border-color: transparent;
      border-bottom: 2px solid transparent;
      border-radius: 6px 6px 0 0;
      background: transparent;
      color: var(--muted);
      box-shadow: none;
    }
    .parity-workspace-tabs button[aria-selected="true"] {
      border-color: var(--line);
      border-bottom-color: #fff;
      background: #fff;
      color: var(--accent);
    }
    #paritySharedFilters {
      padding: 10px 20px;
      border-bottom: 1px solid var(--line);
      background: #fafbfc;
    }
    .parity-shared-filter-shell {
      display: grid;
      grid-template-columns: auto auto minmax(220px, 1fr);
      align-items: center;
      gap: 12px;
      min-height: 40px;
    }
    .parity-filter-group {
      display: flex;
      align-items: center;
      gap: 10px;
      white-space: nowrap;
    }
    .parity-filter-group > strong {
      font-size: 14px;
    }
    .parity-segmented {
      display: inline-flex;
      gap: 2px;
      padding: 2px;
      border: 1px solid #cfd7e3;
      border-radius: 6px;
      background: #fff;
    }
    .parity-segmented button {
      min-height: 32px;
      padding: 5px 12px;
      border: 0;
      border-radius: 4px;
      background: transparent;
      color: #4f5f73;
      box-shadow: none;
    }
    .parity-segmented button.active,
    .parity-segmented button[aria-pressed="true"] {
      background: #e8f2ff;
      color: #0569cf;
    }
    .parity-check-filter {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-height: 36px;
      padding: 6px 10px;
      border: 1px solid #d8dee8;
      border-radius: 6px;
      background: #fff;
      white-space: nowrap;
    }
    .parity-check-filter input {
      width: 17px;
      height: 17px;
      margin: 0;
      accent-color: var(--accent);
    }
    .parity-search-filter {
      display: block;
      justify-self: end;
      width: min(100%, 420px);
    }
    .parity-search-filter input {
      width: 100%;
      min-height: 36px;
      padding: 7px 11px;
      border: 1px solid #cfd7e3;
      border-radius: 6px;
      background: #fff;
    }
    .parity-shared-filter-shell span,
    .parity-panel-heading span {
      color: var(--muted);
    }
    #parityWorkspace {
      padding: 14px 16px 20px;
    }
    .parity-dashboard-grid {
      display: grid;
      grid-template-columns: minmax(288px, 320px) minmax(0, 1fr);
      gap: 14px;
      align-items: start;
    }
    .parity-standard-panel,
    .parity-analysis-panel,
    .parity-custom-placeholder {
      min-width: 0;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
    }
    .parity-standard-panel {
      position: sticky;
      top: 112px;
      overflow: hidden;
    }
    .parity-panel-heading {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
      padding: 13px 14px 11px;
      border-bottom: 1px solid var(--line);
      background: #f9fbfd;
    }
    .parity-panel-heading h3 {
      margin: 0 0 3px;
      font-size: 16px;
      line-height: 1.3;
    }
    .parity-panel-heading > div > span {
      font-size: 12px;
    }
    .parity-standard-state {
      flex: 0 0 auto;
      padding: 4px 7px;
      border: 1px solid #9bd8ca;
      border-radius: 999px;
      background: #edf9f6;
      color: #087b68 !important;
      font-size: 12px;
    }
    .parity-rule-group {
      padding: 10px 12px;
      border-bottom: 1px solid #e5e9f0;
    }
    .parity-rule-group:last-of-type {
      border-bottom: 0;
    }
    .parity-rule-title {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 7px;
    }
    .parity-rule-title strong {
      font-size: 13px;
      line-height: 1.3;
    }
    .parity-rule-title span {
      color: #78869a;
      font-size: 11px;
      text-align: right;
    }
    .parity-rule-group label {
      display: grid;
      grid-template-columns: minmax(86px, 1fr) 34px 48px 18px;
      align-items: center;
      gap: 5px;
      min-height: 32px;
      margin-top: 5px;
      font-size: 12px;
    }
    .parity-rule-group label > span {
      min-width: 0;
      overflow: hidden;
      color: #344054;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .parity-rule-group label > b {
      color: #667085;
      font-size: 11px;
      font-weight: 500;
      text-align: center;
    }
    .parity-rule-group label > input {
      width: 100%;
      min-height: 30px;
      padding: 4px 5px;
      border: 1px solid #cfd7e3;
      border-radius: 4px;
      background: #fff;
      font: inherit;
      text-align: center;
    }
    .parity-rule-group label > em {
      color: #667085;
      font-size: 11px;
      font-style: normal;
    }
    .parity-rule-group p {
      margin: 7px 0 0;
      padding: 6px 7px;
      border-left: 3px solid #e5ad36;
      background: #fff8e8;
      color: #7a5a14;
      font-size: 11px;
      line-height: 1.45;
    }
    .parity-review-rule p {
      border-left-color: #5f8fd4;
      background: #f0f6ff;
      color: #38597e;
    }
    .parity-manual-rule textarea {
      width: 100%;
      min-height: 58px;
      resize: vertical;
      padding: 7px 8px;
      border: 1px solid #cfd7e3;
      border-radius: 4px;
      font: inherit;
      line-height: 1.45;
    }
    .parity-standard-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 7px;
      padding: 11px 12px 13px;
      border-top: 1px solid var(--line);
      background: #f9fbfd;
    }
    .parity-standard-actions .primary {
      grid-column: 1 / -1;
    }
    .parity-standard-actions button {
      min-height: 36px;
      padding: 7px 8px;
      font-size: 12px;
    }
    .parity-analysis-panel {
      padding: 12px;
    }
    .parity-kpi-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(130px, 1fr));
      gap: 9px;
    }
    .parity-kpi-card {
      position: relative;
      min-height: 78px;
      padding: 12px 13px;
      overflow: hidden;
      border: 1px solid #d8dee8;
      border-radius: 6px;
      background: #fff;
      color: #344054;
      text-align: left;
      box-shadow: none;
    }
    .parity-kpi-card::before {
      content: "";
      position: absolute;
      inset: 0 auto 0 0;
      width: 4px;
      background: #7b8796;
    }
    .parity-kpi-card strong {
      display: block;
      margin-bottom: 4px;
      font-size: 25px;
      line-height: 1;
    }
    .parity-kpi-card span {
      color: #667085;
      font-size: 12px;
    }
    .parity-kpi-card.danger::before { background: #d65248; }
    .parity-kpi-card.danger strong { color: #bf3f37; }
    .parity-kpi-card.warning::before { background: #d89a24; }
    .parity-kpi-card.warning strong { color: #a96b00; }
    .parity-kpi-card.neutral::before { background: #778395; }
    .parity-kpi-card.neutral strong { color: #526174; }
    .parity-kpi-card.success::before { background: #2d9a82; }
    .parity-kpi-card.success strong { color: #147c68; }
    .parity-kpi-card:hover,
    .parity-kpi-card.active {
      border-color: #7bb8f4;
      background: #f4f9ff;
      box-shadow: 0 0 0 2px rgba(0, 122, 255, .08);
    }
    .parity-chart-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 9px;
      margin-top: 9px;
    }
    .parity-chart-panel {
      min-width: 0;
      min-height: 172px;
      padding: 11px 12px 12px;
      border: 1px solid #dfe4ec;
      border-radius: 6px;
      background: #fbfcfe;
    }
    .parity-chart-panel h4 {
      margin: 0 0 9px;
      color: #344054;
      font-size: 13px;
    }
    .parity-bar-list {
      display: grid;
      gap: 6px;
    }
    .parity-bar-list button {
      display: grid;
      grid-template-columns: minmax(76px, 42%) minmax(56px, 1fr) 30px;
      align-items: center;
      gap: 7px;
      width: 100%;
      min-height: 25px;
      padding: 2px;
      border: 0;
      border-radius: 4px;
      background: transparent;
      color: #475467;
      box-shadow: none;
      text-align: left;
    }
    .parity-bar-list button:hover,
    .parity-bar-list button.active {
      background: #eaf3ff;
      color: #075fb7;
    }
    .parity-bar-list button > span {
      overflow: hidden;
      font-size: 11px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .parity-bar-list button > i {
      display: block;
      height: 8px;
      overflow: hidden;
      border-radius: 2px;
      background: #e8edf4;
    }
    .parity-bar-list button > i > b {
      display: block;
      height: 100%;
      border-radius: inherit;
      background: #6ea7df;
    }
    .parity-chart-panel:first-child .parity-bar-list button > i > b {
      background: #dc665b;
    }
    .parity-chart-panel:last-child .parity-bar-list button > i > b {
      background: #42a88f;
    }
    .parity-bar-list button > em {
      font-size: 11px;
      font-style: normal;
      font-weight: 700;
      text-align: right;
    }
    .parity-empty-copy {
      display: grid;
      min-height: 112px;
      margin: 0;
      place-items: center;
      color: #98a2b3;
      font-size: 12px;
    }
    .parity-result-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-top: 9px;
      padding: 9px 10px;
      border: 1px solid #dfe4ec;
      border-bottom: 0;
      border-radius: 6px 6px 0 0;
      background: #f8fafc;
    }
    .parity-result-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
    }
    .parity-result-tabs button,
    .parity-active-facet {
      min-height: 31px;
      padding: 5px 9px;
      border: 1px solid transparent;
      border-radius: 4px;
      background: transparent;
      color: #5d6b7f;
      box-shadow: none;
      font-size: 12px;
    }
    .parity-result-tabs button:hover,
    .parity-result-tabs button.active {
      border-color: #b6d7f8;
      background: #eaf3ff;
      color: #0569cf;
    }
    .parity-active-facet {
      flex: 0 0 auto;
      border-color: #edc979;
      background: #fff7df;
      color: #8a6100;
    }
    .parity-result-table {
      min-width: 0;
      overflow: hidden;
      border: 1px solid #dfe4ec;
      background: #fff;
    }
    .parity-table-scroll {
      width: 100%;
      overflow-x: auto;
      overscroll-behavior-inline: contain;
    }
    .parity-result-table table {
      width: 100%;
      min-width: 1120px;
      border-collapse: collapse;
      table-layout: auto;
    }
    .parity-result-table th,
    .parity-result-table td {
      padding: 9px 10px;
      border-bottom: 1px solid #e8ecf2;
      color: #3d4959;
      font-size: 12px;
      line-height: 1.45;
      text-align: left;
      vertical-align: middle;
      white-space: nowrap;
    }
    .parity-result-table th {
      position: sticky;
      top: 0;
      z-index: 1;
      background: #f3f6f9;
      color: #596679;
      font-weight: 600;
    }
    .parity-result-table tbody tr:hover td {
      background: #f7fbff;
    }
    .parity-result-table tr:last-child td {
      border-bottom: 0;
    }
    .parity-result-table td.parity-recent-data {
      min-width: 240px;
      white-space: normal;
    }
    .parity-source-note {
      display: block;
      margin-top: 2px;
      color: #9a6700;
      font-size: 11px;
      font-weight: 600;
      line-height: 1.25;
    }
    .parity-result-table .text-button {
      min-height: 30px;
      padding: 4px 8px;
    }
    .parity-result-table footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      min-height: 46px;
      padding: 7px 10px;
      border-top: 1px solid #e1e6ee;
      background: #fafbfd;
      color: #667085;
      font-size: 12px;
    }
    .parity-result-table footer > div {
      display: flex;
      gap: 6px;
    }
    .parity-result-table footer button {
      min-height: 32px;
      padding: 5px 10px;
    }
    .parity-result-badge {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      padding: 3px 7px;
      border: 1px solid #d8dee8;
      border-radius: 999px;
      background: #f5f7fa;
      color: #5f6b7c;
      font-size: 11px;
      line-height: 1;
      white-space: nowrap;
    }
    .parity-result-badge.suggested_cull {
      border-color: #efb2ac;
      background: #fff0ee;
      color: #b93830;
    }
    .parity-result-badge.key_review {
      border-color: #efd28f;
      background: #fff8e7;
      color: #946000;
    }
    .parity-result-badge.incomplete {
      border-color: #cbd2dc;
      background: #f2f4f7;
      color: #596579;
    }
    .parity-result-badge.not_matched {
      border-color: #a8d9cd;
      background: #ecf9f5;
      color: #147563;
    }
    .parity-empty-state {
      display: grid;
      min-height: 260px;
      place-items: center;
      color: #8793a5;
      font-size: 13px;
    }
    .parity-custom-placeholder {
      min-height: 360px;
      padding: 22px;
    }
    .parity-custom-placeholder h3 {
      margin: 0 0 8px;
      font-size: 18px;
    }
    .parity-custom-placeholder p {
      max-width: 720px;
      margin: 0;
      color: #667085;
      line-height: 1.7;
    }
    .parity-workspace-shell {
      min-height: 220px;
      padding: 18px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
    }
    .parity-workspace-shell h3 {
      margin: 0 0 6px;
      font-size: 17px;
    }
    .parity-workspace-shell p {
      margin: 0;
      color: var(--muted);
    }
    .parity-results-shell {
      min-height: 360px;
      background: #fbfcfd;
    }
    .parity-detail-drawer {
      position: fixed;
      inset: 0;
      z-index: 120;
      pointer-events: none;
    }
    .parity-detail-drawer[hidden] {
      display: none;
    }
    .parity-detail-backdrop {
      position: absolute;
      inset: 0;
      pointer-events: auto;
      background: rgba(20, 28, 40, .38);
      backdrop-filter: blur(1px);
    }
    .parity-detail-drawer aside {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      width: min(620px, 92vw);
      overflow: auto;
      pointer-events: auto;
      border-left: 1px solid var(--line);
      background: #fff;
      box-shadow: -12px 0 34px rgba(16, 24, 40, .2);
    }
    .parity-detail-drawer aside > header {
      position: sticky;
      top: 0;
      z-index: 2;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      padding: 16px 18px;
      border-bottom: 1px solid var(--line);
      background: rgba(255, 255, 255, .97);
    }
    .parity-detail-drawer aside > header span {
      color: #667085;
      font-size: 12px;
    }
    .parity-detail-drawer aside > header h3 {
      margin: 3px 0 0;
      font-size: 20px;
    }
    .parity-detail-drawer aside > header button {
      width: 36px;
      height: 36px;
      padding: 0;
      border-radius: 50%;
      font-size: 23px;
      line-height: 1;
    }
    .parity-detail-body {
      display: grid;
      gap: 12px;
      padding: 15px 18px 24px;
    }
    .parity-detail-body > section {
      padding: 13px 14px;
      border: 1px solid #dfe4ec;
      border-radius: 6px;
      background: #fff;
    }
    .parity-detail-body h4 {
      margin: 0 0 10px;
      color: #344054;
      font-size: 14px;
    }
    .parity-detail-body p {
      margin: 0;
      color: #596579;
      line-height: 1.65;
    }
    .parity-detail-body dl {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 1px;
      margin: 0;
      overflow: hidden;
      border: 1px solid #e2e7ee;
      background: #e2e7ee;
    }
    .parity-detail-body dl > div {
      min-width: 0;
      padding: 9px 10px;
      background: #fbfcfe;
    }
    .parity-detail-body dt {
      margin-bottom: 4px;
      color: #7a8798;
      font-size: 11px;
    }
    .parity-detail-body dd {
      min-width: 0;
      margin: 0;
      overflow-wrap: anywhere;
      color: #344054;
      font-size: 13px;
      font-weight: 600;
    }
    .parity-detail-list {
      display: grid;
      gap: 0;
      margin: 0;
      padding: 0;
      list-style: none;
    }
    .parity-detail-list li {
      display: grid;
      grid-template-columns: minmax(130px, .8fr) minmax(0, 1.2fr);
      gap: 12px;
      padding: 9px 0;
      border-bottom: 1px solid #edf0f4;
    }
    .parity-detail-list li:first-child {
      padding-top: 0;
    }
    .parity-detail-list li:last-child {
      padding-bottom: 0;
      border-bottom: 0;
    }
    .parity-detail-list strong,
    .parity-detail-list span {
      min-width: 0;
      overflow-wrap: anywhere;
      font-size: 12px;
      line-height: 1.5;
    }
    .parity-detail-list span {
      color: #667085;
    }
    @media (prefers-reduced-motion: reduce) {
      .plan-row.animated-list-item td,
      .detail-row .detail-box {
        animation: none;
      }
      .fx-spotlight::before,
      .plan-row td {
        transition: none;
      }
    }
    @media (max-width: 980px) {
      main { grid-template-columns: 1fr; }
      main.view.active { display: grid; }
      .layout-view { grid-template-columns: 1fr; }
      .layout-view.sources-collapsed { grid-template-columns: 1fr; }
      .advanced-grid { grid-template-columns: 1fr; }
      .death-summary { grid-template-columns: 1fr; }
      .source-settings-panel.collapsed .collapsible-head {
        min-height: auto;
        display: flex;
        justify-content: space-between;
        padding: 12px 14px;
      }
      .source-settings-panel.collapsed .collapsible-head h2 {
        writing-mode: horizontal-tb;
        font-size: 16px;
      }
      .source-settings-panel.collapsed .collapse-toggle {
        width: auto;
        padding: 5px 10px;
      }
      .stats { grid-template-columns: repeat(2, 1fr); }
      .plan-toolbar { align-items: stretch; }
      .plan-toolbar,
      .plan-toolbar .btn-row,
      .segmented-control {
        width: 100%;
      }
      .segmented-control button { flex: 1; }
      .plan-wean-grid { grid-template-columns: 1fr; }
      .rate-filter-bar { grid-template-columns: 1fr; }
      .report-filter-bar { grid-template-columns: 1fr; }
      main.pig-archive-page.active { grid-template-columns: 1fr; }
      .pig-archive-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .pig-archive-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .inventory-setup-grid,
      .inventory-active-head,
      .inventory-task-toolbar {
        grid-template-columns: 1fr;
        flex-direction: column;
      }
      .inventory-task-toolbar {
        align-items: stretch;
      }
      .inventory-task-actions {
        width: 100%;
      }
      .inventory-task-actions button {
        flex: 1;
      }
      .inventory-summary {
        min-width: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .report-section-grid { grid-template-columns: 1fr; }
      .report-metrics { grid-template-columns: repeat(2, 1fr); }
      .unit-rate-grid { grid-template-columns: 1fr; }
      .hormone-toolbar {
        align-items: stretch;
        flex-direction: column;
      }
      .hormone-toolbar .segmented-control,
      .hormone-toolbar > button {
        width: 100%;
      }
      .hormone-toolbar .segmented-control button {
        min-height: 44px;
      }
      .hormone-toolbar > button {
        min-height: 44px;
      }
      .hormone-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      .hormone-cohort-card {
        grid-template-columns: 1fr;
      }
      .hormone-member-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      .parity-dashboard-grid {
        grid-template-columns: 1fr;
      }
      .parity-standard-panel {
        position: static;
      }
      .parity-chart-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .parity-chart-panel:last-child {
        grid-column: 1 / -1;
      }
      .parity-results-shell {
        min-height: 280px;
      }
    }

    @media (max-width: 760px) {
      .history-planning-controls,
      .history-metric-grid {
        grid-template-columns: 1fr;
      }
      .planning-parameters-details summary {
        align-items: flex-start;
      }
      .history-metric-card-head,
      .history-metric-row-head {
        align-items: flex-start;
      }
      html {
        -webkit-text-size-adjust: 100%;
      }
      body {
        overflow-x: hidden;
        font-size: 15px;
      }
      header {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
      }
      h1 {
        font-size: 19px;
        line-height: 1.2;
      }
      .tabs {
        top: 50px;
        gap: 8px;
        padding: 10px 12px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
      }
      .tabs::-webkit-scrollbar {
        display: none;
      }
      .tab-btn {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 8px 12px;
      }
      main {
        width: 100%;
        padding: 12px;
        gap: 12px;
      }
      .panel,
      .body,
      .source-settings-panel,
      .layout-view > .panel {
        min-width: 0;
      }
      .panel {
        border-radius: 12px;
      }
      .panel h2,
      .collapsible-head {
        padding: 13px 14px;
        font-size: 16px;
      }
      .body {
        padding: 13px 14px 15px;
      }
      .control-tool-body {
        padding: 12px;
      }
      .control-auth-options {
        grid-template-columns: minmax(0, 1fr);
      }
      .parity-page {
        min-height: calc(100vh - 132px);
      }
      .parity-page-head {
        align-items: stretch;
        flex-direction: column;
        padding: 14px;
      }
      .parity-page-head button {
        width: 100%;
        min-height: 44px;
      }
      .parity-workspace-tabs {
        flex-wrap: wrap;
        padding: 10px 12px 0;
      }
      .parity-workspace-tabs button {
        flex: 1 1 150px;
      }
      #paritySharedFilters,
      #parityWorkspace {
        padding: 12px;
      }
      .parity-shared-filter-shell {
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        gap: 9px;
      }
      .parity-filter-group {
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
        white-space: normal;
      }
      .parity-segmented {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
      }
      .parity-segmented button {
        min-width: 0;
        padding-inline: 6px;
      }
      .parity-check-filter,
      .parity-search-filter {
        justify-self: stretch;
        width: 100%;
      }
      .parity-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .parity-kpi-card {
        min-height: 72px;
        padding: 10px 11px;
      }
      .parity-kpi-card strong {
        font-size: 22px;
      }
      .parity-chart-grid {
        grid-template-columns: minmax(0, 1fr);
      }
      .parity-chart-panel:last-child {
        grid-column: auto;
      }
      .parity-result-toolbar,
      .parity-result-footer {
        align-items: stretch;
        flex-direction: column;
      }
      .parity-result-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .parity-result-tabs button {
        width: 100%;
      }
      .parity-active-facet {
        align-self: flex-start;
      }
      .parity-detail-drawer aside {
        width: 100vw;
        border-left: 0;
      }
      .parity-detail-body dl {
        grid-template-columns: minmax(0, 1fr);
      }
      .parity-detail-list li {
        grid-template-columns: minmax(0, 1fr);
        gap: 3px;
      }
      .control-auth-option,
      .control-auth-option + .control-auth-option {
        padding: 14px 0 2px;
        border-left: 0;
      }
      .control-auth-option + .control-auth-option {
        margin-top: 12px;
        border-top: 1px solid var(--line);
      }
      .control-workbench {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
          "head"
          "search"
          "categories"
          "tabs"
          "list"
          "message";
        padding: 12px;
      }
      .control-inline-view {
        padding: 8px;
      }
      .control-inline-head {
        align-items: stretch;
        flex-direction: column;
      }
      .control-inline-head button {
        width: 100%;
      }
      .control-inline-frame {
        height: calc(100dvh - 190px);
        min-height: 560px;
      }
      .control-workbench-head {
        align-items: stretch;
        flex-direction: column;
      }
      .control-workbench-head button,
      .control-session-gate button {
        width: 100%;
      }
      .control-workbench-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
      }
      .control-category-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
      }
      .control-category-nav button,
      .control-line-tabs button {
        flex: 0 0 auto;
      }
      .control-line-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
      }
      .control-device-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 10px;
      }
      .control-device-copy {
        min-width: 0;
        overflow: hidden;
      }
      .control-device-status {
        grid-column: 1;
      }
      .control-device-row button {
        grid-column: 2;
        grid-row: 1 / span 2;
      }
      .grid,
      .source-grid,
      .advanced-grid,
      .wean-breed-controls,
      .pregnancy-controls,
      .rate-filter-bar,
      .report-filter-bar,
      .pig-query-grid,
      .inventory-form-grid,
      .inventory-source-row,
      .inventory-scan-row {
        grid-template-columns: 1fr;
      }
      .pig-captcha-row {
        grid-template-columns: 1fr auto;
      }
      .pig-captcha-row input {
        grid-column: 1 / -1;
      }
      input[type="text"],
      input[type="password"],
      input[type="number"],
      input[type="date"],
      input[type="file"],
      select,
      .checkline,
      button {
        min-height: 44px;
      }
      input[type="file"] {
        font-size: 13px;
      }
      .btn-row {
        gap: 8px;
      }
      .btn-row > button,
      .btn-row > .tab-jump {
        flex: 1 1 140px;
      }
      .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }
      .stat {
        padding: 11px 12px;
      }
      .stat .num {
        font-size: 23px;
      }
      .plan-toolbar {
        gap: 9px;
      }
      .segmented-control {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }
      .segmented-control button {
        flex: 1 0 max-content;
        min-height: 38px;
      }
      .table-wrap,
      .rate-table-wrap,
      .death-table-wrap {
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
      }
      .table-wrap table {
        min-width: 760px;
      }
      .rate-table-wrap table {
        min-width: 980px;
      }
      .report-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }
      .report-table table {
        min-width: 520px;
      }
      .layout-view {
        overflow: visible;
      }
      .source-settings-panel.collapsed .collapsible-head {
        min-height: 56px;
      }
      .farm-map {
        min-height: 0;
        padding: 12px;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        border-radius: 0 0 12px 12px;
        scroll-snap-type: x proximity;
      }
      .map-grid {
        min-width: 980px;
        grid-template-columns: 236px 218px 218px 236px 92px;
        gap: 14px;
        align-items: start;
      }
      .farrowing-block {
        grid-template-columns: 100px 100px;
        gap: 8px 10px;
        padding: 12px 10px;
        scroll-snap-align: start;
      }
      .barn {
        min-height: 280px;
        scroll-snap-align: start;
      }
      .barn.breeding-barn {
        padding: 12px;
      }
      .barn-title {
        font-size: 21px;
        padding-bottom: 8px;
      }
      .summary-main .num {
        font-size: 28px;
      }
      .summary-row {
        font-size: 12px;
      }
      .unit-tile {
        min-height: 104px;
        padding: 8px;
      }
      .unit-tile .unit-no {
        font-size: 19px;
      }
      .unit-tile .unit-meta {
        font-size: 11px;
        line-height: 1.28;
      }
      .map-note {
        min-width: 980px;
      }
      .wean-sequence-panel {
        min-width: 980px;
      }
      .wean-sequence-grid {
        gap: 10px;
        padding: 12px;
      }
      .wean-seq-row {
        grid-template-columns: 30px 54px 70px 78px 70px 78px;
        gap: 6px;
        font-size: 11px;
      }
      .modal-backdrop {
        align-items: stretch;
        padding: 8px;
      }
      .modal,
      .modal.wean-modal,
      .modal.chart-modal {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 14px;
      }
      .modal-head {
        padding: 12px 13px;
      }
      .modal-head h3 {
        font-size: 16px;
      }
      .modal-body {
        padding: 12px 13px 14px;
      }
      .modal-actions {
        bottom: -14px;
        margin: 14px -13px -14px;
        padding: 10px 13px calc(13px + env(safe-area-inset-bottom, 0px));
      }
      .modal-actions button {
        flex: 1 1 0;
      }
      .death-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      .death-chart,
      .pregnancy-chart,
      .pregnancy-chart-large {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }
      .death-chart svg,
      .pregnancy-chart svg {
        min-width: 520px;
      }
      .death-table-wrap table {
        min-width: 560px;
      }
      .pregnancy-chart-large svg {
        min-width: 720px;
      }
      .plan-wean-table-wrap {
        -webkit-overflow-scrolling: touch;
      }
      .plan-wean-table {
        min-width: 720px;
      }
      .report-section-grid {
        grid-template-columns: 1fr;
      }
      .report-card {
        border-radius: 12px;
      }
      .report-card-body {
        padding: 11px 12px 13px;
      }
      .report-chart svg {
        min-width: 620px;
      }
      .hormone-tool-body {
        padding: 12px;
        gap: 12px;
      }
      .hormone-toolbar {
        align-items: stretch;
        flex-direction: column;
      }
      .hormone-toolbar .segmented-control,
      .hormone-toolbar > button {
        width: 100%;
      }
      .hormone-toolbar .segmented-control button {
        flex: 1 1 0;
        min-height: 44px;
      }
      .hormone-source-list {
        grid-template-columns: 1fr;
      }
      .hormone-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .hormone-kpi {
        min-height: 88px;
      }
      .hormone-cohort-card {
        grid-template-columns: 1fr;
        padding: 10px;
      }
      .hormone-cohort-main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .hormone-stage-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      .hormone-stage-grid button {
        min-height: 72px;
      }
      .hormone-details-head {
        align-items: stretch;
        flex-direction: column;
      }
      .hormone-details-head button {
        width: 100%;
      }
      .hormone-member-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px 8px;
        padding: 9px 7px;
      }
      .hormone-member-row strong,
      .hormone-member-row .hormone-flags {
        grid-column: 1 / -1;
      }
      .hormone-issue-row {
        grid-template-columns: 1fr 1fr;
      }
      .hormone-issue-row span:last-child {
        grid-column: 1 / -1;
      }
    }

    @media (max-width: 480px) {
      header {
        padding-left: 12px;
        padding-right: 12px;
      }
      .tabs {
        top: 48px;
        padding-left: 10px;
        padding-right: 10px;
      }
      main {
        padding: 10px;
      }
      .panel h2,
      .collapsible-head,
      .body {
        padding-left: 12px;
        padding-right: 12px;
      }
      .stats,
      .report-metrics,
      .pig-archive-hero,
      .pig-archive-fields,
      .death-summary {
        grid-template-columns: 1fr;
      }
      .stat .num,
      .unit-rate-main strong,
      .report-metric strong {
        font-size: 22px;
      }
      .farm-map {
        padding: 10px;
      }
      .map-grid {
        min-width: 900px;
        grid-template-columns: 218px 198px 198px 218px 82px;
        gap: 12px;
      }
      .farrowing-block {
        grid-template-columns: 92px 92px;
        gap: 8px;
        padding: 10px 8px;
      }
      .barn.breeding-barn {
        padding: 10px;
      }
      .barn-title {
        font-size: 19px;
      }
      .unit-tile {
        min-height: 100px;
        padding: 7px;
      }
      .unit-tile .unit-meta {
        font-size: 10.5px;
      }
      .map-note,
      .wean-sequence-panel {
        min-width: 900px;
      }
      .tool-grid {
        grid-template-columns: 1fr;
      }
      .tool-drawer-head {
        align-items: stretch;
        flex-direction: column;
      }
      .tool-actions,
      .tool-open-btn,
      .tool-actions button,
      .inventory-source-row > button,
      .inventory-scan-row > button,
      .inventory-task-actions button {
        width: 100%;
      }
      .inventory-row-filter,
      .inventory-task-actions {
        width: 100%;
      }
      .inventory-row-filter button {
        flex: 1;
        width: auto;
        min-width: 0;
      }
      .inventory-table-wrap {
        max-height: 55vh;
      }
      .quick-tool-frame {
        min-height: calc(100dvh - 240px);
        height: 760px;
      }
      .modal-backdrop {
        padding: 6px;
      }
      .modal,
      .modal.wean-modal,
      .modal.chart-modal {
        width: calc(100vw - 12px);
        max-height: calc(100dvh - 12px);
      }
      .modal-actions {
        flex-direction: column;
      }
      .modal-actions button {
        width: 100%;
      }
    }

  
