/* ===== CSS VARIABLES ===== */
:root {
  --bg-primary: #fef5ed;
  --bg-secondary: #fff8f2;
  --bg-white: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-dark: #2c2420;

  --accent: #e8915a;
  --accent-hover: #d47a45;
  --accent-light: #f5c9a8;
  --accent-subtle: #fde8d4;

  --text-primary: #2c2420;
  --text-secondary: #7a6e66;
  --text-muted: #b0a49c;
  --text-white: #ffffff;

  --border: #e8ddd4;
  --border-light: #f0e8e0;

  --shadow-sm: 0 1px 3px rgba(44, 36, 32, 0.06);
  --shadow-md: 0 4px 16px rgba(44, 36, 32, 0.08);
  --shadow-lg: 0 12px 40px rgba(44, 36, 32, 0.12);
  --shadow-glow: 0 0 24px rgba(232, 145, 90, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;

  --topbar-h: 60px;
  --sidebar-w: 260px;
  --panel-w: 380px;

  /* Relationship colors */
  --rel-parent: #e8915a;
  --rel-grandparent: #c06040;
  --rel-child: #5a9ee8;
  --rel-spouse: #e85a8a;
  --rel-sibling: #7c5ae8;
  --rel-cousin: #5ae8b0;
  --rel-friend: #aab4be;
  --rel-uncle: #c4a35a;
  --rel-default: #bbb;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== SCREENS ===== */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ===== AUTH SCREEN ===== */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(ellipse at 20% 50%, rgba(232, 145, 90, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(90, 158, 232, 0.05) 0%, transparent 50%);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  text-align: center;
}

.auth-brand { margin-bottom: 2.5rem; }

.tree-icon {
  display: inline-flex;
  width: 72px;
  height: 72px;
  color: var(--accent);
  margin-bottom: 1rem;
  animation: fadeInScale 0.6s ease-out;
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.93rem;
  font-weight: 300;
}

.auth-form {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  animation: slideUp 0.4s ease-out;
}

.form-group {
  text-align: left;
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 145, 90, 0.12);
  background: var(--bg-white);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.auth-links {
  margin-top: 1.2rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.auth-message {
  margin-top: 1rem;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: none;
}
.auth-message.error { display: block; background: #fdeaea; color: #c44; border: 1px solid #f5c6c6; }
.auth-message.success { display: block; background: #eafde8; color: #3a3; border: 1px solid #c6f5c6; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.93rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-white);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-glow); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-white); border-color: var(--accent-light); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}
.btn-icon:hover { background: var(--accent-subtle); color: var(--accent); }
.btn-icon.active { background: var(--accent-subtle); color: var(--accent); }
.btn-icon.danger:hover { background: #fdeaea; color: #c44; }

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 100;
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 200px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.topbar-brand svg { color: var(--accent); }

.topbar-center { flex: 1; max-width: 480px; margin: 0 auto; }

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 1rem;
  transition: var(--transition);
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 145, 90, 0.1);
}
.search-bar i { color: var(--text-muted); font-size: 0.85rem; }
.search-bar input {
  flex: 1;
  border: none;
  background: none;
  padding: 0.55rem 0.7rem;
  outline: none;
  color: var(--text-primary);
}
.search-bar input::placeholder { color: var(--text-muted); }

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
}
.search-dropdown.active { display: block; }

.search-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: var(--transition);
}
.search-item:hover { background: var(--accent-subtle); }

.search-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
}
.search-avatar img { width: 100%; height: 100%; object-fit: cover; }

.search-info { flex: 1; }
.search-info .name { font-weight: 500; font-size: 0.9rem; }
.search-info .meta { font-size: 0.78rem; color: var(--text-muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-switcher {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.user-menu { position: relative; }

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 200;
  overflow: hidden;
}
.dropdown.active { display: block; }

.dropdown-header {
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
}

.dropdown hr {
  border: none;
  border-top: 1px solid var(--border-light);
}

.dropdown a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1rem;
  color: var(--text-primary);
  transition: var(--transition);
}
.dropdown a:hover { background: var(--accent-subtle); color: var(--accent); }

.role-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0 4px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 1.2rem;
  z-index: 50;
  transform: translateX(0);
  transition: transform 0.3s ease;
}
.sidebar.hidden { transform: translateX(-100%); }

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section h3 {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-group {
  margin-bottom: 0.8rem;
}

.filter-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.filter-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.filter-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-top: var(--topbar-h);
  margin-left: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  transition: margin-left 0.3s ease;
  position: relative;
}

.sidebar.hidden ~ .main-content { margin-left: 0; }

.view { display: none; height: 100%; position: relative; }
.view.active { display: block; }

