:root {
  --color-bg: #f8f9fa;
  --color-surface: #fff;
  --color-border: #dee2e6;
  --color-text: #212529;
  --color-muted: #6c757d;
  --color-primary: #228be6;
  --color-success: #2d6a4f;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: 780px; max-width: 95vw;
  padding: 24px; position: relative;
}
.modal-header {
  font-size: 1.2em; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  cursor: pointer; font-size: 1.2em; opacity: 0.5;
  background: none; border: none;
}
.modal-close:hover { opacity: 1; }

/* ─── Carousel ─── */
.carousel { position: relative; }
.carousel-slide { display: none; }
.carousel-slide.active { display: block; }
.carousel-indicators {
  display: flex; justify-content: center; gap: 6px; margin: 16px 0 4px;
}
.carousel-indicator {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--color-border); border: none; cursor: pointer;
}
.carousel-indicator.active { background: var(--color-primary); }
.carousel-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: transparent; border: none; font-size: 1.5em;
  cursor: pointer; z-index: 5; opacity: 0.6;
  display: flex; align-items: center; justify-content: center;
}
.carousel-btn:hover { opacity: 1; background: rgba(0,0,0,0.05); }
.carousel-btn.prev { left: -8px; }
.carousel-btn.next { right: -8px; }

/* ─── Paper / Card ─── */
.paper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.paper-title { font-size: 1em; font-weight: 600; margin-bottom: 8px; }

/* ─── Form ─── */
.form-row { display: flex; gap: 12px; margin-bottom: 8px; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; flex: 1; }
.form-label { font-size: 0.85em; color: var(--color-muted); margin-bottom: 2px; }
input[type="text"], select {
  padding: 6px 10px; border: 1px solid var(--color-border);
  border-radius: 4px; font-size: 0.95em; background: white;
}
input:focus, select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(34,139,230,0.2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 14px; border-radius: 4px; border: 1px solid var(--color-border);
  background: white; cursor: pointer; font-size: 0.9em; gap: 4px;
}
.btn:hover { background: #e9ecef; }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: #1c7cd6; }
.btn-sm { font-size: 0.8em; padding: 4px 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Tree ─── */
.tree { list-style: none; padding-left: 0; }
.tree li { padding: 2px 0; cursor: pointer; }
.tree li::before { content: "•"; margin-right: 4px; opacity: 0.5; }
.tree li.selected { font-weight: 600; color: var(--color-primary); }
.tree li.selected::before { color: var(--color-primary); opacity: 1; }
.tree ul { padding-left: 20px; }

/* ─── Auth Bar ─── */
.auth-bar { display: flex; align-items: center; gap: 10px; }
.auth-bar a { color: var(--color-primary); text-decoration: none; }
.auth-bar a:hover { text-decoration: underline; }

/* ─── Progress ─── */
.progress-text {
  font-size: 0.85em; color: var(--color-muted);
  margin-top: 4px; text-align: center;
  visibility: hidden;
}

/* ─── Graph Page ─── */
.graph-page { width: 100%; height: 100%; position: fixed; top: 0; left: 0; }
.graph-page .dashflow-container {
  width: 100%; height: 100%;
}

/* ─── Main Layout ─── */
.app-container {
  display: flex; flex-direction: column; min-height: 100vh;
}
.app-header {
  padding: 8px 16px; background: white;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 12px;
}
.app-header h1 { font-size: 1.1em; font-weight: 700; }
.app-header .auth-bar { margin-left: auto; }
.app-body {
  flex: 1; padding: 16px;
}
.open-modal-btn {
  position: fixed; bottom: 24px; right: 24px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--color-primary); color: white;
  border: none; font-size: 1.4em; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 100;
}
.open-modal-btn:hover { transform: scale(1.05); }

/* ─── Empty State ─── */
.empty-state {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px; min-height: 400px;
  color: var(--color-muted); font-size: 1.1em;
}
.empty-state .icon { font-size: 3em; opacity: 0.3; }