  :root{
    --bg: #141a16;
    --panel: #1b231d;
    --panel-2: #212b23;
    --line: #33402f;
    --line-soft: #2a352b;
    --text: #e9ede5;
    --text-dim: #9db09a;
    --text-faint: #6b7d6a;
    --accent: #e2a33d;
    --accent-dim: #7a5a24;
    --danger: #c1502e;
    --ok: #6fa875;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  }
  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
  }
  .wrap{ max-width: 1180px; margin: 0 auto; padding: 28px 20px 120px; }

  /* header */
  .top{
    display:flex; align-items:flex-end; justify-content:space-between; gap: 24px;
    padding-bottom: 18px; margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
  }
  .top h1{
    font-size: 21px; font-weight: 600; margin:0 0 4px; letter-spacing: 0.2px;
  }
  .top p{ margin:0; color: var(--text-dim); font-size: 13px; max-width: 50ch; }
  .sender-field{ display:flex; flex-direction:column; gap:4px; min-width: 220px; }
  .sender-field label{ font-size: 11px; color: var(--text-faint); }
  .sender-field input{
    background: var(--panel-2); border:1px solid var(--line); color: var(--text);
    padding: 7px 9px; border-radius: 5px; font-family: var(--sans); font-size:13px;
  }
  .sender-field input:focus{ outline: none; border-color: var(--accent); }

  /* dropzone */
  .dropzone{
    border: 1.5px dashed var(--line);
    border-radius: 8px;
    padding: 18px 20px;
    display:flex; align-items:center; justify-content:space-between; gap: 16px;
    margin-bottom: 20px;
    background: var(--panel);
    flex-wrap: wrap;
  }
  .dropzone.drag{ border-color: var(--accent); background: #1f2a1c; }
  .dropzone .dz-text{ color: var(--text-dim); font-size: 13px; }
  .dropzone .dz-text b{ color: var(--text); font-weight: 600; }
  .btn{
    appearance:none; border:1px solid var(--line); background: var(--panel-2); color: var(--text);
    padding: 9px 15px; border-radius: 6px; font-size: 13px; font-family: var(--sans);
    cursor:pointer; white-space: nowrap;
  }
  .btn:hover{ border-color: var(--text-faint); }
  .btn.primary{ background: var(--accent); border-color: var(--accent); color: #241a08; font-weight: 600; }
  .btn.primary:hover{ background: #eeb257; }
  .btn.primary:disabled{ background: var(--accent-dim); border-color: var(--accent-dim); color:#5a4a2e; cursor:not-allowed; }
  .btn.danger-ghost{ color: var(--danger); border-color: transparent; background: transparent; padding: 4px 6px; font-size: 12px; }
  .btn.danger-ghost:hover{ background: #2a1712; }
  .btn.small{ padding: 5px 10px; font-size:12px; }
  .btn.outline{ border-color: var(--accent); color: var(--accent); background: transparent; }
  .btn.outline:hover{ background: #2a2413; }
  .btn.outline:disabled{ border-color: var(--line); color: var(--text-faint); cursor:not-allowed; background: transparent; }
  .mock-note{ background:#2a2213; border:1px solid #4a3c1a; color:#e8d9a8; border-radius:6px; padding:9px 12px; font-size:12px; margin-bottom:14px; }
  .field input[readonly]{ opacity:.75; cursor:not-allowed; }
  .btn.ghost{ background: transparent; }

  /* library columns */
  .shelves{ display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  @media (max-width: 1180px){ .shelves{ grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (max-width: 640px){ .shelves{ grid-template-columns: minmax(0, 1fr); } }
  .shelf{
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
    display:flex; flex-direction:column; min-height: 220px; min-width: 0;
  }
  .shelf-head{
    padding: 12px 14px 10px; border-bottom: 1px solid var(--line-soft);
    display:flex; align-items:baseline; justify-content:space-between;
  }
  .shelf-head .cat{ font-family: var(--mono); font-size: 13px; letter-spacing: 0.5px; color: var(--accent); font-weight:600; }
  .shelf-head .full{ font-size: 11px; color: var(--text-faint); }
  .shelf-head .count{ font-size: 11px; color: var(--text-faint); }
  .shelf-list{ padding: 6px; flex:1; overflow-y:auto; overflow-x:hidden; max-height: calc(100vh - 400px); min-height: 220px; }
  .empty-row{ color: var(--text-faint); font-size: 12.5px; padding: 16px 10px; text-align:center; }
  .file-row{
    display:grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items:start;
    padding: 7px 8px; border-radius: 6px;
  }
  .file-row:hover{ background: var(--panel-2); }
  .file-row.selected{ background: #26321f; }
  .file-row.disabled{ opacity: 0.42; }
  .file-row input[type=checkbox], .file-row input[type=radio]{ accent-color: var(--accent); margin-top: 3px; }
  .file-row .file-main{ min-width:0; }
  .file-row .fname{
    display:block; overflow-wrap:anywhere; word-break:break-word; line-height:1.35;
    font-family: var(--mono); font-size: 12.5px; cursor:pointer;
  }
  .file-row .file-sub{ display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap: 4px 8px; margin-top: 3px; }
  .file-row .file-sub .left{ display:flex; align-items:center; gap:6px; }
  .file-row .meta{ font-size: 10.5px; color: var(--text-faint); }
  .file-row .row-actions{ display:flex; flex-wrap:wrap; gap:2px; }
  .file-row .row-actions button{
    background:none; border:none; color: var(--text-faint); cursor:pointer; font-size: 13px; padding: 3px 5px; border-radius:4px;
  }
  .file-row .row-actions button:hover{ color: var(--text); background: var(--line-soft); }
  .file-row .row-actions button.del:hover{ color: var(--danger); }
  .file-row .row-actions button[data-decompose]{ font-size: 11px; white-space: nowrap; padding: 3px 7px; }

  /* species tree */
  .tree-group{ margin-bottom: 4px; }
  .tree-group > summary, .tree-species > summary{
    cursor:pointer; list-style:none; display:flex; align-items:center; justify-content:space-between;
    padding: 7px 8px; border-radius: 6px; font-size: 12.5px;
  }
  .tree-group > summary::-webkit-details-marker, .tree-species > summary::-webkit-details-marker{ display:none; }
  .tree-group > summary{ font-weight:600; color: var(--text-dim); }
  .tree-group > summary:hover, .tree-species > summary:hover{ background: var(--panel-2); }
  .tree-species{ margin-left: 10px; border-left: 1px solid var(--line-soft); padding-left: 4px; }
  .tree-species > summary{ color: var(--text); }
  .tree-species > summary .spname{ font-weight:500; }
  .node-count{ font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); }
  .disabled-hint{ font-size: 10.5px; color: var(--text-faint); padding: 2px 8px 6px; font-style: italic; }
  .species-tag{
    font-size: 9.5px; text-transform:uppercase; letter-spacing:0.4px; color: var(--accent);
    border:1px solid var(--accent-dim); border-radius:3px; padding:1px 5px; flex-shrink:0;
  }
  .assign-species-row{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; padding:6px 8px; }
  .assign-species-row .fname{ flex: 1 1 100%; overflow-wrap:anywhere; }
  .assign-species-row select{
    background: var(--panel-2); color: var(--text); border:1px solid var(--line); border-radius:4px; padding:3px 6px; font-size:12px; flex:1;
  }

  /* unmatched/intake files banner */
  .unmatched{
    background: #2a2213; border: 1px solid #4a3c1a; color: #e8d9a8; border-radius: 7px;
    padding: 10px 14px; margin-bottom: 18px; font-size: 12.5px;
  }
  .unmatched b{ display:block; margin-bottom:6px; color: #f0d98a; }
  .unmatched-row{ display:flex; align-items:center; gap:8px; padding: 5px 0; flex-wrap:wrap; }
  .unmatched-row select{
    background: var(--panel-2); color: var(--text); border:1px solid var(--line); border-radius:4px; padding:3px 6px; font-size:12px;
  }

  /* sticky action bar */
  .actionbar{
    position: fixed; left:0; right:0; bottom:0;
    background: #10140f; border-top: 1px solid var(--line);
    padding: 14px 20px; display:flex; align-items:center; justify-content:center; gap: 18px;
    flex-wrap: wrap;
  }
  .actionbar .summary{ font-size: 12.5px; color: var(--text-dim); font-family: var(--mono); max-width: min(70vw, 760px); overflow-wrap:anywhere; }
  .actionbar .summary strong{ color: var(--text); }

  /* modal */
  .modal-backdrop{
    position: fixed; inset:0; background: rgba(6,9,6,0.72); display:flex; align-items:flex-start; justify-content:center;
    padding: 40px 16px; overflow-y:auto; z-index: 50;
  }
  .modal{
    background: var(--panel); border:1px solid var(--line); border-radius: 10px; width: 100%; max-width: 760px;
    padding: 22px 24px 24px; max-height: calc(100vh - 80px); overflow-y:auto; overflow-x:hidden;
  }
  .modal h2{ margin:0 0 3px; font-size: 17px; overflow-wrap:anywhere; }
  .modal .sub{ color: var(--text-faint); font-size: 12.5px; margin-bottom: 18px; font-family: var(--mono); overflow-wrap:anywhere; }
  .field-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 8px; }
  .field-grid.full{ grid-template-columns: 1fr; }
  .field{ display:flex; flex-direction:column; gap:4px; }
  .field.span2{ grid-column: 1 / -1; }
  .field label{ font-size: 11px; color: var(--text-faint); }
  .field input, .field select{
    background: var(--panel-2); border:1px solid var(--line); color:var(--text);
    padding: 8px 9px; border-radius:5px; font-size: 13px; font-family: var(--sans);
  }
  .field input:focus, .field select:focus{ outline:none; border-color: var(--accent); }
  .modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top: 20px; }

  /* pin product accordion */
  .product-acc{ border:1px solid var(--line-soft); border-radius:7px; margin-bottom:10px; overflow:hidden; }
  .product-acc summary{
    cursor:pointer; padding: 10px 12px; background: var(--panel-2); font-size: 13px;
    display:flex; align-items:center; justify-content:space-between; list-style:none;
  }
  .product-acc summary::-webkit-details-marker{ display:none; }
  .product-acc summary .pname{ font-weight:600; }
  .product-acc summary .pmeta{ color: var(--text-faint); font-family: var(--mono); font-size:11.5px; }
  .matrix-table{ width:100%; border-collapse:collapse; }
  .matrix-table th{
    text-align:left; font-size: 10.5px; color: var(--text-faint); font-weight:500; padding: 6px 8px;
    border-bottom:1px solid var(--line-soft);
  }
  .matrix-table td{ padding: 3px 8px; border-bottom:1px solid var(--line-soft); }
  .matrix-table input{
    width: 100%; background: transparent; border: 1px solid transparent; color: var(--text);
    padding: 5px 6px; border-radius:4px; font-family: var(--mono); font-size:12.5px;
  }
  .matrix-table input:hover{ border-color: var(--line); }
  .matrix-table input:focus{ outline:none; border-color: var(--accent); background: var(--panel-2); }
  .matrix-table tr:hover{ background: rgba(255,255,255,0.02); }
  .matrix-wrap{ padding: 4px 8px 12px; max-height: 320px; overflow-y:auto; }
  .row-del{ background:none; border:none; color:var(--text-faint); cursor:pointer; font-size:14px; }
  .row-del:hover{ color: var(--danger); }
  .add-row-btn{ margin: 6px 8px 10px; }

  /* view source */
  pre.xmlsource{
    background: #0e120e; border:1px solid var(--line-soft); border-radius:6px; padding:12px;
    font-family: var(--mono); font-size:11.5px; max-height: 480px; overflow:auto; white-space:pre-wrap; word-break:break-word;
    color: #b9c9b6;
  }

  .toast{
    position:fixed; top:18px; left:50%; transform:translateX(-50%);
    background: #23301f; border:1px solid var(--ok); color:#dff0dc; padding:9px 16px; border-radius:6px;
    font-size:13px; z-index: 100; box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  }
  .toast.err{ border-color: var(--danger); background:#301e18; color:#f4d9cf; }

  .hint{ font-size:11.5px; color:var(--text-faint); margin-top:2px; }
  input[type=file]{ display:none; }

  /* ---------- app shell (added for the real frontend) ---------- */
  a{ color: var(--accent); }
  .center-screen{ min-height: 100vh; display:flex; align-items:center; justify-content:center; padding: 24px; }
  .login-card{ width: 100%; max-width: 380px; background: var(--panel); border:1px solid var(--line); border-radius: 10px; padding: 26px 26px 24px; }
  .login-card h1{ font-size: 20px; margin: 0 0 4px; }
  .login-card p{ margin: 0 0 18px; color: var(--text-dim); font-size: 13px; }
  .login-card .field{ margin-bottom: 12px; }
  .login-card .btn{ width:100%; margin-top: 6px; }
  .error-box{ background:#301e18; border:1px solid var(--danger); color:#f4d9cf; border-radius:6px; padding:9px 12px; font-size:12.5px; margin: 10px 0; }
  .ok-box{ background:#1e2d1f; border:1px solid var(--ok); color:#dff0dc; border-radius:6px; padding:9px 12px; font-size:12.5px; margin: 10px 0; }
  .warn-box{ background:#2a2213; border:1px solid #4a3c1a; color:#e8d9a8; border-radius:6px; padding:9px 12px; font-size:12.5px; margin: 10px 0; }
  .topbar{ display:flex; align-items:flex-end; justify-content:space-between; gap: 20px; flex-wrap:wrap; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
  .topbar h1{ font-size: 21px; font-weight:600; margin:0 0 2px; }
  .topbar .who{ color: var(--text-faint); font-size: 12px; }
  .topbar .right{ display:flex; align-items:flex-end; gap: 14px; flex-wrap:wrap; }
  .mode-badge{ font-size: 11px; color: #241a08; background: var(--accent); border-radius: 4px; padding: 2px 7px; font-weight:600; margin-left: 8px; vertical-align: middle; }
  .tabs{ display:flex; gap: 4px; margin-bottom: 18px; }
  .tab{ appearance:none; background:transparent; border:1px solid transparent; color: var(--text-dim); padding: 7px 14px; border-radius: 6px; cursor:pointer; font-size: 13px; font-family: var(--sans); }
  .tab:hover{ color: var(--text); }
  .tab.active{ background: var(--panel-2); border-color: var(--line); color: var(--text); }
  .badge{ display:inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 10px; border:1px solid var(--line); color: var(--text-dim); }
  .badge.sent{ color:#cfe9cc; border-color: var(--ok); background:#1e2d1f; }
  .badge.failed{ color:#f4d9cf; border-color: var(--danger); background:#301e18; }
  .badge.pending{ color:#e8d9a8; border-color:#4a3c1a; background:#2a2213; }
  table.data{ width:100%; border-collapse:collapse; font-size: 12.5px; }
  table.data th{ text-align:left; font-weight:500; color: var(--text-faint); font-size: 11px; padding: 7px 10px; border-bottom:1px solid var(--line); }
  table.data td{ padding: 8px 10px; border-bottom:1px solid var(--line-soft); vertical-align: top; overflow-wrap:anywhere; }
  table.data tr.clickable{ cursor:pointer; }
  table.data tr.clickable:hover{ background: var(--panel-2); }
  .mono{ font-family: var(--mono); }
  .icon-link{ color: var(--text-faint); text-decoration:none; font-size: 13px; padding: 3px 5px; border-radius:4px; }
  .icon-link:hover{ color: var(--text); background: var(--line-soft); }
  .matrix-table input.invalid, .field input.invalid{ border-color: var(--danger); }
  .busy{ opacity: .6; pointer-events:none; }
  .empty-state{ color: var(--text-faint); text-align:center; padding: 40px 10px; font-size: 13px; }
  .kv{ display:grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 14px; }
  .kv dt{ color: var(--text-faint); } .kv dd{ margin:0; word-break: break-word; }
  .modal.wide{ max-width: 860px; }
  .actionbar .env-name{ color: var(--text); }

  .toast{ max-width: min(90vw, 560px); overflow-wrap:anywhere; }
  .topbar .who{ overflow-wrap:anywhere; }
  .rename-row{ display:flex; gap:8px; align-items:center; }
  .rename-row input{ flex:1; min-width:0; }
