/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:         #0f1117;
  --bg-card:    #1a1d27;
  --bg-sidebar: #111420;
  --border:     #2a2d3e;
  --accent:     #00d4aa;
  --accent-dim: #00d4aa22;
  --red:        #ef4444;
  --yellow:     #f59e0b;
  --blue:       #3b82f6;
  --green:      #22c55e;
  --gray:       #6b7280;

  --text:       #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim:   #64748b;

  --radius:  8px;
  --sidebar: 220px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.sidebar-logo .brand { font-size: 1.15rem; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
.sidebar-logo .tagline { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

.nav { list-style: none; flex: 1; }
.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: color 0.15s, background 0.15s;
  border-radius: 0;
}
.nav-item a:hover,
.nav-item a.active {
  color: var(--text);
  background: var(--accent-dim);
  text-decoration: none;
}
.nav-item a.active { color: var(--accent); }
.nav-icon { width: 16px; text-align: center; opacity: 0.8; }

.nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 1rem 1.25rem 0.3rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.sidebar-footer .user-name { font-weight: 600; color: var(--text); }

.main { overflow-x: hidden; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

.page { padding: 2rem; max-width: 1200px; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 1rem; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 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;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.65rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
tr:hover td { background: var(--accent-dim); }

/* ── Status badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}
.badge-scheduled  { background: #374151; color: #9ca3af; }
.badge-in_progress{ background: #451a03; color: #fbbf24; }
.badge-review     { background: #1e3a5f; color: #60a5fa; }
.badge-completed  { background: #052e16; color: #4ade80; }
.badge-cancelled  { background: #3f0f0f; color: #f87171; }
.badge-open       { background: #1e3a5f; color: #60a5fa; }
.badge-resolved   { background: #052e16; color: #4ade80; }
.badge-closed     { background: #374151; color: #9ca3af; }
.badge-low        { background: #1f2937; color: #9ca3af; }
.badge-normal     { background: #1e3a5f; color: #60a5fa; }
.badge-high       { background: #451a03; color: #fbbf24; }
.badge-urgent     { background: #3f0f0f; color: #f87171; }
.badge-blackbox   { background: #1e1e2e; color: #a78bfa; }
.badge-greybox    { background: #1a2535; color: #7dd3fc; }
.badge-whitebox   { background: #052e16; color: #4ade80; }

/* ── Buttons ──────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: var(--accent); color: #0f1117; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: #3f0f0f; color: var(--red); border: 1px solid #7f1d1d; }
.btn-sm        { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.35rem; }
input, textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 100px; }
select option { background: var(--bg-card); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  padding: 1.5rem;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }

/* ── Timeline (status tracker) ───────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: '';
  position: absolute; left: 7px; top: 8px; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-dot {
  position: absolute; left: -1.5rem; top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
.timeline-dot.status_change { background: var(--accent); }
.timeline-dot.phase_update  { background: var(--blue); }
.timeline-dot.note          { background: var(--gray); }
.timeline-time { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.15rem; }
.timeline-desc { font-size: 0.88rem; }

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .brand { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.login-logo .tagline { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.25rem; }
.error-msg { background: #3f0f0f; color: var(--red); padding: 0.6rem 0.9rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; }

/* ── Blog ─────────────────────────────────────────────────────────────────────── */
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.blog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; flex-direction: column;
}
.blog-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.blog-card-summary { font-size: 0.85rem; color: var(--text-muted); flex: 1; margin-bottom: 0.75rem; }
.blog-card-meta { font-size: 0.75rem; color: var(--text-dim); }
.blog-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.blog-tag {
  background: var(--accent-dim); color: var(--accent);
  padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.72rem;
}
.blog-body { line-height: 1.8; font-size: 0.92rem; }
.blog-body h1, .blog-body h2, .blog-body h3 { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; }
.blog-body p { margin-bottom: 1rem; }
.blog-body code { background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; }
.blog-body pre { background: var(--bg); padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin: 1rem 0; }

/* ── Misc ─────────────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem; color: var(--text-dim); font-size: 0.9rem; }
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Real-time indicator ───────────────────────────────────────────────────────── */
.ws-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gray); display: inline-block;
}
.ws-indicator.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
}
