/* ===== CSS Variables ===== */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-dim: rgba(167, 139, 250, 0.15);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 10px;
  --navbar-h: 56px;
}

[data-theme="light"] {
  --bg: #f5f0e8;
  --bg2: #ede8de;
  --bg3: #e4ddd2;
  --border: #ccc4b8;
  --text: #2d2417;
  --text-muted: #7a6d5e;
  --accent: #7c5cbf;
  --accent-hover: #9d7de0;
  --accent-dim: rgba(124, 92, 191, 0.12);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.navbar-brand:hover { color: var(--accent); }

.navbar-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.navbar-links a {
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: color 0.15s, background 0.15s;
}
.navbar-links a:hover {
  color: var(--text);
  background: var(--bg3);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn-icon:hover {
  color: var(--text);
  background: var(--border);
  border-color: var(--accent);
}

/* ===== Container ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 80px 0 60px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #60a5fa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
}

.hero-sub {
  font-size: 1.2rem;
  color: var(--text-muted);
}

/* ===== Cards Grid ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 0;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.card-link {
  cursor: pointer;
}
.card-link:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(167, 139, 250, 0.2);
}

.card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.card-body {
  flex: 1;
}

.card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
  border: none;
  cursor: pointer;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
}

/* ===== Dashboard ===== */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

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

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: border-color 0.2s;
}
.stat-card:hover {
  border-color: var(--accent);
}

.stat-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Table ===== */
.table-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.agents-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.agents-table thead th {
  background: var(--bg3);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.agents-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.agents-table tbody tr:last-child {
  border-bottom: none;
}
.agents-table tbody tr:hover {
  background: var(--bg3);
}

.agents-table td {
  padding: 14px 16px;
  color: var(--text);
}

.agent-emoji {
  font-size: 1.1rem;
  margin-right: 4px;
}

.loading-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

/* ===== File Exchange ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  padding: 60px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 24px;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.upload-zone.dragover .upload-icon {
  transform: scale(1.15);
}
.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  transition: transform 0.2s;
  display: block;
}
.upload-hint-main {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.upload-hint-sub {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upload-progress-wrap {
  margin-bottom: 20px;
}
.upload-progress-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.progress-bar-track {
  background: var(--bg3);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width 0.2s;
}

.table-section { margin-top: 8px; }

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
  min-height: 36px;
}

.btn-dl {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.btn-dl:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.file-name-cell {
  word-break: break-all;
  max-width: 320px;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero-title { font-size: 2rem; }
  .navbar { padding: 0 16px; gap: 12px; }
  .navbar-links { display: none; }
  .container { padding: 24px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .agents-table { font-size: 0.85rem; }
  .agents-table td, .agents-table th { padding: 10px 10px; }
}

.btn-danger {
  background: #da3633;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  margin-left: 8px;
  transition: background 0.2s;
}
.btn-danger:hover { background: #f85149; }
