:root {
  --bg: #0f0f11;
  --surface: #17171a;
  --surface2: #1e1e23;
  --surface3: #26262d;
  --border: #2e2e38;
  --border2: #3a3a48;
  --accent: #4f8ef7;
  --accent2: #6fa3f8;
  --accent-dim: #1a2a4a;
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #5a5a72;
  --green: #3ecf8e;
  --green-dim: #0d2a1f;
  --amber: #f5a623;
  --amber-dim: #2a1f0a;
  --red: #f56565;
  --red-dim: #2a1010;
  --teal: #4ec9d0;
  --teal-dim: #0e2a2c;
  --purple: #b07ff0;
  --purple-dim: #2a1a3a;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;
}

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

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

/* LOGIN */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-mark { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: 3px; text-transform: uppercase; }
.logo-title { font-size: 20px; font-weight: 600; margin-top: 4px; }
.logo-sub { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; }
.logo { padding: 20px; border-bottom: 1px solid var(--border); }
.logo .logo-mark { font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: 2px; }
.logo .logo-title { font-size: 15px; font-weight: 600; margin-top: 2px; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text2); font-size: 13px; text-decoration: none; transition: all 0.15s; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent2); font-weight: 500; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.role-badge { font-size: 10px; background: var(--surface3); color: var(--text3); padding: 2px 6px; border-radius: 999px; font-family: var(--mono); }
.btn-logout { font-size: 12px; color: var(--text3); text-decoration: none; }
.btn-logout:hover { color: var(--red); }
.main { margin-left: 220px; flex: 1; padding: 28px 32px; }

/* PAGE HEADER */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 600; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-title { font-size: 11px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 16px; }

/* STATS */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 28px; font-weight: 600; font-family: var(--mono); }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* GRID */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* BARS */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { font-size: 13px; width: 160px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 6px; background: var(--surface3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.5s; }
.bar-blue { background: var(--accent); }
.bar-green { background: var(--green); }
.bar-amber { background: var(--amber); }
.bar-purple { background: var(--purple); }
.bar-teal { background: var(--teal); }
.bar-red { background: var(--red); }
.bar-count { font-family: var(--mono); font-size: 12px; color: var(--text3); width: 32px; text-align: right; }

/* TABLE */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
.table tbody tr:hover td { background: var(--surface2); }
.table tbody tr:last-child td { border-bottom: none; }

/* TOOLBAR */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; align-items: center; }
.search-form input[type=text] { min-width: 200px; flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.result-count { font-size: 13px; color: var(--text2); font-family: var(--mono); white-space: nowrap; }

/* INPUTS */
input[type=text], input[type=email], input[type=password], select, textarea {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: 13px; padding: 8px 12px;
  outline: none; transition: border 0.15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text3); }
textarea { resize: vertical; }

/* FORM */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: var(--surface2); color: var(--text); font-family: var(--font); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn:hover { background: var(--surface3); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-green { background: var(--green); border-color: var(--green); color: #000; font-weight: 600; }
.btn-green:hover { opacity: 0.85; }
.btn-danger { border-color: var(--red-dim); color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red-dim); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* BADGES */
.badge { display: inline-block; padding: 3px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500; }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-red { background: var(--red-dim); color: var(--red); }

/* KW TAGS */
.kw-tag { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11px; font-family: var(--mono); margin: 2px; }
.tag-blue { background: var(--accent-dim); color: var(--accent2); border: 1px solid #2a3a6a; }
.tag-green { background: var(--green-dim); color: var(--green); border: 1px solid #1a4a38; }
.tag-amber { background: var(--amber-dim); color: var(--amber); border: 1px solid #4a3820; }
.tag-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid #4a3060; }
.tag-teal { background: var(--teal-dim); color: var(--teal); border: 1px solid #1a4a50; }
.tag-red { background: var(--red-dim); color: var(--red); border: 1px solid #4a2828; }
.cat-label { font-size: 10px; color: var(--text3); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.5px; }

/* KEYWORDS PAGE */
.kw-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.category-list { display: flex; flex-direction: column; gap: 4px; }
.category-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); background: var(--surface2); text-decoration: none; color: var(--text); font-size: 13px; transition: all 0.15s; }
.category-item:hover { border-color: var(--border2); }
.category-item.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent2); }
.cat-badge { font-family: var(--mono); font-size: 11px; background: var(--surface3); color: var(--text3); padding: 2px 7px; border-radius: 999px; }
.category-item.active .cat-badge { background: var(--accent-dim); color: var(--accent); }
.import-label { display: block; padding: 12px; border: 1.5px dashed var(--border2); border-radius: var(--radius-sm); text-align: center; cursor: pointer; font-size: 13px; color: var(--text2); transition: all 0.15s; }
.import-label:hover { border-color: var(--accent); color: var(--accent2); background: var(--accent-dim); }
.kw-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.kw-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.kw-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; min-height: 40px; }
.kw-tag-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--surface3); border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--mono); color: var(--text); }
.kw-del { background: none; border: none; cursor: pointer; color: var(--text3); font-size: 16px; line-height: 1; padding: 0; }
.kw-del:hover { color: var(--red); }
.kw-add-form { display: flex; gap: 8px; }

