:root, [data-theme="light"] {
  --pink: #E8A0BF;
  --pink-light: #FFF0F6;
  --pink-dark: #C67A9E;
  --text: #2D2D2D;
  --text-light: #666;
  --bg: #FAFAFA;
  --card-bg: #FFF;
  --border: #E5E5E5;
  --success: #4CAF50;
  --warning: #FF9800;
  --radius: 12px;
  --sidebar-bg: #FEFEFE;
  --msg-user-bg: #E8F0FE;
  --msg-asst-bg: #F5F5F5;
  --code-bg: #F8F8F8;
  --hover-bg: var(--pink-light);
  --topbar-bg: #FFF;
  --toggle-icon: '🌙';
}

[data-theme="dark"] {
  --pink: #D48AAA;
  --pink-light: #2A1A22;
  --pink-dark: #E8A0BF;
  --text: #E0E0E0;
  --text-light: #999;
  --bg: #1A1A1E;
  --card-bg: #242428;
  --border: #333338;
  --success: #66BB6A;
  --warning: #FFA726;
  --sidebar-bg: #1E1E22;
  --msg-user-bg: #1E2A3A;
  --msg-asst-bg: #2A2A2E;
  --code-bg: #1E1E22;
  --hover-bg: #2A1A22;
  --topbar-bg: #242428;
  --toggle-icon: '☀️';
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--pink-light), #fff);
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  max-width: 400px;
  width: 90%;
}

.logo { font-size: 4rem; margin-bottom: 0.5rem; }
.login-card h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-light); margin-bottom: 1.5rem; }

.info-box {
  background: var(--pink-light);
  border-radius: 8px;
  padding: 1rem;
}
.info-box p { font-size: 0.95rem; }
.small { font-size: 0.8rem; color: var(--text-light); margin-top: 0.5rem; }

.alert { padding: 0.75rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: #FFF0F0; color: #C62828; }
.alert.success { background: #F0FFF0; color: #2E7D32; }

/* ── Top bar ────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-sm {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.user-info { color: var(--text-light); font-size: 0.9rem; }

/* ── Container ──────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.container h1 { font-size: 1.4rem; margin-bottom: 1rem; }

/* ── Breadcrumbs ────────────────────────────────────────── */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}
.breadcrumbs span { margin: 0 0.3rem; }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--pink-dark); border-bottom-color: var(--pink); font-weight: 500; }

/* ── Project grid ───────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow 0.2s, border-color 0.2s;
  display: block;
  color: var(--text);
}

.project-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--pink);
  text-decoration: none;
}

.project-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.project-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.project-meta { font-size: 0.8rem; color: var(--text-light); display: flex; justify-content: space-between; }

/* ── File list ──────────────────────────────────────────── */
.file-list {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-row {
  display: grid;
  grid-template-columns: 2rem 1fr 80px 100px 40px;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}

.file-row:hover { background: var(--pink-light); }
.file-row:last-child { border-bottom: none; }
.file-icon { text-align: center; }
.file-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 0.8rem; color: var(--text-light); text-align: right; }
.file-date { font-size: 0.8rem; color: var(--text-light); text-align: right; }
.btn-download { text-align: center; opacity: 0.5; transition: opacity 0.2s; text-decoration: none; }
.btn-download:hover { opacity: 1; }

/* ── Preview panel ──────────────────────────────────────── */
.preview-panel {
  position: fixed;
  top: 0; right: 0;
  width: 50%;
  height: 100vh;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.btn-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 0.25rem 0.5rem; }
.preview-content { flex: 1; overflow: auto; padding: 1rem; }
.code-preview { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem; white-space: pre-wrap; line-height: 1.5; }

/* ── Chat layout (Conversations tab) ────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: calc(100vh - 180px);
  min-height: 500px;
  background: var(--card-bg);
}

.chat-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--sidebar-bg);
}

.chat-sidebar h3 {
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
}

.session-item {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s;
}

.session-item:hover { background: var(--pink-light); text-decoration: none; }
.session-item.active { background: var(--pink-light); border-left: 3px solid var(--pink); }
.session-date { font-size: 0.8rem; font-weight: 500; margin-bottom: 0.2rem; }
.session-preview { font-size: 0.75rem; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { display: flex; flex-direction: column; overflow: hidden; }

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
}

.chat-empty-icon { font-size: 3rem; margin-bottom: 1rem; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.chat-message.assistant { }
.chat-message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-message.assistant .msg-avatar { background: var(--pink-light); }
.chat-message.user .msg-avatar { background: var(--msg-user-bg); }

.msg-body {
  max-width: 70%;
  background: var(--bg);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.chat-message.user .msg-body { background: var(--msg-user-bg); text-align: right; }

.msg-role { font-size: 0.75rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--text-light); }
.msg-content { font-size: 0.9rem; line-height: 1.5; word-break: break-word; }
.msg-time { font-size: 0.7rem; color: var(--text-light); margin-top: 0.3rem; }

/* ── Billing ────────────────────────────────────────────── */
.billing-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  flex: 1;
  text-align: center;
}

.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--pink-dark); }
.stat-label { font-size: 0.85rem; color: var(--text-light); margin-top: 0.25rem; }

.billing-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.billing-table th {
  background: var(--pink-light);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 500;
}

.billing-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.billing-table tr:last-child td { border-bottom: none; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  color: var(--text);
}
.theme-toggle:hover { background: var(--hover-bg); }

/* ── Kanban board ───────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.kanban-column {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.kanban-column-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-column-header .count {
  background: var(--pink-light);
  color: var(--pink-dark);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
}

.kanban-cards { padding: 0.5rem; min-height: 60px; }

.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  transition: box-shadow 0.2s;
}

.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.kanban-card .card-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-top: 0.3rem;
}
.card-tag.urgent { background: #FFEBEE; color: #C62828; }
.card-tag.normal { background: var(--pink-light); color: var(--pink-dark); }
.card-tag.done { background: #E8F5E9; color: #2E7D32; }

/* ── Stakeholders ───────────────────────────────────────── */
.stakeholders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.stakeholder-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.stakeholder-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: var(--pink-light);
  flex-shrink: 0;
}

.stakeholder-info { flex: 1; }
.stakeholder-name { font-weight: 600; font-size: 0.95rem; }
.stakeholder-role {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.1rem;
}
.stakeholder-detail {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}
.stakeholder-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--pink-light);
  color: var(--pink-dark);
  margin-top: 0.4rem;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-sidebar { max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-messages { min-height: 400px; }
  .msg-body { max-width: 85%; }
  .preview-panel { width: 100%; }
  .file-row { grid-template-columns: 2rem 1fr 60px 40px; }
  .file-date { display: none; }
  .project-grid { grid-template-columns: 1fr; }
  .billing-summary { flex-direction: column; }
}
