/* Sassy Configuration UI — aligned with ma-ops (M&Asana): Inter, gray + indigo */

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

:root {
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-surface: rgba(249, 250, 251, 0.8);
  --bg-secondary: #f3f4f6;
  --bg-hover: #f9fafb;
  --text: #111827;
  --text-soft: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ring: #e0e7ff;
  --accent-strong: #3730a3;
  --accent-glow: #eef2ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --error: #dc2626;
  --error-soft: #fef2f2;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --border-subtle: #f3f4f6;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, .14);
  --font: "Inter", ui-sans-serif, system-ui, sans-serif;
  --serif: var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --muted: var(--text-muted);
  --fg: var(--text);
  --primary: var(--accent);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ── Animations ─────────────────────────────────────────────── */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes glow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Layout ─────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.25rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex: none;
}

.sidebar .space-switcher { margin: 0 0.75rem 0.75rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 0.75rem; }

.sidebar-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 1.25rem 1.25rem 0.25rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4rem 0.625rem;
  border-radius: 0.5rem;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.12s, color 0.12s;
}

.sidebar-nav a svg { flex: none; width: 16px; height: 16px; color: var(--text-muted); }
.sidebar-nav a:hover { background: #e5e7eb; color: var(--text); }
.sidebar-nav a.active { background: var(--accent-ring); color: var(--accent-strong); font-weight: 500; }
.sidebar-nav a.active svg { color: var(--accent); }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  overflow: hidden;
  background: #d1fae5;
  color: #065f46;
  font-size: 0.75rem;
  font-weight: 600;
}

.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.sidebar-footer .who { min-width: 0; flex: 1; }
.sidebar-footer .who-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  padding: 0.25rem;
  border-radius: 6px;
  color: var(--text-faint);
  background: transparent;
  border: none;
}

.icon-btn:hover { background: #e5e7eb; color: var(--text-soft); }
.icon-btn svg { width: 16px; height: 16px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 2rem 4rem;
  overflow-x: auto;
  animation: fadeIn 0.25s var(--ease) both;
}

.main h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ── Cards ──────────────────────────────────────────────────── */

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

.card h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Stats ──────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.25rem;
  transition: border-color 0.12s;
}

.stat:hover { border-color: #c7d2fe; }

.stat .value {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Tables ─────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom-color: var(--border);
}

tr:hover td { background: var(--bg-hover); }

/* ── Badges ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1rem;
  background: var(--bg-secondary);
  color: var(--text-muted);
}

.badge-ok, .badge-enabled { background: var(--success-soft); color: #047857; }
.badge-error { background: var(--error-soft); color: #b91c1c; }
.badge-unknown, .badge-disabled { background: var(--bg-secondary); color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────── */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

button:hover, .btn:hover { background: var(--accent-hover); }

button.secondary, .btn-ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text-soft);
}

button.secondary:hover, .btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

button.danger {
  background: var(--error-soft);
  border-color: #fecaca;
  color: #b91c1c;
}

button.danger:hover { background: #fee2e2; }

button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */

input, textarea, select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  font-family: var(--font);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input:disabled { background: var(--bg-hover); color: var(--text-muted); }

input[type="checkbox"] { width: auto; accent-color: var(--accent); }

textarea {
  font-family: var(--mono);
  font-size: 0.8125rem;
  min-height: 200px;
  resize: vertical;
  line-height: 1.6;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.form-group { margin-bottom: 1rem; }

/* ── Toggle ─────────────────────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 22px;
  transition: 0.25s var(--ease);
}

.toggle .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s var(--ease);
}

.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

/* ── Modal ──────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s var(--ease);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-pop);
  padding: 1.5rem;
  min-width: 400px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  animation: fadeUp 0.3s var(--ease);
}

.modal h3 {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ── Space switcher ─────────────────────────────────────────── */

.space-switcher-btn {
  width: 100%;
  justify-content: space-between;
  text-align: left;
  padding: 0.375rem 0.625rem;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
}

.space-switcher-btn:hover { background: #fff; border-color: var(--border-strong); }

.space-switcher-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.space-switcher-menu input { border: none; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 0.5rem 0.75rem; }
.space-switcher-menu input:focus { box-shadow: none; }

.space-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 400;
}

.space-option:hover, .space-option.hl { background: var(--accent-soft); }
.space-option.selected { font-weight: 600; }
.space-option .sub { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

/* ── Utility ────────────────────────────────────────────────── */

.mono { font-family: var(--mono); font-size: 0.8125rem; }
.muted { color: var(--text-muted); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.flex { display: flex; align-items: center; gap: 0.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* ── Spinner ────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-ring);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Charts ─────────────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-bar { transition: opacity 0.15s var(--ease); }
.chart-bar:hover { opacity: 0.8; }

/* ── Markdown Editor ────────────────────────────────────────── */

.md-editor {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.md-toolbar {
  display: flex;
  gap: 2px;
  padding: 0.4rem 0.6rem;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
}

.md-toolbar button {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-family: var(--mono);
  font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 3px;
  cursor: pointer;
  line-height: 1.2;
  transition: all 0.15s var(--ease);
}

.md-toolbar button:hover {
  border-color: var(--border);
  color: var(--accent);
  background: #fff;
}

.md-split {
  display: flex;
  height: 520px;
}

.md-split textarea {
  flex: 1;
  resize: none;
  min-height: unset;
  height: 100%;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  margin: 0;
  background: #fff;
  padding: 1rem;
  font-size: 0.8125rem;
}

.md-split textarea:focus {
  box-shadow: none;
  border-color: var(--border);
  border-right-color: var(--accent);
}

.md-preview {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  font-size: 0.88rem;
  line-height: 1.7;
}

.md-preview h1 { font-size: 1.4rem; font-weight: 600; margin: 1rem 0 0.4rem; }
.md-preview h2 { font-size: 1.15rem; font-weight: 600; margin: 0.8rem 0 0.3rem; }
.md-preview h3 { font-size: 1rem; font-weight: 600; margin: 0.7rem 0 0.25rem; }
.md-preview p { margin: 0.45rem 0; }
.md-preview code {
  background: var(--bg-secondary);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.84em;
  color: var(--accent-strong);
}
.md-preview pre {
  background: var(--bg-hover);
  padding: 0.85rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0.6rem 0;
  border: 1px solid var(--border-subtle);
}
.md-preview pre code { background: none; padding: 0; color: var(--text); }
.md-preview a { color: var(--accent); text-decoration-color: #c7d2fe; }
.md-preview a:hover { text-decoration-color: var(--accent); }
.md-preview ul, .md-preview ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.md-preview blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 0.6rem 0;
  font-style: italic;
}
.md-preview table { width: 100%; margin: 0.5rem 0; }
.md-preview img { max-width: 100%; border-radius: var(--radius); }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Scrollbar ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .md-split { flex-direction: column; height: auto; }
  .md-split textarea {
    min-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .md-preview { min-height: 200px; }
}
