/* ===== Creshyt Desk — Theme ===== */
:root {
  --bg: #0f1420;
  --bg-elevated: #161d2e;
  --bg-card: #1b2436;
  --border: #2a3448;
  --text: #e8ecf4;
  --text-muted: #8b93a7;
  --accent: #3ba7ff;
  --accent-dark: #2b7fd0;
  --green: #34c78a;
  --red: #f0556b;
  --yellow: #e8b84b;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }

/* ===== Login ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; width: 100%; max-width: 380px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; margin: 0 auto 12px;
}
.login-logo.small { width: 36px; height: 36px; font-size: 0.85rem; margin: 0; }
.login-brand h1 { font-size: 1.3rem; margin: 0 0 4px; }
.login-form label { display: block; font-size: 0.82rem; margin: 14px 0 6px; color: var(--text-muted); }
.login-form input {
  width: 100%; padding: 11px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); font-size: 0.95rem;
}
.login-form input:focus { outline: none; border-color: var(--accent); }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 14px; }
.alert-error { background: rgba(240,85,107,0.12); color: var(--red); border: 1px solid rgba(240,85,107,0.3); }
.alert-success { background: rgba(52,199,138,0.12); color: var(--green); border: 1px solid rgba(52,199,138,0.3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 0.9rem; font-weight: 600; text-decoration: none; transition: opacity .15s;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }

/* ===== App Shell ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg-elevated); border-right: 1px solid var(--border);
  padding: 20px 16px; display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.brand-title { font-weight: 700; font-size: 0.95rem; }

.business-switcher { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.business-btn {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted); cursor: pointer; text-align: left;
  font-size: 0.85rem; font-weight: 600;
}
.business-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--text-muted);
  font-size: 0.88rem; font-weight: 500;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--bg-card); color: var(--accent); }

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.main-content { flex: 1; padding: 28px 32px; overflow-y: auto; }
.loading { color: var(--text-muted); padding: 40px; text-align: center; }

/* ===== Cards / Sections ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { margin: 0; font-size: 1.35rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.tag-lead { background: rgba(232,184,75,0.15); color: var(--yellow); }
.tag-in_talks { background: rgba(59,167,255,0.15); color: var(--accent); }
.tag-active { background: rgba(52,199,138,0.15); color: var(--green); }
.tag-churned { background: rgba(240,85,107,0.15); color: var(--red); }
.tag-paid { background: rgba(52,199,138,0.15); color: var(--green); }
.tag-unpaid { background: rgba(240,85,107,0.15); color: var(--red); }

/* ===== Kanban ===== */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kanban-col { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kanban-col h4 { margin: 0 0 10px; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kanban-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: grab;
}
.kanban-card .task-title { font-weight: 600; font-size: 0.88rem; margin-bottom: 4px; }
.kanban-card .task-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; white-space: pre-wrap; }
.kanban-card .task-due { font-size: 0.75rem; color: var(--text-muted); }
.kanban-col.drag-over { outline: 2px dashed var(--accent); }

/* ===== Scripts library ===== */
.script-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.script-card pre { white-space: pre-wrap; font-family: inherit; background: var(--bg-elevated); padding: 12px; border-radius: 8px; font-size: 0.85rem; margin: 8px 0; }

/* ===== Forms / Modal ===== */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.82rem; margin-bottom: 6px; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 11px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 0.9rem; font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.progress-bar-track { background: var(--bg-elevated); border-radius: 20px; height: 10px; overflow: hidden; }
.progress-bar-fill { background: var(--accent); height: 100%; transition: width .3s; }

.icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.85rem; padding: 4px 6px; }
.icon-btn:hover { color: var(--text); }

.empty-state { color: var(--text-muted); text-align: center; padding: 30px; font-size: 0.9rem; }

/* ===== Mobile ===== */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; padding: 14px; }
  .sidebar-brand { width: 100%; margin-bottom: 12px; }
  .business-switcher { flex-direction: row; width: 100%; }
  .business-btn { flex: 1; }
  .nav-list { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .sidebar-footer { width: 100%; flex-direction: row; }
  .main-content { padding: 18px; }
  .kanban { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
}
