:root {
  --bg: #080c10;
  --panel: #0f1720;
  --line: #27313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --brand: #00b386;
  --brand-dark: #00d4ff;
  --danger: #ff5f57;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  border-radius: 12px;
  padding: 10px 12px;
  color: #334155;
  font-weight: 600;
}

.nav-link.active {
  background: #eaf1ff;
  color: #1d4ed8;
}

.content {
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-left h2 {
  margin: 0;
  font-size: 18px;
}

.topbar-left small {
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
}

.btn:hover {
  background: var(--brand-dark);
}

.btn.soft {
  background: #eef2ff;
  color: #1d4ed8;
}

.btn.soft:hover {
  background: #e0e7ff;
}

.btn.danger {
  background: var(--danger);
}

.view {
  padding: 14px;
  overflow: auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.hero h3 {
  margin: 0;
  font-size: 20px;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 14px;
}

.document-layout {
  display: grid;
  grid-template-columns: 1fr;
}

.document-list-card {
  min-width: 0;
}

.stack {
  display: grid;
  gap: 14px;
}

.status-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: #1d4ed8;
}

.badge.success {
  background: #ecfdf5;
  color: #047857;
}

.badge.danger {
  background: #fef2f2;
  color: #b91c1c;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 28%, rgba(255, 255, 255, 0.88), transparent 34%),
    radial-gradient(circle at 82% 30%, rgba(219, 234, 254, 0.9), transparent 38%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(239, 246, 255, 0.92));
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow: auto;
}

.login-brandmark {
  padding: 22px 26px 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-shell {
  min-height: calc(100vh - 56px);
  width: 100%;
  display: grid;
  place-items: center;
  padding: 28px 16px 40px;
}

.login-box {
  width: min(420px, 92vw);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  padding: 34px 34px 26px;
  box-shadow: 0 18px 50px rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(12px);
}

.login-header {
  text-align: center;
  margin-bottom: 18px;
}

.login-header h3 {
  margin: 0;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  background: #f3f6fb;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #dbeafe;
  border-color: #bfdbfe;
  background: #fff;
}

.login-message {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.login-submit {
  width: 100%;
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #6b8df2);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}

.login-submit:hover {
  background: linear-gradient(90deg, #1d4ed8, #5c7ee6);
}

.login-footer {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 18px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  font-size: 13px;
}

th {
  color: var(--muted);
}

.action-group {
  display: flex;
  gap: 6px;
}

.doc-process {
  min-width: 230px;
  display: grid;
  gap: 8px;
  color: #475569;
}

.doc-process-lines {
  display: grid;
  gap: 3px;
  font-size: 12px;
  line-height: 1.35;
}

.doc-process-lines strong {
  color: #64748b;
}

.doc-progress-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.doc-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  transition: width 240ms ease;
}

.upload-drop-zone {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 150px;
  border: 1px dashed #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
  color: #64748b;
  text-align: center;
  cursor: pointer;
  padding: 18px;
  transition:
    background 180ms ease,
    border-color 180ms ease;
}

.upload-drop-zone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.upload-drop-zone strong {
  color: #1f2937;
}

.upload-drop-zone input {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(2px);
}

.upload-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 18px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  margin: 0 0 6px;
  font-size: 19px;
}

.modal-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  background: #f3f6fb;
  color: #64748b;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: #e5e7eb;
}

.upload-submit {
  width: 100%;
  margin-top: 14px;
}

body.modal-open {
  overflow: hidden;
}

.selected-files {
  display: grid;
  gap: 6px;
  color: #64748b;
  font-size: 12px;
}

.selected-files span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
}

.document-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.document-toolbar label {
  display: grid;
  gap: 5px;
}

.document-toolbar span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.batch-action-bar {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(148, 163, 184, 0.16);
  backdrop-filter: blur(10px);
}

.batch-action-bar strong {
  margin-right: auto;
  color: #1f2937;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-list span {
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
}

.muted-text {
  color: #94a3b8;
}

.training-example {
  display: block;
  margin-top: 5px;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.35;
}

.role-select {
  width: auto;
  min-width: 120px;
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
}

.mobile-nav {
  display: none;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 8px;
  gap: 8px;
}

.mobile-menu-bar,
.mobile-menu-links,
.mobile-menu-backdrop {
  display: none;
}

body.mobile-menu-open {
  overflow: hidden;
}

.mobile-link {
  flex: 1;
  text-align: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  background: #fff;
}

.mobile-link.active {
  background: #eaf1ff;
  color: #1d4ed8;
  border-color: #c7d2fe;
}

.history-topbar {
  background: #f8fafc;
}

.history-search {
  min-width: 220px;
  border-radius: 999px;
  background: #eef2f7;
  color: #94a3b8;
  padding: 8px 14px;
  font-size: 12px;
}

.history-view {
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 32px 44px;
}

.history-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 22px;
  margin-bottom: 26px;
}

.history-stat,
.history-period-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid #edf0f4;
  border-radius: 24px;
  padding: 26px 28px;
  box-shadow: 0 18px 40px rgba(148, 163, 184, 0.12);
  min-height: 132px;
}

.history-stat::after {
  content: "";
  position: absolute;
  right: 24px;
  top: 22px;
  width: 34px;
  height: 34px;
  border: 4px solid #e5e7eb;
  border-radius: 8px;
  opacity: 0.75;
}

.history-stat span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.history-stat .stat-value {
  font-size: 38px;
  letter-spacing: 0.02em;
}

