:root {
  --bg: #111827;
  --card: #1F2937;
  --border: #374151;
  --text: #E5E7EB;
  --muted: #9CA3AF;
  --accent: #F59E0B;
  --accent-dark: #D97706;
  --danger: #EF4444;
  --success: #10B981;
  --radius: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* NAV */
nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  position: sticky; top: 0; z-index: 100;
}
.logo { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: 1px; }
nav .links { display: flex; gap: 4px; flex: 1; }
nav .links a {
  padding: 6px 12px; border-radius: var(--radius);
  color: var(--muted); font-weight: 500; transition: all .15s;
}
nav .links a:hover, nav .links a.active { color: var(--text); background: var(--border); text-decoration: none; }
.user-info { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 4px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* MAIN LAYOUT */
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }

/* CARDS */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #4B5563; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* INPUTS */
input, textarea, select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 8px 12px; font-size: 14px; width: 100%;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }

/* TICKET INPUT */
.ticket-input-area { display: flex; gap: 8px; margin-bottom: 20px; }
.ticket-input-area textarea {
  flex: 1; min-height: 48px; max-height: 120px;
  font-size: 15px; padding: 12px;
}
.ticket-input-area .btn { align-self: flex-end; min-width: 80px; }

/* FILTERS */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 120px; }

/* TICKET CARDS */
.ticket-list { display: flex; flex-direction: column; gap: 8px; }
.ticket-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; cursor: pointer; transition: border-color .15s;
  animation: fadeIn .2s ease;
}
.ticket-card:hover { border-color: var(--accent); }
.ticket-card .header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ticket-card .client { font-weight: 600; color: var(--accent); }
.ticket-card .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* BADGES */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 500;
}
.badge-gray { background: var(--border); color: var(--muted); }
.badge-blue { background: #1E40AF; color: #93C5FD; }
.badge-green { background: #065F46; color: #6EE7B7; }
.badge-yellow { background: #78350F; color: #FCD34D; }
.badge-red { background: #7F1D1D; color: #FCA5A5; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 16px; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

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

/* PARSE RESULT */
.parse-result {
  background: #0F2027; border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; animation: fadeIn .3s;
}
.parse-result .row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.parse-result .field { }
.parse-result .field span { color: var(--muted); font-size: 11px; }
.parse-result .field strong { display: block; }
.billable-btns { display: flex; gap: 8px; margin-top: 8px; }

/* TABLE */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tbl tr:hover td { background: rgba(255,255,255,.02); }
.tbl tr:last-child td { border-bottom: none; }

/* ANALYTICS */
.qa-history { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.qa-item {}
.qa-question { color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.qa-answer { color: var(--text); white-space: pre-wrap; }

/* STATS */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 20px; min-width: 120px;
}
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 12px; color: var(--muted); }

/* LOGIN */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 40px; width: 100%; max-width: 380px;
}
.login-logo { font-size: 32px; font-weight: 700; color: var(--accent); text-align: center; margin-bottom: 8px; letter-spacing: 2px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.error-msg { background: #7F1D1D; color: #FCA5A5; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }

/* ANIMATIONS */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* RESPONSIVE */
@media (max-width: 600px) {
  nav .links a { padding: 6px 8px; font-size: 13px; }
  .ticket-input-area { flex-direction: column; }
  .filters { gap: 6px; }
  .filters select, .filters input { min-width: 0; flex: 1; }
}
