*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f0f0f;
  --surface:    #1a1a1a;
  --surface2:   #222222;
  --surface3:   #2a2a2a;
  --border:     #2e2e2e;
  --text:       #e0e0e0;
  --text-muted: #888;
  --accent:     #5865f2;
  --accent-dim: rgba(88, 101, 242, 0.15);
  --success:    #3ba55c;
  --danger:     #ed4245;
  --warning:    #faa61a;
  --radius:     8px;
  --radius-lg:  12px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Consolas', 'Cascadia Code', monospace;
  font-size: 12px;
}

.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav-inner {
  width: 100%;
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.brand i { color: var(--accent); font-size: 18px; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.nav-username {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 12px;
  text-decoration: none;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  text-decoration: none;
}

.page-wrapper {
  flex: 1;
  width: 100%;
  padding: 28px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.site-footer {
  text-align: center;
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 11px;
  border-top: 1px solid var(--border);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header h1 i { color: var(--accent); }

.page-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.filter-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filter-group select,
.filter-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 140px;
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--accent);
}

.btn-filter,
.btn-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn-filter {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-clear:hover {
  border-color: var(--danger);
  color: var(--danger);
  text-decoration: none;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.open   { background: rgba(59, 165, 92, 0.15);  color: var(--success); }
.stat-icon.closed { background: rgba(237, 66, 69, 0.15);  color: var(--danger);  }
.stat-icon.total  { background: var(--accent-dim);         color: var(--accent);  }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  background: var(--surface2);
  color: #fff;
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
}

.data-table tbody tr {
  border-bottom: 1px solid #1e1e1e;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table td {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  vertical-align: middle;
}

.data-table td.col-id     { color: var(--text); font-weight: 600; white-space: nowrap; }
.data-table td.col-mono   { font-family: 'Consolas', monospace; font-size: 12px; }
.data-table td.col-date   { white-space: nowrap; }
.data-table td.col-subject { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.data-table td.col-actions { text-align: right; }
.data-table td.col-muted  { color: var(--text-muted); }

.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.badge-open   { background: rgba(59, 165, 92, 0.15);  color: var(--success); border: 1px solid rgba(59, 165, 92, 0.3); }
.badge-closed { background: rgba(237, 66, 69, 0.15);  color: var(--danger);  border: 1px solid rgba(237, 66, 69, 0.3); }

.btn-view {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.btn-view:hover { background: var(--accent); color: #fff; text-decoration: none; }
.btn-view.disabled { background: var(--surface3); color: var(--text-muted); cursor: not-allowed; }

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px;
  justify-content: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
}

.pager-btn:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.pager-btn.current { background: var(--accent); color: #fff; border-color: var(--accent); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state i { font-size: 36px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  gap: 20px;
  text-align: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 420px;
  width: 100%;
}

.login-icon { font-size: 48px; color: var(--accent); }
.login-title { color: #fff; font-size: 22px; font-weight: 700; }
.login-desc { color: var(--text-muted); font-size: 13px; line-height: 1.6; }

.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #5865f2;
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  width: 100%;
  justify-content: center;
}

.btn-discord:hover { background: #4752c4; text-decoration: none; }

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  gap: 16px;
  text-align: center;
}

.error-code { font-size: 72px; font-weight: 700; color: var(--accent); line-height: 1; }
.error-title { font-size: 22px; color: #fff; font-weight: 600; }
.error-desc { font-size: 14px; color: var(--text-muted); max-width: 360px; }
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 20px;
  text-decoration: none;
  font-size: 14px;
  margin-top: 8px;
}
.btn-back:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover { color: var(--text); text-decoration: none; }

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.detail-title-row h1 {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}

.detail-actors {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.actor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}

.actor-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.actor-label i { color: var(--accent); }

.actor-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.actor-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.actor-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.actor-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actor-id {
  font-size: 11px;
  color: var(--text-muted);
}

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-chip i { color: var(--accent); font-size: 11px; }
.meta-chip.rating-chip { border-color: rgba(250, 166, 26, 0.4); color: var(--warning); }
.meta-chip.rating-chip i { color: var(--warning); }

.close-reason-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(237, 66, 69, 0.08);
  border: 1px solid rgba(237, 66, 69, 0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
}

.close-reason-banner i { color: var(--danger); flex-shrink: 0; margin-top: 2px; }
.close-reason-banner strong { color: var(--danger); }

.transcript-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.transcript-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.btn-raw {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 5px;
  background: var(--accent-dim);
}

.btn-raw:hover { background: var(--accent); color: #fff; text-decoration: none; }

.transcript-frame-wrap {
  height: 700px;
  background: #313338;
}

.transcript-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.notes-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.notes-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.notes-header i { color: var(--warning); }
.notes-header h2 { color: #fff; font-size: 14px; font-weight: 600; }

.notes-count {
  background: rgba(250, 166, 26, 0.15);
  color: var(--warning);
  border: 1px solid rgba(250, 166, 26, 0.3);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}

.notes-list { display: flex; flex-direction: column; }

.note-item {
  padding: 14px 20px;
  border-bottom: 1px solid #1e1e1e;
}

.note-item:last-child { border-bottom: none; }

.note-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.note-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
}

.note-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Consolas', monospace;
}

.note-body {
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.55;
}

@media (max-width: 1024px) {
  .topnav-inner { padding: 0 20px; }
  .page-wrapper  { padding: 20px 20px 32px; }
}

@media (max-width: 768px) {
  .topnav-inner { padding: 0 16px; }
  .page-wrapper  { padding: 16px 16px 32px; }
  .stats-row     { grid-template-columns: 1fr; }
  .page-header   { flex-direction: column; }
  .filter-form   { flex-direction: column; align-items: stretch; }
  .filter-group select,
  .filter-group input { min-width: 0; width: 100%; }
  .transcript-frame-wrap { height: 480px; }
  .login-card { padding: 32px 24px; }
  .detail-actors { flex-direction: column; }
  .actor-card { min-width: 0; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .data-table td.col-date { display: none; }
  .data-table td.col-subject { display: none; }
}