.history-stat small {
  display: block;
  margin-top: 14px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.history-period-card {
  background: linear-gradient(135deg, #0b5ed7, #5f86f2);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 20px 42px rgba(37, 99, 235, 0.28);
}

.history-period-card span {
  display: block;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.history-period-card strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.history-period-card small {
  display: inline-flex;
  margin-top: 18px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 11px;
  font-weight: 800;
}

.history-filter-bar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  padding: 6px;
}

.filter-label {
  color: #9ca3af;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-filters {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(150px, 0.9fr) repeat(2, minmax(150px, 1fr)) 44px;
  gap: 10px;
  align-items: center;
}

.history-filters label {
  position: relative;
}

.history-filters label span {
  position: absolute;
  left: 14px;
  top: -9px;
  background: #080c10;
  padding: 0 5px;
  color: #c9d1d9;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-filters input,
.history-filters select {
  min-height: 54px;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 12px 16px;
  background: #0a1118;
  color: #e6edf3;
}

.history-filters input:disabled {
  color: #6e7681;
  background: #0f1720;
}

.history-filters input::placeholder {
  color: #8b949e;
}

.history-filters input:focus,
.history-filters select:focus {
  outline: 2px solid rgba(0, 212, 255, 0.24);
  border-color: #00d4ff;
  background: #0c141c;
}

.history-filters .btn {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  padding: 0;
  font-size: 0;
}

.history-filters .btn::before {
  content: ">";
  font-size: 18px;
  line-height: 1;
}

.history-list {
  display: grid;
  gap: 0;
  position: relative;
  padding-left: 42px;
}

.history-list::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.history-thread {
  position: relative;
  padding: 0 0 34px;
}

.history-thread-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 26px;
  margin-bottom: 14px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.history-dot {
  position: absolute;
  left: -40px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #0b5ed7;
  box-shadow: 0 0 0 5px #eef5ff;
}

.history-thread-meta strong {
  margin-left: auto;
  color: #94a3b8;
  font-weight: 800;
}

.history-full-chat {
  border: 0;
  padding: 0;
  background: transparent;
  color: #0b5ed7;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.history-user-label {
  margin: -6px 0 14px;
  color: #64748b;
  font-size: 12px;
}

.history-message {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 14px;
}

.history-message.ai {
  grid-template-columns: 32px minmax(0, 0.72fr);
}

.history-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #0b5ed7;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.history-avatar.ai {
  background: #eef2ff;
  color: #1d4ed8;
}

.history-bubble {
  border-radius: 24px;
  padding: 18px 20px;
  font-size: 13px;
  line-height: 1.55;
}

.history-bubble.question {
  background: #075bd8;
  color: #fff;
  justify-self: end;
  width: min(720px, 82%);
  font-weight: 700;
}

.history-bubble.answer {
  background: #e9edf2;
  color: #3f4652;
  min-height: 86px;
}

.token-topbar {
  background: #f8fafc;
}

.token-view {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 28px 42px;
}

.token-filter-bar {
  display: grid;
  grid-template-columns: auto 1fr minmax(220px, 280px);
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.token-filter-bar > span,
.token-search span {
  color: #9ca3af;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.token-period-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(120px, auto));
  gap: 2px;
  width: fit-content;
  padding: 3px;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  background: #fff;
}

.token-period-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: transparent;
  color: #64748b;
  font-weight: 800;
  cursor: pointer;
}

.token-period-tabs button.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.token-period-tabs button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.token-search {
  display: grid;
  gap: 5px;
}

.token-search input {
  border-radius: 999px;
  background: #fff;
  padding: 10px 14px;
}

.token-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 26px;
  margin-bottom: 28px;
}

.token-stat-card,
.token-table-card {
  background: #fff;
  border: 1px solid #edf0f4;
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(148, 163, 184, 0.12);
}

.token-stat-card {
  min-height: 132px;
  padding: 26px 28px;
}

.token-stat-card.primary {
  position: relative;
  overflow: hidden;
  background: #2f6eea;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 20px 42px rgba(37, 99, 235, 0.28);
}

.token-stat-card.primary::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 18px;
  width: 74px;
  height: 74px;
  background:
    linear-gradient(30deg, transparent 47%, rgba(255, 255, 255, 0.14) 48% 52%, transparent 53%),
    linear-gradient(150deg, transparent 47%, rgba(255, 255, 255, 0.12) 48% 52%, transparent 53%),
    rgba(255, 255, 255, 0.08);
  clip-path: polygon(50% 0, 92% 25%, 92% 75%, 50% 100%, 8% 75%, 8% 25%);
}

.token-stat-card span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.token-stat-card.primary span {
  color: rgba(255, 255, 255, 0.78);
}

.token-stat-card strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.token-stat-card small {
  display: block;
  margin-top: 16px;
  color: #8a94a6;
  font-size: 12px;
  font-weight: 700;
}

.token-stat-card.primary small {
  color: rgba(255, 255, 255, 0.82);
}

.token-table-card {
  padding: 28px;
}

.token-table-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.token-table-head h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.token-table-head p {
  margin: 0;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 700;
}

.token-table {
  min-width: 850px;
}

.token-table th {
  border-bottom: 0;
  color: #a3acbd;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.token-table th.numeric,
.token-table td.token-number,
.token-table td.token-usage {
  text-align: right;
}

.token-table td {
  padding: 16px 8px;
  color: #475569;
  font-weight: 700;
}

.rank-pill {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eaf2ff;
  color: #2f6eea;
  font-size: 12px;
  font-weight: 900;
}

.token-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: center;
}

.token-user span {
  min-width: 0;
  color: #1f2937;
}

