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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1923;
  color: #e0e0e0;
  min-height: 100vh;
}

a { color: #4ecdc4; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 40px;
  background: #1a2836;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-container h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #4ecdc4;
  font-size: 1.5em;
}

.login-container form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-container input {
  padding: 12px 16px;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  background: #0f1923;
  color: #e0e0e0;
  font-size: 1em;
  transition: border-color 0.2s;
}

.login-container input:focus {
  outline: none;
  border-color: #4ecdc4;
}

.login-container button {
  padding: 12px;
  background: #4ecdc4;
  color: #0f1923;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-container button:hover { opacity: 0.9; }

.error {
  color: #ff6b6b;
  text-align: center;
  font-size: 0.9em;
}

/* Dashboard */
.top-bar {
  background: #1a2836;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2a3a4a;
}

.top-bar h1 {
  color: #4ecdc4;
  font-size: 1.3em;
}

.top-bar .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar .user-info span {
  color: #a0b0c0;
}

.top-bar .user-info .username {
  color: #4ecdc4;
  font-weight: 600;
}

.btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }

.btn-logout {
  background: #ff6b6b;
  color: #fff;
}

.btn-primary {
  background: #4ecdc4;
  color: #0f1923;
  font-weight: 600;
}

.btn-danger {
  background: #ff6b6b;
  color: #fff;
}

.btn-secondary {
  background: #2a3a4a;
  color: #e0e0e0;
}

/* Menu */
.menu-bar {
  background: #1a2836;
  padding: 12px 32px;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid #2a3a4a;
  flex-wrap: wrap;
}

.menu-bar .btn {
  padding: 10px 24px;
}

.menu-bar .btn.active {
  background: #4ecdc4;
  color: #0f1923;
  box-shadow: 0 0 12px rgba(78, 205, 196, 0.3);
}

/* Main layout */
.main-layout {
  display: flex;
  gap: 24px;
  padding: 24px 32px 0;
}

.content-area {
  flex: 1;
  min-width: 0;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
}

.graph-fullwidth {
  padding: 0 32px 24px;
}

.graph-fullwidth .panel {
  width: 100%;
}

/* Sidebar panels */
.panel {
  background: #1a2836;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel h3 {
  color: #4ecdc4;
  margin-bottom: 12px;
  font-size: 1em;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.panel ul {
  list-style: none;
}

.panel ul li {
  padding: 6px 0;
  color: #a0b0c0;
  font-size: 0.9em;
}

.panel ul li::before {
  content: "●";
  color: #4ecdc4;
  margin-right: 8px;
  font-size: 0.7em;
}

/* Graph */
#graph-container {
  width: 100%;
  height: 400px;
  border-radius: 8px;
  overflow: hidden;
}

/* Forms */
.form-section {
  background: #1a2836;
  border-radius: 12px;
  padding: 24px;
}