/* ACTIVITIES */
.act-list { display: flex; flex-direction: column; gap: 12px; }
.act-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.act-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.match-badge { font-family: var(--mono); font-size: 11px; background: var(--surface3); color: var(--text3); padding: 3px 8px; border-radius: 999px; }

/* UPLOAD / PARSE */
.drop-zone { border: 2px dashed var(--border2); border-radius: var(--radius); padding: 40px 24px; text-align: center; cursor: pointer; transition: all 0.2s; }
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); background: var(--accent-dim); }
.drop-icon { font-size: 36px; display: block; margin-bottom: 10px; }
.drop-zone h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.drop-zone p { font-size: 13px; color: var(--text2); }
.drop-zone span { font-size: 11px; color: var(--text3); margin-top: 6px; display: block; }
.file-queue { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.fname { flex: 1; font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsize { color: var(--text3); font-size: 11px; font-family: var(--mono); }
.file-status { font-size: 11px; font-family: var(--mono); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.st-pending { background: var(--surface3); color: var(--text3); }
.st-processing { background: var(--amber-dim); color: var(--amber); }
.st-done { background: var(--green-dim); color: var(--green); }
.st-duplicate { background: var(--amber-dim); color: var(--amber); }
.st-error { background: var(--red-dim); color: var(--red); }
.file-remove { cursor: pointer; color: var(--text3); font-size: 14px; }
.file-remove:hover { color: var(--red); }
.parse-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.parse-status { font-size: 12px; color: var(--text2); font-family: var(--mono); }
.progress-wrap { flex: 1; height: 4px; background: var(--surface3); border-radius: 999px; overflow: hidden; min-width: 100px; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s; width: 0; }

/* PAGINATION */
.pagination { display: flex; gap: 4px; padding: 16px; justify-content: center; border-top: 1px solid var(--border); }
.page-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 13px; text-decoration: none; color: var(--text2); border: 1px solid var(--border); background: var(--surface2); }
.page-btn:hover, .page-btn.active { background: var(--accent-dim); color: var(--accent2); border-color: var(--accent); }

/* ALERTS */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.flash-top { position: fixed; top: 16px; right: 24px; z-index: 999; min-width: 280px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid #1a4a38; }
.alert-danger { background: var(--red-dim); color: var(--red); border: 1px solid #4a2828; }
.alert-warning { background: var(--amber-dim); color: var(--amber); border: 1px solid #4a3820; }

/* MISC */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-icon { font-size: 36px; display: block; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }
.text-muted { color: var(--text3); }
.text-accent { color: var(--accent2); }
.mono { font-family: var(--mono); }
.text-center { text-align: center; }

@media (max-width: 900px) {
  .sidebar { width: 180px; }
  .main { margin-left: 180px; padding: 20px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .kw-layout { grid-template-columns: 1fr; }
}
