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

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

:root {
  --bg: #080c14;
  --surface: #0e1420;
  --surface2: #141b2d;
  --surface3: #1a2236;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.15);
  --blue-glow: rgba(59,130,246,0.3);
  --text: #e2e8f4;
  --muted: #64748b;
  --muted2: #94a3b8;
  --error: #f87171;
  --success: #34d399;
  --warning: #fbbf24;
  --purple: #818cf8;
  --sidebar-w: 220px;
  --radius: 10px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 200;
  gap: 2px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-logo-icon {
  width: 28px; height: 28px;
  background: var(--blue);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  box-shadow: 0 0 16px var(--blue-glow);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--muted2);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--surface3); color: var(--text); }
.nav-item.active { background: var(--blue-dim); color: var(--blue); }
.nav-icon { font-size: 15px; flex-shrink: 0; }

.sidebar-spacer { flex: 1; }

.sidebar-avatar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

.sidebar-avatar:hover { background: var(--surface3); }

.avatar-icon {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}

.avatar-info { flex: 1; min-width: 0; }
.avatar-email { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-action { font-size: 11px; color: var(--muted); }

/* ── Main shell ── */
.shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.topbar-crumb {
  color: var(--muted);
  font-size: 13px;
}

.topbar-sep { color: var(--muted); font-size: 12px; }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Content area ── */
.content {
  flex: 1;
  padding: 32px 36px;
}

/* ── View transitions ── */
.view { display: none; }
.view.active {
  display: block;
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Dashboard cards ── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.tool-card:hover {
  border-color: var(--blue);
  background: var(--surface2);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.tool-card-icon {
  width: 40px; height: 40px;
  background: var(--blue-dim);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.tool-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.tool-card-desc { font-size: 12px; color: var(--muted2); line-height: 1.5; }

/* ── Section header ── */
.section-header { margin-bottom: 20px; }
.section-title { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.section-subtitle { font-size: 13px; color: var(--muted2); }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Forms ── */
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input, select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

input::placeholder { color: var(--muted); }
select option { background: var(--surface2); }

/* ── Buttons ── */
.btn {
  padding: 7px 16px;
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: white;
  box-shadow: 0 1px 3px rgba(59,130,246,0.3);
}
.btn-primary:hover { background: #2563eb; box-shadow: 0 4px 12px rgba(59,130,246,0.4); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  background: transparent;
  color: var(--muted2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border2); background: var(--surface3); }

/* ── Panel / card ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title { font-size: 13px; font-weight: 600; }
.panel-meta { font-size: 12px; color: var(--muted); }

/* ── Ticket list ── */
.ticket-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: pointer;
}

.ticket-item:last-child { border-bottom: none; }
.ticket-item:hover { background: var(--surface2); }

.ticket-item input[type="checkbox"] {
  margin-top: 2px;
  width: 15px; height: 15px;
  flex-shrink: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.ticket-info { flex: 1; min-width: 0; }
.ticket-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; line-height: 1.4; }
.ticket-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface3);
  color: var(--muted2);
  border: 1px solid var(--border);
}

.badge.project { color: #60a5fa; border-color: rgba(96,165,250,0.2); background: rgba(96,165,250,0.08); }
.badge.status-backlog { color: #64748b; border-color: rgba(100,116,139,0.2); background: rgba(100,116,139,0.08); }
.badge.status-todo { color: #94a3b8; border-color: rgba(148,163,184,0.2); background: rgba(148,163,184,0.08); }
.badge.status-inprogress { color: #fbbf24; border-color: rgba(251,191,36,0.2); background: rgba(251,191,36,0.08); }
.badge.status-review { color: #a78bfa; border-color: rgba(167,139,250,0.2); background: rgba(167,139,250,0.08); }
.badge.status-done { color: #34d399; border-color: rgba(52,211,153,0.2); background: rgba(52,211,153,0.08); }

/* ── Messages ── */
.message {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  display: none;
  margin-top: 12px;
}

.message.error { background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.2); color: var(--error); display: block; }
.message.success { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.2); color: var(--success); display: block; }

/* ── Generate bar ── */
.generate-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.generate-bar input { flex: 1; min-width: 180px; }
.selected-count { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Select actions ── */
.select-actions { display: flex; gap: 6px; }
.select-btn {
  font-size: 11px; color: var(--muted); cursor: pointer;
  padding: 2px 8px; border-radius: 4px; transition: color 0.15s;
  background: none; border: 1px solid var(--border); font-family: 'Inter', sans-serif;
}
.select-btn:hover { color: var(--text); border-color: var(--border2); }

/* ── Empty state ── */
.empty-state { padding: 48px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.5; }
.empty-text { font-size: 13px; }

/* ── Spinner ── */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login page ── */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59,130,246,0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(129,140,248,0.06), transparent);
  pointer-events: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 1;
  box-shadow: 0 32px 64px rgba(0,0,0,0.5);
  animation: fadeIn 0.4s ease both;
}

.login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  box-shadow: 0 0 20px var(--blue-glow);
}

.login-logo-text {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; font-family: 'Inter', sans-serif; }
.login-subtitle { color: var(--muted2); font-size: 13px; margin-bottom: 28px; }

.login-card input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}

.btn-login {
  width: 100%;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-login:hover { background: #2563eb; box-shadow: 0 4px 16px var(--blue-glow); }
.btn-login:disabled { opacity: 0.4; cursor: not-allowed; }

.otp-inputs { display: flex; gap: 8px; margin-bottom: 14px; }
.otp-inputs input {
  width: 44px; height: 52px;
  text-align: center; font-size: 20px; font-weight: 600;
  margin-bottom: 0; padding: 0;
}

.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 12px; cursor: pointer;
  margin-bottom: 20px; background: none; border: none; padding: 0;
  font-family: 'Inter', sans-serif; transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.login-message { margin-top: 12px; }
.step { display: none; }
.step.active { display: block; }