
  :root {
    --bg:        #0e0e0f;
    --surface:   #16161a;
    --surface2:  #1e1e24;
    --surface3:  #26262e;
    --border:    #2e2e38;
    --border2:   #3a3a46;
    --text:      #e8e6df;
    --text2:     #9e9c96;
    --text3:     #5c5a56;
    --accent:    #c9a96e;
    --accent2:   #8b6f3e;
    --accent-bg: #1f1a10;
    --blue:      #6b9fd4;
    --blue-bg:   #0f1820;
    --green:     #7db87a;
    --green-bg:  #0e1a0e;
    --red:       #d47a7a;
    --red-bg:    #1a0f0f;
    --purple:    #a888d4;
    --purple-bg: #160f1a;
    --radius:    6px;
    --radius-lg: 10px;
    --font-head: 'Syne', sans-serif;
    --font-body: 'Lora', serif;
    --font-mono: 'DM Mono', monospace;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
  }

  /* ── HEADER ── */
  .app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .logo {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .logo-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.7;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  /* ── TOOLBAR ── */
  .toolbar {
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }

  .search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 400px;
  }

  .search-wrap svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.35;
    pointer-events: none;
  }

  .search-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 7px 12px 7px 34px;
    outline: none;
    transition: border-color 0.15s;
  }

  .search-input:focus { border-color: var(--accent2); }
  .search-input::placeholder { color: var(--text3); }

  .filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .filter-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    white-space: nowrap;
  }

  select.filter-select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text2);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 6px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
  }

  select.filter-select:focus { border-color: var(--accent2); }

  .spacer { flex: 1; }

  .stat-chip {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 12px;
    white-space: nowrap;
  }

  .stat-chip span { color: var(--accent); font-weight: 500; }

  /* ── BUTTONS ── */
  .btn {
    font-family: var(--font-head);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 7px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }

  .btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }

  .btn-accent {
    background: var(--accent-bg);
    border-color: var(--accent2);
    color: var(--accent);
  }

  .btn-accent:hover { background: #2a2010; color: var(--accent); }

  /* ── TAB BAR ── */
  .tab-bar {
    display: flex;
    gap: 0;
    padding: 0 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .tab {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
  }

  .tab:hover { color: var(--text2); }
  .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  /* ── TABLE ── */
  .table-wrap {
    overflow-x: auto;
    padding: 1.5rem 2rem;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
  }

  .group-header-row th {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 12px 5px;
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
  }

  .gh-biblio  { background: var(--blue-bg);   color: var(--blue);   border-bottom: 2px solid #1a3a5c; }
  .gh-pipeline{ background: var(--green-bg);  color: var(--green);  border-bottom: 2px solid #1a3a1a; }
  .gh-content { background: var(--purple-bg); color: var(--purple); border-bottom: 2px solid #2a1a3a; }
  .gh-critical{ background: var(--accent-bg); color: var(--accent); border-bottom: 2px solid #3a2a10; }

  .col-header-row th {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--text3);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--surface);
    position: sticky;
    top: 0;
    letter-spacing: 0.03em;
  }

  .col-biblio   { border-top: 1px solid #1a3a5c; }
  .col-pipeline { border-top: 1px solid #1a3a1a; }
  .col-content  { border-top: 1px solid #2a1a3a; }
  .col-critical { border-top: 1px solid #3a2a10; }

  tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    cursor: pointer;
  }

  tbody tr:hover { background: var(--surface2); }
  tbody tr.expanded { background: var(--surface2); }

  td {
    padding: 11px 12px;
    vertical-align: top;
    font-size: 13px;
    color: var(--text2);
    max-width: 180px;
  }

  td.td-title {
    font-family: var(--font-body);
    font-style: italic;
    color: var(--text);
    font-size: 13px;
    max-width: 220px;
  }

  td.td-authors {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    max-width: 140px;
  }

  td.td-date {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    white-space: nowrap;
  }

  .cell-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
  }

  .cell-dash { color: var(--text3); font-size: 12px; }

  /* badges */
  .badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 99px;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }

  .b-unread    { background: var(--surface3); color: var(--text3);   border: 1px solid var(--border2); }
  .b-partial   { background: #1f1a0a;         color: #d4a84a;        border: 1px solid #3a2e10; }
  .b-read      { background: var(--green-bg); color: var(--green);   border: 1px solid #1f3a1f; }
  .b-annotated { background: #0e1a14;         color: #7ac4a0;        border: 1px solid #1a3a28; }

  .b-high      { background: var(--red-bg);    color: var(--red);    border: 1px solid #3a1f1f; }
  .b-medium    { background: #1a1510;          color: #d4a050;       border: 1px solid #3a2810; }
  .b-low       { background: var(--green-bg);  color: var(--green);  border: 1px solid #1f3a1f; }

  .score-pips {
    display: flex;
    gap: 4px;
    align-items: center;
  }

  .pip {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--border2);
  }

  .pip.on { background: var(--accent); }

  .link-cell a {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--blue);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.1s;
  }

  .link-cell a:hover { opacity: 1; text-decoration: underline; }

  /* ── EXPANDED ROW ── */
  .expand-row td {
    padding: 0;
    border-bottom: 1px solid var(--border);
  }

  .expand-panel {
    padding: 1.5rem 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    background: var(--surface2);
    border-top: 1px solid var(--border);
  }

  .field-block { display: flex; flex-direction: column; gap: 4px; }

  .field-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text3);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .field-value {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text);
    line-height: 1.65;
  }

  .field-value.mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text2);
  }

  .field-value.quote-val {
    font-style: italic;
    color: var(--accent);
    border-left: 2px solid var(--accent2);
    padding-left: 10px;
    line-height: 1.7;
  }

  .expand-actions {
    display: flex;
    gap: 8px;
    padding: 0 2rem 1.25rem;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
  }

  /* ── EMPTY STATE ── */
  .empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text3);
    font-family: var(--font-mono);
    font-size: 13px;
  }

  .empty-state p:first-child {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.3;
  }

  /* ── MODAL ── */
  .modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 200;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
  }

  .modal-backdrop.open { display: flex; }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 740px;
    padding: 2rem;
    position: relative;
    animation: modal-in 0.18s ease;
  }

  @keyframes modal-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .modal-title {
    font-family: var(--font-head);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .modal-close {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: var(--radius);
    transition: color 0.1s;
  }

  .modal-close:hover { color: var(--text); }

  .modal-section-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 1.25rem 0 0.75rem;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }

  .modal-section-label:first-of-type { margin-top: 0; }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .form-grid.full { grid-template-columns: 1fr; }

  .form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .form-field label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text3);
    letter-spacing: 0.03em;
  }

  .form-field input,
  .form-field select,
  .form-field textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.15s;
    resize: vertical;
  }

  .form-field input:focus,
  .form-field select:focus,
  .form-field textarea:focus { border-color: var(--accent2); }

  .form-field input::placeholder,
  .form-field textarea::placeholder { color: var(--text3); font-style: italic; }

  .form-field select { cursor: pointer; }

  .form-field textarea { min-height: 72px; }

  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
  }

  /* ── SCROLLBAR ── */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: var(--bg); }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text3); }

  /* ── TOAST ── */
  .toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--surface3);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    padding: 10px 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    z-index: 999;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s;
    pointer-events: none;
  }

  .toast.show { opacity: 1; transform: translateY(0); }