/* ── CSS Custom Properties (Light theme) ── */
:root {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-sidebar: #1e2a3a;
  --bg-sidebar-hover: #2a3a50;
  --bg-sidebar-active: #3b82f6;
  --text-primary: #1a202c;
  --text-secondary: #6b7280;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;
  --border: #e5e7eb;
  --border-focus: #3b82f6;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --card-shadow: 0 1px 3px rgba(0,0,0,.1);
  --radius: 6px;
}

[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-sidebar: #111827;
  --bg-sidebar-hover: #1f2937;
  --bg-sidebar-active: #3b82f6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #2d3748;
  --card-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.app-shell { display: flex; flex: 1; overflow: hidden; }
.sidebar { width: 240px; min-width: 240px; background: var(--bg-sidebar); display: flex; flex-direction: column; overflow-y: auto; }
.main-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.main-content { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* ── Topbar ── */
.topbar { background: var(--bg-secondary); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; align-items: center; gap: 1rem; }
.topbar-brand { font-weight: 700; font-size: 1.1rem; color: var(--accent); white-space: nowrap; }
.topbar-search { flex: 1; max-width: 400px; }
.topbar-search input { width: 100%; padding: .4rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text-primary); font-size: .875rem; }
.topbar-search input:focus { outline: none; border-color: var(--border-focus); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

/* ── Sidebar tree ── */
.sidebar-section { padding: .5rem 0; }
.sidebar-label { font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-sidebar); opacity: .5; padding: .5rem 1rem; }
.sidebar-item { display: flex; align-items: center; gap: .5rem; padding: .45rem 1rem; font-size: .875rem; color: var(--text-sidebar); cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.sidebar-item:hover { background: var(--bg-sidebar-hover); }
.sidebar-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); font-weight: 600; }
.sidebar-item .icon { width: 1rem; text-align: center; flex-shrink: 0; }
.sidebar-sub { padding-left: 1.5rem; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: .25rem; font-size: .875rem; color: var(--text-secondary); margin-bottom: 1rem; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--text-primary); text-decoration: none; }
.breadcrumb-sep { color: var(--border); }

/* ── Cards & Grid ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--card-shadow); cursor: pointer; transition: border-color .15s; position: relative; }
.card:hover { border-color: var(--accent); }
.card-icon { font-size: 2rem; margin-bottom: .5rem; }
.card-name { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; word-break: break-word; }
.card-meta { font-size: .75rem; color: var(--text-secondary); }

/* ── Status badges ── */
.badge-row { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.badge { font-size: .65rem; padding: .15rem .4rem; border-radius: 3px; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-missing { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
[data-theme="dark"] .badge-ok { background: #14532d; color: #86efac; }
[data-theme="dark"] .badge-missing { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-info { background: #1e3a5f; color: #93c5fd; }

/* ── File list (dataset contents) ── */
.file-list { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-item { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; }
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg-primary); }
.file-icon { font-size: 1.25rem; flex-shrink: 0; width: 1.5rem; text-align: center; }
.file-name { flex: 1; font-weight: 500; }
.file-meta { font-size: .75rem; color: var(--text-secondary); }
.file-actions { display: flex; gap: .5rem; }

/* ── Forms ── */
.form-input, .form-select, .form-textarea { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-secondary); color: var(--text-primary); font-size: .875rem; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--border-focus); }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-secondary); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; cursor: pointer; border: none; transition: background .15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-icon { padding: .35rem .5rem; background: none; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; color: var(--text-secondary); }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ── Star button ── */
.star-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-secondary); padding: 0; }
.star-btn.starred { color: #f59e0b; }

/* ── Activity feed ── */
.activity-item { display: flex; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .8rem; }
.activity-item:last-child { border-bottom: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 700; flex-shrink: 0; }
.activity-text { flex: 1; line-height: 1.4; }
.activity-time { color: var(--text-secondary); white-space: nowrap; }

/* ── Checklist ── */
.checklist { display: flex; gap: 1rem; flex-wrap: wrap; padding: .75rem; background: var(--bg-primary); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1rem; }
.check-item { display: flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 500; }
.check-ok { color: var(--success); }
.check-missing { color: var(--danger); }

/* ── Dark mode toggle ── */
.dark-toggle { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .3rem .5rem; cursor: pointer; color: var(--text-primary); display: inline-flex; align-items: center; line-height: 1; }
.dark-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }

/* ── Section heading ── */
.section-heading { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; color: var(--text-primary); }

/* ── Profile point table ── */
.point-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.point-table th { text-align: left; padding: .4rem .6rem; font-size: .75rem; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border); }
.point-table td { padding: .35rem .6rem; border-bottom: 1px solid var(--border); }
.point-table tr:hover td { background: var(--bg-primary); }
.drag-handle { cursor: grab; color: var(--text-secondary); }

/* ── Photo gallery ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.photo-thumb { aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer; width: 100%; }

/* ── Lightbox ── */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }

/* ── Map ── */
.map-container { height: 260px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }

/* ── Chart container ── */
.chart-container { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }

/* ── Messages ── */
.messages { list-style: none; margin-bottom: 1rem; }
.messages li { padding: .6rem 1rem; border-radius: var(--radius); margin-bottom: .4rem; font-size: .875rem; }
.messages .success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.messages .error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
[data-theme="dark"] .messages .success { background: #14532d; color: #86efac; border-color: #166534; }
[data-theme="dark"] .messages .error { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 500; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; min-width: 320px; max-width: 480px; width: 90%; }
.modal-title { font-weight: 700; margin-bottom: 1rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .card-grid { grid-template-columns: 1fr 1fr; }
}
