:root {
  --bg: #0e1116;
  --panel: #161b22;
  --muted: #8b949e;
  --text: #e6edf3;
  --accent: #2f81f7;
  --accent-2: #1f6feb;
  --border: #30363d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  display: flex;
  flex-direction: column;
  overflow: hidden; /* page itself doesn't scroll */
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.controls {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.control-group { display: flex; align-items: center; gap: 8px; }
.control-label { color: var(--muted); font-size: 12px; }

.segmented { display: inline-flex; align-items: center; background: #0b0e13; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented input { appearance: none; margin: 0; width: 0; height: 0; }
.segmented span { display: inline-block; padding: 6px 10px; color: var(--text); cursor: pointer; }
.segmented input:checked + span { background: var(--accent); color: white; }

.search-group { flex: 1 1 320px; }
#search-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b0e13;
  color: var(--text);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 0 16px 12px 16px;
}
.filter label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.filter select {
  width: 100%;
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b0e13;
  color: var(--text);
}

.main {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1 1 auto;
  min-height: 0; /* allow children to size and scroll internally */
}

.list-panel {
  border-right: 1px solid var(--border);
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.list-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.muted { color: var(--muted); font-size: 12px; }

.rows-list { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 0; overflow: auto; }
.rows-list li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.rows-list li:hover { background: #0b0e13; }
.rows-list li.active { background: rgba(47, 129, 247, 0.15); }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.preview-panel { position: relative; background: var(--bg); overflow: hidden; min-height: 0; }
.preview-container { height: 100%; }
.pdf-canvas-container { 
  width: 100%; 
  height: 100%; 
  display: none; 
  overflow: auto;
  padding: 10px;
  box-sizing: border-box;
  position: relative;
}
.pdf-canvas { 
  display: block; 
  margin: 0 auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.preview-message { padding: 24px; color: var(--muted); }

.fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  display: none;
}
.fab:hover { background: var(--accent-2); }

.footer { padding: 8px 16px; border-top: 1px solid var(--border); background: var(--panel); }

/* Tablet and small desktop */
@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; }
  .preview-container { position: static; height: 60vh; }
}

/* Mobile phones */
@media (max-width: 768px) {
  /* Allow page scrolling on mobile */
  body {
    overflow: auto;
  }
  
  /* Header adjustments */
  .controls {
    flex-direction: column;
    gap: 16px;
    padding: 12px;
    align-items: stretch;
  }
  
  .control-group {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .control-group .segmented {
    width: 100%;
  }
  
  .control-group .segmented span {
    flex: 1;
    text-align: center;
    padding: 10px;
  }
  
  .search-group {
    flex: none;
  }
  
  /* Filters grid - single column on mobile */
  .filters {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
  
  /* Main layout - allow normal document flow */
  .main {
    display: block;
    flex: none;
    min-height: auto;
  }
  
  /* List panel - scrollable with max height */
  .list-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
    min-height: auto;
    overflow: auto;
  }
  
  /* Preview panel - fixed height, part of page flow */
  .preview-panel {
    overflow: visible;
    min-height: auto;
  }
  
  .preview-container {
    height: 65vh;
    position: relative;
  }
  
  /* PDF canvas adjustments */
  .pdf-canvas-container {
    padding: 8px;
    height: 100%;
  }
  
  /* FAB button adjustments */
  .fab {
    right: 12px;
    bottom: 12px;
    padding: 12px 16px;
    font-size: 14px;
  }
  
  /* Logo adjustments */
  .site-logo {
    width: 120px;
    right: 12px;
    bottom: 12px;
  }
  
  /* Footer adjustments */
  .footer {
    padding: 8px 12px;
  }
}

/* Small mobile phones */
@media (max-width: 480px) {
  .controls {
    padding: 8px;
    gap: 12px;
  }
  
  .filters {
    padding: 8px;
  }
  
  .list-panel {
    max-height: 35vh;
  }
  
  .preview-container {
    height: 50vh;
  }
  
  .list-header {
    padding: 8px 12px;
  }
  
  .rows-list li {
    padding: 10px 12px;
  }
  
  .row-title {
    font-size: 14px;
  }
  
  .row-sub {
    font-size: 11px;
  }
  
  .site-logo {
    width: 100px;
    right: 8px;
    bottom: 8px;
  }
  
  .fab {
    right: 8px;
    bottom: 8px;
    padding: 10px 14px;
    font-size: 13px;
  }
}

.btn {
  background: #0b0e13;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.filter label.inline { display: inline-flex; align-items: center; gap: 8px; }

.site-logo {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 220px;
  height: auto;
  opacity: 0.9;
  pointer-events: none;
}