.form-section h2 {
  color: #4ecdc4;
  margin-bottom: 20px;
  font-size: 1.2em;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #a0b0c0;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  background: #0f1923;
  color: #e0e0e0;
  font-size: 0.95em;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #4ecdc4;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.success {
  color: #4ecdc4;
  text-align: center;
  padding: 10px;
  background: rgba(78, 205, 196, 0.1);
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Delete */
.delete-section {
  text-align: center;
}

.delete-section p {
  color: #a0b0c0;
  margin-bottom: 16px;
}

.delete-section input {
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  border: 1px solid #ff6b6b;
  border-radius: 8px;
  background: #0f1923;
  color: #e0e0e0;
  margin-bottom: 16px;
}

.delete-section .entry-name {
  color: #ff6b6b;
  font-weight: 600;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: #a0b0c0;
  padding: 40px;
}

.empty-state p {
  margin-bottom: 8px;
}

/* Graph legend */
.graph-legend {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  padding: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.paper-type-legend {
  border-top: 1px solid #2a3a4a;
  padding-top: 14px;
  margin-top: 4px;
}

.legend-title {
  font-size: 0.8em;
  color: #4ecdc4;
  font-weight: 600;
  margin-right: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8em;
  color: #a0b0c0;
}

.legend-color {
  width: 20px;
  height: 3px;
  border-radius: 2px;
}

.legend-dash {
  width: 20px;
  height: 0;
  border-top: 3px dashed;
}

.legend-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Term filter */
.term-filter {
  margin-top: 16px;
  padding: 16px;
  background: #1a2836;
  border-radius: 12px;
}

.term-filter h4 {
  color: #4ecdc4;
  font-size: 0.85em;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.term-groups {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.term-group {
  flex: 1;
  min-width: 180px;
}

.term-group h5 {
  color: #a0b0c0;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  border-bottom: 1px solid #2a3a4a;
  padding-bottom: 4px;
}

.term-checkbox {
  display: inline-block;
  padding: 3px 0;
  color: #e0e0e0;
  font-size: 0.85em;
  cursor: pointer;
  margin-right: 12px;
}

.term-checkbox input {
  margin-right: 5px;
  vertical-align: middle;
  accent-color: #4ecdc4;
}

/* ML results */
.ml-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.85em;
}

.ml-table th,
.ml-table td {
  border: 1px solid #2a3a4a;
  padding: 6px 10px;
  text-align: left;
  color: #e0e0e0;
}

.ml-table th {
  background: #0f1923;
  color: #4ecdc4;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.75em;
}

.ml-table tr:nth-child(even) td {
  background: #16232f;
}

.ml-chip {
  display: inline-block;
  background: #2a3a4a;
  color: #4ecdc4;
  border-radius: 12px;
  padding: 3px 10px;
  margin: 3px;
  font-size: 0.8em;
}

.ml-progress {
  width: 100%;
  height: 14px;
  background: #16232f;
  border: 1px solid #2a3a4a;
  border-radius: 7px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.ml-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5dade2, #bb8fce);
  border-radius: 7px;
  transition: width 0.5s ease;
}

.ml-progress-label {
  color: #a0b0c0;
  font-size: 0.85em;
  margin-bottom: 2px;
}

.grouping-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #a0b0c0;
  font-size: 0.9em;
  margin: 10px 0;
  cursor: pointer;
  user-select: none;
}

.grouping-toggle input {
  accent-color: #4ecdc4;
}

.cluster-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.cluster-legend .legend-item {
  align-items: center;
  font-size: 0.8em;
  color: #a0b0c0;
  max-width: 260px;
}

.cluster-legend .legend-item .legend-circle {
  flex: 0 0 auto;
}

/* Taxonomy tree */
.taxonomy-tree {
    margin-top: 10px;
    background: #0f1923;
    border: 1px solid #2a3a4a;
    border-radius: 8px;
    overflow: hidden;
}

.taxonomy-header {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.82em;
    color: #4ecdc4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.taxonomy-header:hover {
    background: #1a2836;
}

.taxonomy-arrow {
    font-size: 0.7em;
    transition: transform 0.15s;
}

.taxonomy-body {
    display: none;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0 8px 0;
    border-top: 1px solid #2a3a4a;
}

.taxonomy-body ul {
    list-style: none;
    padding-left: 18px;
    margin: 0;
}

.taxonomy-body .taxonomy-root {
    padding-left: 8px;
}

.taxonomy-body li {
    padding: 1px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
}

.taxonomy-toggle {
    display: inline-block;
    width: 14px;
    font-size: 0.6em;
    cursor: pointer;
    color: #4ecdc4;
    flex-shrink: 0;
    text-align: center;
    user-select: none;
}

.taxonomy-toggle:hover {
    color: #7eddd6;
}

.taxonomy-spacer {
    visibility: hidden;
}

.taxonomy-kw {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.82em;
    color: #e0e0e0;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
}

.taxonomy-kw:hover {
    background: #4ecdc4;
    color: #0f1923;
}

.taxonomy-body::-webkit-scrollbar {
    width: 6px;
}

.taxonomy-body::-webkit-scrollbar-track {
    background: #0f1923;
}

.taxonomy-body::-webkit-scrollbar-thumb {
    background: #2a3a4a;
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .graph-fullwidth {
    padding: 0 16px 16px;
  }
}