.token-user small {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.token-usage {
  color: #2563eb !important;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .content {
    min-height: 100vh;
    grid-template-rows: auto 1fr;
    padding-top: 58px;
  }

  .topbar {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    display: block;
    padding: 0;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid rgba(229, 231, 235, 0.68);
    box-shadow: 0 10px 28px rgba(148, 163, 184, 0.12);
    backdrop-filter: blur(12px);
  }

  .mobile-nav.open {
    background: rgba(255, 255, 255, 0.96);
    border-bottom-color: rgba(229, 231, 235, 0.68);
    box-shadow: 0 10px 28px rgba(148, 163, 184, 0.12);
  }

  .mobile-menu-bar {
    position: relative;
    z-index: 120;
    min-height: 58px;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    padding: 0 16px;
  }

  .mobile-menu-brand {
    justify-self: start;
    color: #2f6eea;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0;
  }

  .mobile-nav.open .mobile-menu-brand {
    color: #2f6eea;
  }

  .mobile-menu-toggle,
  .mobile-menu-more {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
  }

  .mobile-nav.open .mobile-menu-toggle,
  .mobile-nav.open .mobile-menu-more {
    color: #64748b;
  }

  .mobile-nav.open .mobile-menu-toggle {
    border-radius: 999px;
    background: #eef2ff;
  }

  .mobile-menu-toggle {
    gap: 4px;
  }

  .mobile-menu-toggle span {
    width: 17px;
    height: 2px;
    display: block;
    border-radius: 999px;
    background: #64748b;
  }

  .mobile-nav.open .mobile-menu-toggle span {
    background: #2f6eea;
  }

  .mobile-menu-more {
    justify-self: end;
    padding-bottom: 8px;
    font-size: 24px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0;
  }

  .mobile-menu-links {
    position: fixed;
    top: 66px;
    left: 8px;
    z-index: 110;
    width: min(88vw, 340px);
    height: calc(100vh - 78px);
    display: grid;
    grid-auto-rows: max-content;
    gap: 10px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    background:
      radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.11), transparent 34%),
      rgba(20, 25, 30, 0.88);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(16px);
    transform: translateX(calc(-100% - 16px));
    opacity: 0;
    pointer-events: none;
    transition:
      transform 240ms ease,
      opacity 220ms ease;
  }

  .mobile-nav.open .mobile-menu-links {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }

  .mobile-nav.open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-panel-head {
    display: grid;
    gap: 4px;
    padding: 4px 4px 12px;
  }

  .mobile-menu-panel-head span {
    color: #f8fafc;
    font-size: 20px;
    font-weight: 900;
  }

  .mobile-menu-panel-head small {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-menu-links .mobile-link {
    min-height: 48px;
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #e5e7eb;
    text-align: left;
    font-size: 16px;
    font-weight: 800;
    transition:
      background 180ms ease,
      color 180ms ease;
  }

  .mobile-menu-links .mobile-link::before {
    width: 24px;
    color: #d1d5db;
    font-size: 19px;
    font-weight: 500;
    text-align: center;
  }

  .mobile-menu-links .mobile-link[data-nav="chat"]::before {
    content: "<";
  }

  .mobile-menu-links .mobile-link[data-nav="history"]::before {
    content: "o";
  }

  .mobile-menu-links .mobile-link[data-nav="documents"]::before {
    content: "[]";
  }

  .mobile-menu-links .mobile-link[data-nav="training"]::before {
    content: "+";
  }

  .mobile-menu-links .mobile-link[data-nav="tokens"]::before {
    content: "#";
  }

  .mobile-menu-links .mobile-link[data-nav="users"]::before {
    content: "*";
  }

  .mobile-menu-links .mobile-link + .mobile-link {
    border-top: 0;
  }

  .mobile-menu-links .mobile-link:hover,
  .mobile-menu-links .mobile-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .login-brandmark {
    padding: 16px 18px 0;
  }

  .login-box {
    padding: 28px 22px 22px;
    border-radius: 24px;
  }

  .login-footer {
    gap: 14px;
    flex-wrap: wrap;
  }

  .history-view {
    padding: 22px 14px;
  }

  .history-dashboard,
  .history-filter-bar,
  .history-filters {
    grid-template-columns: 1fr;
  }

  .history-list {
    padding-left: 28px;
  }

  .history-dot {
    left: -30px;
  }

  .history-thread-meta {
    gap: 8px;
    flex-wrap: wrap;
  }

  .history-thread-meta strong {
    margin-left: 0;
  }

  .history-message.ai {
    grid-template-columns: 30px 1fr;
  }

  .history-bubble.question {
    width: 100%;
  }

  .history-search {
    display: none;
  }

  .token-view {
    padding: 22px 14px;
  }

  .token-filter-bar,
  .token-stats {
    grid-template-columns: 1fr;
  }

  .token-period-tabs {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .token-table-head {
    display: grid;
  }
}

@media (max-width: 520px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    background: #f7f9fc;
  }

  .app,
  .content,
  .view,
  .card,
  .token-table-card,
  .history-view,
  .token-view {
    max-width: 100%;
    overflow-x: hidden;
  }

  .view {
    padding: 16px 14px 24px;
  }

  .hero {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 16px;
  }

  .hero h3 {
    font-size: 18px;
    line-height: 1.25;
  }

  .hero p {
    font-size: 13px;
    line-height: 1.5;
  }

  .stats-grid,
  .document-layout,
  .history-dashboard,
  .token-stats,
  .split-layout,
  .history-filter-bar,
  .history-filters,
  .token-filter-bar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card,
  .stat-card,
  .history-stat,
  .history-period-card,
  .token-stat-card,
  .token-table-card {
    width: 100%;
    border-radius: 8px;
    padding: 16px;
  }

  .stat-value,
  .history-stat .stat-value,
  .token-stat-card strong {
    font-size: 26px;
    line-height: 1.1;
  }

  .token-period-tabs {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .token-period-tabs button,
  .btn,
  input,
  textarea,
  select {
    min-height: 44px;
  }

  .field {
    margin-top: 12px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  .token-table {
    min-width: 0;
    width: 100%;
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    display: grid;
    width: 100%;
    border: 1px solid #e8edf5;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(148, 163, 184, 0.1);
    overflow: hidden;
  }

  td {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid #edf0f4;
    padding: 11px 12px;
    font-size: 13px;
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: #94a3b8;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  td[colspan] {
    display: block;
    padding: 18px 12px;
    text-align: center;
  }

  td[colspan]::before {
    content: "";
    display: none;
  }

  .action-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .action-group .btn {
    width: 100%;
  }

  .role-select {
    width: 100%;
    min-width: 0;
  }

  .document-toolbar {
    grid-template-columns: 1fr;
  }

  .batch-action-bar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
  }

  .batch-action-bar strong {
    margin-right: 0;
  }

  .doc-process {
    min-width: 0;
  }

  .token-table-head {
    gap: 8px;
    margin-bottom: 14px;
  }

  .history-view,
  .token-view {
    padding: 18px 14px 28px;
  }

  .history-list {
    padding-left: 0;
  }

  .history-list::before,
  .history-dot {
    display: none;
  }

  .history-thread {
    padding-bottom: 26px;
  }

  .history-thread-meta {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
  }

  .history-thread-meta strong,
  .history-full-chat {
    margin-left: 0;
    justify-self: start;
  }

  .history-message.ai {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .history-bubble {
    border-radius: 18px;
    padding: 14px 15px;
  }

  .history-bubble.question {
    width: 100%;
  }

  .login-shell {
    min-height: calc(100vh - 46px);
    padding: 18px 14px 26px;
  }

  .login-box {
    width: 100%;
    max-width: 360px;
    padding: 26px 18px 20px;
    border-radius: 8px;
  }
}

/* KEVIN AI dark tech theme overrides */
body {
  background:
    linear-gradient(180deg, #0b1117 0%, #080c10 42%, #05080b 100%);
  color: var(--text);
}

.sidebar,
.topbar,
.mobile-nav {
  background: rgba(15, 23, 32, 0.96);
  border-color: var(--line);
}

.sidebar {
  box-shadow: inset -1px 0 0 rgba(0, 212, 255, 0.05);
}

.logo {
  border-radius: 8px;
  background:
    linear-gradient(135deg, #00b386, #00d4ff);
  box-shadow: 0 0 24px rgba(0, 179, 134, 0.24);
}

.brand h1,
.topbar-left h2,
.hero h3,
.modal-head h3,
.token-table-head h3 {
  color: #f0f6fc;
}

.brand small,
.topbar-left small,
.hero p,
.modal-head p,
.status-note,
.muted-text,
.training-example {
  color: var(--muted);
}

.nav-link,
.mobile-link {
  border-radius: 8px;
  color: #b8c7d3;
}

.nav-link:hover,
.nav-link.active,
.mobile-link.active {
  background: #112820;
  color: #7ee787;
}

.chip,
.badge,
.rank-pill,
.tag-list span {
  border-color: #1f6f5b;
  background: #0c1a17;
  color: #7ee787;
}

.badge.success {
  background: #0d2419;
  color: #7ee787;
}

.badge.danger {
  background: #2a1114;
  color: #ff7b72;
}

.btn {
  border-radius: 8px;
  background: #00b386;
  color: #03110d;
  box-shadow: 0 0 0 1px rgba(0, 179, 134, 0.12);
}

.btn:hover {
  background: #00d4ff;
  color: #021014;
}

.btn.soft {
  border: 1px solid #27313c;
  background: #111b25;
  color: #7ee787;
}

.btn.soft:hover {
  background: #13251f;
}

.btn.danger {
  background: #ff5f57;
  color: #230708;
}

.card,
.stat-card,
.history-stat,
.history-period-card,
.token-stat-card,
.token-table-card,
.upload-modal,
.login-box {
  border-color: var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 32, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.26);
}

.stat-card {
  background: linear-gradient(180deg, #101a23, #0c131a);
}

.history-period-card,
.token-stat-card.primary {
  background: linear-gradient(135deg, #063c35, #0b5365);
  color: #f0f6fc;
  box-shadow: 0 20px 42px rgba(0, 179, 134, 0.16);
}

.history-period-card span,
.history-period-card small,
.token-stat-card.primary span,
.token-stat-card.primary small {
  color: rgba(230, 237, 243, 0.78);
}

.stat-label,
th,
.history-stat span,
.token-stat-card span,
.token-filter-bar > span,
.token-search span,
.filter-label {
  color: #8b949e;
}

.stat-value,
.token-stat-card strong,
.history-stat .stat-value {
  color: #f0f6fc;
}

input,
textarea,
select,
.history-search {
  border-color: #27313c;
  background: #0a1118;
  color: #e6edf3;
}

input::placeholder,
textarea::placeholder {
  color: #6e7681;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(0, 212, 255, 0.24);
  border-color: #00d4ff;
  background: #0c141c;
}

table,
td,
th {
  border-color: #27313c;
}

td,
.token-table td,
.token-user span {
  color: #c9d1d9;
}

.empty-state,
.upload-drop-zone {
  border-color: #1f6f5b;
  background: #0c1a17;
  color: #8b949e;
}

.upload-drop-zone.dragover {
  border-color: #00d4ff;
  background: #0b1f27;
}

.upload-drop-zone strong,
.batch-action-bar strong {
  color: #e6edf3;
}

.selected-files span,
.batch-action-bar {
  border-color: #27313c;
  background: rgba(15, 23, 32, 0.96);
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.modal-close {
  border-radius: 8px;
  background: #111b25;
  color: #8b949e;
}

.modal-close:hover {
  background: #182635;
}

.login-overlay {
  background:
    radial-gradient(circle at 18% 20%, rgba(0, 179, 134, 0.14), transparent 28%),
    radial-gradient(circle at 82% 16%, rgba(0, 212, 255, 0.12), transparent 30%),
    linear-gradient(180deg, rgba(8, 12, 16, 0.98), rgba(5, 8, 11, 0.96));
}

.login-brandmark {
  color: #7ee787;
}

.login-submit {
  border-radius: 8px;
  background: linear-gradient(90deg, #00b386, #00d4ff);
  color: #03110d;
  box-shadow: 0 8px 24px rgba(0, 179, 134, 0.18);
}

.login-submit:hover {
  background: linear-gradient(90deg, #7ee787, #00d4ff);
}

.login-footer {
  color: #6e7681;
}

.history-topbar,
.token-topbar {
  background: rgba(15, 23, 32, 0.96);
}

.history-list::before {
  background: #27313c;
}

.history-dot {
  background: #00b386;
  box-shadow: 0 0 0 5px rgba(0, 179, 134, 0.12);
}

.history-avatar {
  background: #00b386;
  color: #03110d;
}

.history-avatar.ai {
  background: #0c1a17;
  color: #7ee787;
}

.history-bubble.question {
  background: #00b386;
  color: #03110d;
}

.history-bubble.answer {
  background: #111b25;
  color: #c9d1d9;
}

.history-bubble.answer .code-block {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 10px 0;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 38px 14px 14px;
  background: #05080b;
  color: #d7fbe8;
  white-space: pre-wrap;
  overflow-x: auto;
  overflow-wrap: anywhere;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.history-bubble.answer .code-block-head {
  position: absolute;
  inset: 8px 8px auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-bubble.answer .code-block span {
  color: #00d4ff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-bubble.answer .code-block code {
  font-family: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-bubble.answer .code-copy {
  width: 32px;
  height: 32px;
  min-height: 0;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #111b25;
  color: #e6edf3;
  cursor: pointer;
}

.history-bubble.answer .code-copy:hover,
.history-bubble.answer .code-copy.copied {
  border-color: #8b949e;
  background: #1a242f;
}

.history-bubble.answer .code-copy[data-state="copied"]::after {
  content: "Copied";
  position: absolute;
  right: 0;
  top: 36px;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 4px 8px;
  background: #111b25;
  color: #7ee787;
  font-size: 11px;
}

.history-bubble.answer .copy-icon {
  position: relative;
  width: 15px;
  height: 15px;
  display: block;
}

.history-bubble.answer .copy-icon::before,
.history-bubble.answer .copy-icon::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 11px;
  border: 1.7px solid currentColor;
  border-radius: 3px;
}

.history-bubble.answer .copy-icon::before {
  left: 1px;
  top: 3px;
  opacity: 0.7;
}

.history-bubble.answer .copy-icon::after {
  left: 5px;
  top: 0;
}

.history-full-chat,
.token-usage {
  color: #00d4ff !important;
}

@media (min-width: 901px) {
  .history-message.ai {
    grid-template-columns: 1fr;
  }

  .history-avatar.ai {
    display: none;
  }

  .history-bubble.answer {
    width: min(100%, 920px);
    max-width: min(100%, 920px);
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 8px 4px;
    background: transparent;
    color: #d9e2ec;
  }

  .history-bubble.question {
    width: fit-content;
    max-width: min(680px, 64%);
    border-radius: 18px;
    padding: 14px 18px;
    background: #2a2d31;
    color: #f0f6fc;
  }
}

.token-period-tabs {
  border-color: #27313c;
  background: #0a1118;
}

.token-period-tabs button {
  color: #8b949e;
}

.token-period-tabs button.active {
  background: #00b386;
  color: #03110d;
  box-shadow: 0 8px 18px rgba(0, 179, 134, 0.18);
}

.token-user small {
  background: #111b25;
  color: #8b949e;
}

@media (max-width: 900px) {
  body {
    background: #080c10;
  }

  .mobile-nav,
  .mobile-nav.open {
    background: rgba(15, 23, 32, 0.96);
    border-bottom-color: #27313c;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  }

  .mobile-menu-brand,
  .mobile-nav.open .mobile-menu-brand {
    color: #7ee787;
  }

  .mobile-menu-toggle,
  .mobile-menu-more,
  .mobile-nav.open .mobile-menu-toggle,
  .mobile-nav.open .mobile-menu-more {
    color: #8b949e;
  }

  .mobile-nav.open .mobile-menu-toggle {
    background: #112820;
  }

  .mobile-menu-toggle span,
  .mobile-nav.open .mobile-menu-toggle span {
    background: #7ee787;
  }

  .mobile-menu-links {
    border-color: #27313c;
    background:
      radial-gradient(circle at 18% 8%, rgba(0, 179, 134, 0.12), transparent 34%),
      rgba(12, 18, 24, 0.96);
  }

  .mobile-menu-links .mobile-link:hover,
  .mobile-menu-links .mobile-link.active {
    background: #112820;
    color: #7ee787;
  }
}

@media (max-width: 520px) {
  body {
    background: #080c10;
  }

  tr {
    border-color: #27313c;
    background: #0f1720;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  }

  td {
    border-bottom-color: #27313c;
  }
}

/* KEVIN AI full terminal shell */
:root {
  --terminal-bg: #05080b;
  --terminal-panel: #0b1117;
  --terminal-panel-2: #0f1720;
  --terminal-line: #27313c;
  --terminal-line-hot: rgba(0, 179, 134, 0.55);
  --terminal-green: #7ee787;
  --terminal-cyan: #00d4ff;
  --terminal-amber: #f0b86a;
  --terminal-text: #e6edf3;
  --terminal-muted: #8b949e;
  --terminal-width: min(1536px, calc(100vw - 48px));
}

html,
body {
  min-height: 100%;
  background: var(--terminal-bg);
}

body {
  font-family: Consolas, Monaco, "Courier New", monospace;
  background:
    radial-gradient(circle at 16% 0%, rgba(0, 179, 134, 0.1), transparent 30%),
    radial-gradient(circle at 88% -8%, rgba(0, 212, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #080c10 0%, #05080b 100%);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: transparent;
}

.sidebar,
.mobile-nav {
  display: none !important;
}

.content {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  border: 0;
  border-bottom: 1px solid var(--terminal-line);
  padding: 10px max(18px, calc((100vw - var(--terminal-width)) / 2));
  background: rgba(5, 8, 11, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.topbar::before {
  content: "KEVIN AI";
  justify-self: start;
  align-self: start;
  color: var(--terminal-green);
  font-weight: 900;
  letter-spacing: 0.08em;
  font-size: 11px;
  text-transform: uppercase;
}

.topbar-left {
  display: grid;
  gap: 3px;
}

.topbar-left h2 {
  margin: 0;
  color: var(--terminal-text);
  font-size: 18px;
  letter-spacing: 0;
}

.topbar-left h2::before {
  content: "[";
  color: var(--terminal-cyan);
}

.topbar-left h2::after {
  content: "]";
  color: var(--terminal-cyan);
}

.topbar-left small {
  color: var(--terminal-muted);
}

.topbar-right {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chip {
  border: 1px solid var(--terminal-line-hot);
  border-radius: 8px;
  background: rgba(0, 179, 134, 0.08);
  color: var(--terminal-green);
  font-size: 12px;
}

.terminal-command-bar {
  position: sticky;
  top: 58px;
  z-index: 45;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr);
  gap: 10px;
  align-items: start;
  border-bottom: 1px solid var(--terminal-line);
  padding: 10px max(18px, calc((100vw - var(--terminal-width)) / 2));
  background: rgba(8, 12, 16, 0.94);
  backdrop-filter: blur(12px);
}

.terminal-command-prompt {
  padding: 10px 0;
  color: var(--terminal-green);
  white-space: nowrap;
}

.terminal-command-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  padding: 7px 8px 7px 12px;
  background: #05080b;
}

.terminal-command-form > span {
  color: var(--terminal-green);
  font-weight: 900;
}

.terminal-command-form input {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 6px 4px;
  background: transparent;
  color: var(--terminal-text);
  font-family: inherit;
}

.terminal-command-form input:focus {
  outline: 0;
  border: 0;
  background: transparent;
}

.terminal-command-form button {
  min-height: 32px;
  border: 1px solid var(--terminal-line-hot);
  border-radius: 7px;
  padding: 0 12px;
  background: #0c1a17;
  color: var(--terminal-green);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.terminal-command-output {
  grid-column: 1 / -1;
  display: none;
  margin: 0;
  border: 1px dashed var(--terminal-line-hot);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 179, 134, 0.05);
  color: var(--terminal-muted);
  white-space: pre-wrap;
}

.terminal-command-output.show {
  display: block;
}

.terminal-command-output.error {
  border-color: rgba(255, 95, 87, 0.65);
  background: rgba(255, 95, 87, 0.08);
  color: #ff9a94;
}

body.pre-login .topbar,
body.pre-login .terminal-command-bar,
body.pre-login .global-terminal-composer {
  display: none !important;
}

/* Minimal header + one global terminal composer */
.content {
  padding-bottom: 112px;
}

.topbar {
  min-height: 76px;
  grid-template-columns: auto 1fr;
  padding-top: 14px;
  padding-bottom: 14px;
}

.topbar::before {
  content: "KEVIN AI";
  align-self: center;
  color: var(--terminal-green);
  font-size: clamp(28px, 3.4vw, 54px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.topbar-left {
  justify-self: end;
  text-align: right;
}

.topbar-left h2 {
  font-size: 18px;
  color: var(--terminal-cyan);
}

.topbar-left small {
  font-size: 12px;
}

.topbar-right {
  display: none !important;
}

.terminal-command-bar {
  display: none !important;
}

.global-terminal-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: grid;
  gap: 8px;
  padding: 10px max(14px, calc((100vw - var(--terminal-width)) / 2)) 12px;
  border-top: 1px solid var(--terminal-line);
  background: rgba(5, 8, 11, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 -18px 46px rgba(0, 0, 0, 0.36);
}

.global-terminal-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #05080b;
}

.global-terminal-form span {
  color: var(--terminal-green);
  white-space: nowrap;
}

.global-terminal-form textarea {
  min-height: 34px;
  max-height: 180px;
  border: 0;
  border-radius: 0;
  padding: 6px 4px;
  background: transparent;
  color: var(--terminal-text);
  caret-color: var(--terminal-green);
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  white-space: pre-wrap;
}

.global-terminal-form textarea:focus {
  outline: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: #f0f6fc;
  text-shadow: 0 0 10px rgba(126, 231, 135, 0.18);
}

.global-terminal-form button {
  min-height: 34px;
  border: 1px solid var(--terminal-line-hot);
  border-radius: 7px;
  padding: 0 14px;
  background: #00b386;
  color: #03110d;
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
}

.global-terminal-form button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.global-terminal-output {
  display: none;
  max-height: 190px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  padding: 12px;
  background: #0b1117;
  color: #c9d1d9;
  white-space: pre-wrap;
}

.global-terminal-output.show {
  display: block;
}

.global-terminal-output.error {
  border-color: rgba(255, 95, 87, 0.65);
  background: rgba(255, 95, 87, 0.08);
  color: #ff9a94;
}

.global-terminal-entry span {
  color: var(--terminal-green);
  font-weight: 900;
}

.kevin-library-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.kevin-library-item {
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.78);
  padding: 12px;
}

.kevin-library-item strong {
  display: block;
  color: var(--terminal-green);
  font-size: 13px;
  margin-bottom: 4px;
}

.kevin-library-item small {
  color: var(--terminal-cyan);
  font-size: 11px;
}

.kevin-library-item p {
  margin: 8px 0 10px;
  color: var(--terminal-muted);
  font-size: 12px;
  line-height: 1.5;
}

.kevin-library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kevin-library-actions button {
  border: 1px solid var(--terminal-line-hot);
  border-radius: 7px;
  background: rgba(0, 255, 136, 0.08);
  color: var(--terminal-green);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  cursor: pointer;
}

.kevin-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  white-space: normal;
}

.kevin-option {
  width: 100%;
  display: grid;
  gap: 4px;
  min-height: 0;
  border: 1px solid rgba(0, 179, 134, 0.28);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 179, 134, 0.05);
  color: #c9d1d9;
  font-family: Consolas, Monaco, "Courier New", monospace;
  text-align: left;
  cursor: pointer;
}

.kevin-option:hover,
.kevin-option:focus {
  border-color: var(--terminal-cyan);
  outline: 0;
  background: rgba(0, 212, 255, 0.08);
}

.kevin-option strong {
  color: var(--terminal-green);
  font-size: 12px;
}

.kevin-option span {
  color: var(--terminal-muted);
  font-size: 11px;
  line-height: 1.35;
}

.global-terminal-palette {
  display: none;
  overflow: hidden;
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: #0b1117;
  box-shadow: 0 -18px 56px rgba(0, 0, 0, 0.36);
}

.global-terminal-palette.show {
  display: block;
}

.global-terminal-palette-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--terminal-line);
  padding: 9px 12px;
  color: var(--terminal-muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.global-terminal-palette-head kbd {
  border: 1px solid var(--terminal-line);
  border-radius: 5px;
  padding: 1px 5px;
  background: #05080b;
  color: var(--terminal-green);
  font: inherit;
  font-size: 10px;
}

.global-terminal-palette-list {
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}

.global-command-item {
  width: 100%;
  display: grid;
  grid-template-columns: 150px 1fr 80px;
  gap: 12px;
  align-items: center;
  border: 0;
  border-radius: 7px;
  padding: 9px 10px;
  background: transparent;
  color: #c9d1d9;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.global-command-item:hover,
.global-command-item.active {
  background: rgba(0, 179, 134, 0.1);
}

.global-command-item.locked {
  opacity: 0.48;
}

.global-command-item strong {
  color: var(--terminal-green);
}

.global-command-item small {
  display: block;
  margin-top: 2px;
  color: var(--terminal-muted);
  font-size: 10px;
}

.global-command-item span {
  overflow: hidden;
  color: #c9d1d9;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-command-item em {
  justify-self: end;
  color: var(--terminal-cyan);
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.global-command-empty {
  padding: 18px;
  color: var(--terminal-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .content {
    padding-bottom: 118px;
  }

  .topbar {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .topbar::before {
    font-size: 34px;
  }

  .topbar-left {
    justify-self: start;
    text-align: left;
  }

  .global-terminal-composer {
    padding: 10px 14px 12px;
  }

  .global-terminal-form {
    grid-template-columns: 1fr auto;
  }

  .global-terminal-form span {
    grid-column: 1 / -1;
    font-size: 12px;
  }

  .global-command-item {
    grid-template-columns: 108px 1fr;
  }

  .global-command-item em {
    display: none;
  }
}

.view,
.history-view,
.token-view {
  width: var(--terminal-width);
  max-width: var(--terminal-width);
  margin: 0 auto;
  padding: 18px 0 28px;
  overflow: auto;
}

.hero,
.card,
.stat-card,
.history-stat,
.history-period-card,
.history-filter-bar,
.history-thread,
.token-filter-bar,
.token-stat-card,
.token-table-card,
.upload-modal,
.empty-state,
.batch-action-bar {
  position: relative;
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: rgba(11, 17, 23, 0.96);
  color: var(--terminal-text);
  box-shadow: none;
}

.hero::before,
.card::before,
.document-list-card::before,
.history-filter-bar::before,
.token-filter-bar::before,
.token-table-card::before {
  position: absolute;
  top: -10px;
  left: 14px;
  padding: 0 8px;
  background: var(--terminal-bg);
  color: var(--terminal-green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero::before {
  content: "[page.context]";
}

.document-list-card::before {
  content: "[documents.index]";
}

.card::before {
  content: "[terminal.panel]";
}

.history-filter-bar::before {
  content: "[history.filter]";
}

.token-filter-bar::before {
  content: "[tokens.filter]";
}

.token-table-card::before {
  content: "[tokens.usage]";
}

.hero {
  margin: 0 0 16px;
  padding: 18px;
}

.hero h3,
.card h3,
.modal-head h3,
.token-table-head h3 {
  color: var(--terminal-text);
}

.hero p,
.card p,
.modal-head p,
.status-note,
.muted-text {
  color: var(--terminal-muted) !important;
}

.stats-grid,
.history-dashboard,
.token-stats {
  gap: 12px;
}

.stat-card,
.history-stat,
.history-period-card,
.token-stat-card {
  padding: 16px;
  background: linear-gradient(180deg, #0d151d, #091017);
}

.history-period-card,
.token-stat-card.primary {
  background:
    linear-gradient(135deg, rgba(0, 179, 134, 0.18), rgba(0, 212, 255, 0.12)),
    #091017;
}

.stat-label,
.history-stat span,
.history-period-card span,
.token-stat-card span,
.filter-label,
label > span {
  color: var(--terminal-green);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value,
.history-stat .stat-value,
.history-period-card strong,
.token-stat-card strong {
  color: var(--terminal-text);
  font-family: inherit;
}

input,
textarea,
select,
.history-search {
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: #05080b;
  color: var(--terminal-text);
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--terminal-cyan);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
  background: #070d12;
}

.btn {
  border: 1px solid var(--terminal-line-hot);
  border-radius: 8px;
  background: #00b386;
  color: #03110d;
  font-family: inherit;
  box-shadow: none;
}

.btn.soft {
  border-color: var(--terminal-line);
  background: #0c1a17;
  color: var(--terminal-green);
}

.btn.danger {
  border-color: rgba(255, 95, 87, 0.65);
  background: #2a1114;
  color: #ff9a94;
}

.table-wrap {
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: #05080b;
}

table {
  min-width: 760px;
  background: transparent;
}

th {
  background: #0b1117;
  color: var(--terminal-green);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: #c9d1d9;
}

tr:hover td {
  background: rgba(0, 179, 134, 0.04);
}

.badge,
.tag-list span,
.rank-pill {
  border: 1px solid var(--terminal-line-hot);
  border-radius: 7px;
  background: #0c1a17;
  color: var(--terminal-green);
}

.document-toolbar,
.history-filters,
.token-filter-bar,
.token-period-tabs,
.token-search {
  font-family: inherit;
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.upload-modal {
  background: #0b1117;
}

.upload-drop-zone {
  border-color: var(--terminal-line-hot);
  background: #05080b;
}

.selected-files span,
.batch-action-bar {
  background: #0b1117;
}

.history-list::before {
  background: var(--terminal-line);
}

.history-thread {
  background: transparent;
}

.history-bubble.question {
  border: 1px solid rgba(0, 179, 134, 0.42);
  border-radius: 8px;
  background: #2a2d31;
  color: var(--terminal-text);
}

.history-bubble.answer {
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: #0b1117;
  color: #c9d1d9;
}

.token-period-tabs {
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
}

.token-period-tabs button {
  font-family: inherit;
}

.login-overlay {
  background:
    radial-gradient(circle at 16% 0%, rgba(0, 179, 134, 0.16), transparent 28%),
    linear-gradient(180deg, rgba(5, 8, 11, 0.98), rgba(5, 8, 11, 0.96));
}

.login-box {
  border: 1px solid var(--terminal-line);
  border-radius: 8px;
  background: #0b1117;
}

.login-brandmark,
.login-header h3 {
  color: var(--terminal-green);
}

.login-submit {
  border-radius: 8px;
}

@media (max-width: 900px) {
  :root {
    --terminal-width: calc(100vw - 28px);
  }

  .content {
    grid-template-rows: auto auto 1fr;
  }

  .topbar {
    position: sticky;
    grid-template-columns: 1fr;
    padding: 10px 14px;
  }

  .topbar-right {
    justify-content: flex-start;
  }

  .terminal-command-bar {
    top: auto;
    grid-template-columns: 1fr;
    padding: 10px 14px;
  }

  .terminal-command-prompt {
    padding: 0;
    white-space: normal;
  }

  .view,
  .history-view,
  .token-view {
    padding: 14px 0 24px;
  }

  .history-dashboard,
  .history-filter-bar,
  .history-filters,
  .token-filter-bar,
  .token-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  table {
    min-width: 0;
  }

  tr {
    border: 1px solid var(--terminal-line);
    border-radius: 8px;
    background: #0b1117;
  }

  td::before {
    color: var(--terminal-green);
  }
}

/* Unified dark terminal form controls */
input,
textarea,
select,
.history-filters input,
.history-filters select,
.token-search input,
.document-toolbar input,
.document-toolbar select,
.role-select,
.history-search,
.global-terminal-form textarea,
.terminal-command-form input {
  border: 1px solid var(--terminal-line) !important;
  border-radius: 8px !important;
  background: #05080b !important;
  color: var(--terminal-text) !important;
  caret-color: var(--terminal-green);
  caret-shape: block;
  font-family: Consolas, Monaco, "Courier New", monospace !important;
  box-shadow: inset 0 0 0 1px rgba(0, 179, 134, 0.02);
}

input::placeholder,
textarea::placeholder,
.global-terminal-form textarea::placeholder,
.terminal-command-form input::placeholder {
  color: #6e7681 !important;
  opacity: 1;
}

input:focus,
textarea:focus,
select:focus,
.history-filters input:focus,
.history-filters select:focus,
.token-search input:focus,
.document-toolbar input:focus,
.role-select:focus,
.global-terminal-form textarea:focus,
.terminal-command-form input:focus {
  border-color: var(--terminal-cyan) !important;
  outline: 0 !important;
  background: #05080b !important;
  color: #f0f6fc !important;
  caret-color: var(--terminal-green) !important;
  caret-shape: block;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.12), inset 0 0 0 1px rgba(0, 212, 255, 0.18) !important;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--terminal-text) !important;
  caret-color: var(--terminal-green);
  caret-shape: block;
  box-shadow: 0 0 0 1000px #05080b inset, 0 0 0 3px rgba(0, 212, 255, 0.12) !important;
  border-color: var(--terminal-cyan) !important;
  transition: background-color 9999s ease-out;
}

select {
  color-scheme: dark;
}

.field label,
.document-toolbar span,
.history-filters label > span,
.token-search span {
  color: var(--terminal-green) !important;
}
