@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #3a75c4;
  --primary-hover: #2f62a6;
  --primary-light: #e8f0fb;
  --accent: #8bc34a;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f4f7fb;
  --bg-card: #ffffff;
  --sidebar-bg: #dbe4ef;
  --sidebar-hover: #c9d6e4;
  --sidebar-active: #b2c5d9;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.12);
}

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

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 1.125rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.sidebar-logo .brand {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.sidebar-logo .version {
  font-size: 0.65rem;
  color: var(--text-light);
  margin-left: 4px;
}

.sidebar-section {
  padding: 1rem 0.75rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #728094;
  padding-left: 1.25rem;
}

.nav-links {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: #334155;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-item:hover { background: var(--sidebar-hover); color: var(--primary-hover); }
.nav-item.active { background: var(--sidebar-active); color: var(--primary); font-weight: 700; }
.nav-item.active svg { color: var(--primary); }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Main Content ────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.top-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 50;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  width: 380px;
}
.search-bar input {
  border: none; background: none; outline: none;
  font-size: 0.875rem; color: var(--text); width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }

.top-actions { display: flex; align-items: center; gap: 1rem; }
.icon-btn { position: relative; cursor: pointer; color: var(--text-muted); transition: color 0.2s; padding: 0.375rem; border-radius: 6px; }
.icon-btn:hover { color: var(--primary); background: var(--primary-light); }
.notification-badge { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; background: var(--danger); border-radius: 50%; border: 1.5px solid white; }

.user-pill {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.25rem 0.875rem 0.25rem 0.25rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 9999px; cursor: pointer; transition: all 0.2s;
}
.user-pill:hover { border-color: var(--primary); }

.avatar-sm {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; flex-shrink: 0;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.glass-card:hover { box-shadow: var(--shadow); }

/* ── Page Header ─────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.375rem; font-weight: 700; color: var(--text);
}
.page-header p { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* kept for legacy templates */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }

/* ── Stat Cards ──────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.5rem;
}
.stat-card .value {
  font-size: 1.875rem; font-weight: 800; color: var(--text);
  line-height: 1.1;
}
.stat-card .sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.stat-card h3 { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.5rem; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font-size: 0.875rem; font-weight: 600;
  transition: all 0.15s ease; text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary); color: white; border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(58,117,196,0.25); }

.btn-outline {
  background: transparent; color: var(--text-muted); border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

.btn-icon {
  padding: 0.4rem; background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted);
  transition: all 0.15s; display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-icon svg { width: 14px; height: 14px; }

/* ── Forms ───────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text); margin-bottom: 0.375rem; }
.form-control {
  width: 100%; padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); font-size: 0.875rem; line-height: 1.2; color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ── Table ───────────────────────────────────── */
.table-container { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  text-align: left; padding: 0.75rem 1rem;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
tbody td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0.2rem 0.625rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 700; white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,0.12); color: #059669; }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-danger  { background: rgba(239,68,68,0.12);  color: #dc2626; }
.badge-info    { background: rgba(79,70,229,0.10);  color: var(--primary); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Modals ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(4px);
  display: none; justify-content: center; align-items: center;
  z-index: 1000; padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.5rem 1.75rem 0;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 700; }
.modal-body { padding: 1.25rem 1.75rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1rem 1.75rem 1.5rem;
  border-top: 1px solid var(--border);
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.25rem;
  border-radius: 6px; transition: all 0.15s;
  font-size: 1.25rem; line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ── Tabs ────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1.5px solid var(--border); margin-bottom: 1.25rem; }
.tab {
  padding: 0.75rem 1.25rem; cursor: pointer;
  font-size: 0.875rem; font-weight: 500; color: var(--text-muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
  transition: all 0.15s; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Kanban ──────────────────────────────────── */
.kanban-board {
  display: flex; gap: 1rem;
  overflow-x: auto; align-items: flex-start;
  padding-bottom: 1rem;
  min-height: calc(100vh - 280px);
}
.kanban-column {
  background: #f3f4f8; border-radius: var(--radius);
  min-width: 290px; width: 290px;
  display: flex; flex-direction: column;
}
.kanban-col-header {
  padding: 1rem; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1.5px solid var(--border); background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col-header h3 { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.kanban-col-body { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.75rem; flex: 1; min-height: 120px; }

.kanban-card {
  background: var(--bg-card); padding: 1rem; border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: grab;
  transition: all 0.2s ease;
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
}
.kanban-card.dragging {
  opacity: 0.6;
  transform: scale(0.98) rotate(2deg);
  box-shadow: var(--shadow-lg);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; }
.kanban-card p { font-size: 0.75rem; color: var(--text-muted); }
.kanban-card .footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.75rem; padding-top: 0.625rem;
  border-top: 1px dashed var(--border);
}

/* ── Chat ────────────────────────────────────── */
.chat-container { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.5rem 0; max-height: 320px; overflow-y: auto; }
.chat-bubble {
  max-width: 78%; padding: 0.625rem 0.875rem;
  border-radius: 1rem; font-size: 0.85rem; line-height: 1.4;
}
.chat-bubble.me { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.other { align-self: flex-start; background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.chat-time { font-size: 0.65rem; opacity: 0.65; margin-top: 3px; display: block; text-align: right; }

/* ── Animations ──────────────────────────────── */
.animate-fade-in { animation: fade-in 0.3s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; vertical-align: middle; }

/* ── Misc ────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; opacity: 0.4; margin-bottom: 1rem; display: block; margin-left: auto; margin-right: auto; }

/* Plan card styles */
.plan-card { transition: all 0.2s; cursor: pointer; border: 2px solid transparent; }
.plan-card.selected { border-color: var(--primary); background: var(--primary-light); }
.plan-row-premium {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.875rem 1rem; background: var(--bg-card);
  border: 1.5px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: all 0.18s;
}
.plan-row-premium:hover { border-color: var(--primary); background: var(--primary-light); transform: translateX(2px); }
.plan-row-premium.selected { border-color: var(--primary); background: var(--primary-light); }
.plan-icon-box {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  background: var(--primary-light); display: flex; align-items: center;
  justify-content: center; color: var(--primary);
}
.plan-icon-box svg { width: 18px; height: 18px; }
.plan-name { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.plan-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  padding: 2px 8px; border-radius: 9999px;
  font-size: 0.65rem; font-weight: 600;
  background: var(--bg); color: var(--text-muted);
  border: 1px solid var(--border);
}
.plan-price-box { margin-left: auto; text-align: right; flex-shrink: 0; }
.plan-price { font-size: 1rem; font-weight: 800; color: var(--primary); }
.plan-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; color: transparent; }
.plan-row-premium.selected .plan-check { background: var(--primary); border-color: var(--primary); color: white; }

/* Proposal bar */
.proposal-bar {
  position: fixed; bottom: 0; left: 240px; right: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white; padding: 1rem 2rem;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 -4px 20px rgba(79,70,229,0.25);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  z-index: 500;
}
.proposal-bar.visible { transform: translateY(0); }

/* Tier card (commission rules) */
.tier-card {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.dist-row {
  display: grid; grid-template-columns: 1fr 100px 36px;
  gap: 0.5rem; margin-bottom: 0.5rem; align-items: center;
}

/* Misc utility */
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.875rem; font-weight: 500; padding: 0; text-decoration: underline; }