/* ===== GRAPH ===== */
#graph-container {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle at 1px 1px, var(--border-light) 1px, transparent 0);
  background-size: 30px 30px;
  cursor: grab;
  overflow: hidden;
}
#graph-container:active { cursor: grabbing; }

#graph-svg {
  width: 100%;
  height: 100%;
}

.graph-controls {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--bg-white);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

/* ===== GRAPH NODES ===== */
.node-group { cursor: pointer; }
.node-group:hover .node-bubble { filter: brightness(0.97); }

.node-bubble {
  fill: var(--bg-white);
  stroke: var(--border);
  stroke-width: 2;
  transition: all 0.2s;
}

.node-center .node-bubble {
  fill: var(--accent-subtle);
  stroke: var(--accent);
  stroke-width: 3;
}

.node-photo {
  clip-path: circle(50%);
}

.node-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  fill: var(--text-primary);
  text-anchor: middle;
  pointer-events: none;
}

.node-sublabel {
  font-family: var(--font-body);
  font-size: 9px;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
}

.node-avatar-text {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  fill: var(--accent);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.link-line {
  stroke-width: 2;
  fill: none;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.link-line:hover { opacity: 0.8; }

.link-label {
  font-family: var(--font-body);
  font-size: 9px;
  fill: var(--text-muted);
  text-anchor: middle;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-secondary);
}
.empty-state i { font-size: 3rem; color: var(--accent-light); margin-bottom: 1rem; }
.empty-state h2 { font-family: var(--font-display); margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; font-size: 0.9rem; }

/* ===== DETAIL PANEL ===== */
.detail-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  background: var(--bg-white);
  border-left: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.detail-panel.open { transform: translateX(0); }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 1;
}

.panel-actions { display: flex; gap: 0.3rem; }

.panel-body { padding: 1.2rem; }

.person-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.person-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
  border: 3px solid var(--bg-white);
  box-shadow: var(--shadow-md);
}
.person-avatar img { width: 100%; height: 100%; object-fit: cover; }

.person-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.person-dates {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.person-alive-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.4rem;
}
.person-alive-badge.alive { background: #e8f5e8; color: #4a8; }
.person-alive-badge.deceased { background: #f0eae8; color: #9a8580; }

.info-section {
  margin-bottom: 1.2rem;
}

.info-section h4 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-light);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.35rem 0;
  font-size: 0.88rem;
}

.info-label { color: var(--text-secondary); }
.info-value { font-weight: 500; text-align: right; max-width: 60%; }

.relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  margin: 0.2rem;
}
.relation-chip:hover { background: var(--accent-subtle); border-color: var(--accent-light); }

.relation-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 32, 0.4);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-body { padding: 1.5rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* ===== TIMELINE ===== */
.timeline-container {
  padding: 2rem;
  max-width: 700px;
  margin: 0 auto;
  overflow-y: auto;
  height: 100%;
}

.timeline-event {
  display: flex;
  gap: 1.2rem;
  margin-bottom: 0;
  position: relative;
  padding-bottom: 1.5rem;
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-event:last-child::before { display: none; }

.timeline-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: white;
  z-index: 1;
}
.timeline-dot.birth { background: #5ae8b0; }
.timeline-dot.death { background: #9a8580; }
.timeline-dot.marriage { background: var(--rel-spouse); }

.timeline-content {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  padding: 1rem;
  flex: 1;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.timeline-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.timeline-label { font-size: 0.9rem; }
.timeline-place { font-size: 0.8rem; color: var(--text-muted); }

/* ===== LIST VIEW ===== */
.list-container {
  padding: 1.5rem;
  overflow-y: auto;
  height: 100%;
}

.list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.list-table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.8rem 1rem;
  text-align: left;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}

.list-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
}

.list-table tr {
  cursor: pointer;
  transition: var(--transition);
}
.list-table tbody tr:hover { background: var(--accent-subtle); }

.list-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.6rem;
}
.list-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-dark);
  color: var(--text-white);
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 360px;
}
.toast.success { border-left: 4px solid #5ae8b0; }
.toast.error { border-left: 4px solid #e85a5a; }
.toast.info { border-left: 4px solid #5a9ee8; }

/* ===== ADMIN PANEL ===== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 0.6rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.admin-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
}

.admin-table select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
  gap: 0.5rem;
}
.loading i { animation: pulse 1.2s ease-in-out infinite; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.visible { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .detail-panel { width: 100%; }
  .topbar-brand span { display: none; }
}

@media (max-width: 768px) {
  :root { --panel-w: 100%; }
  .topbar-center { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .auth-container { padding: 1.5rem; }
  .modal { width: 95%; max-height: 90vh; }
  .view-switcher { display: none; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .auth-brand h1 { font-size: 1.6rem; }
  .auth-form { padding: 1.2rem; }
}
