*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f8f9fa; --surface: #fff; --border: #dee2e6; --text: #212529; --muted: #6c757d;
  --primary: #0d6efd; --danger: #dc3545; --success: #198754; --warning: #ffc107;
  --radius: 6px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.navbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.navbar h1 { font-size: 18px; font-weight: 600; }
.navbar .spacer { flex: 1; }
.container { max-width: 1600px; margin: 0 auto; padding: 16px 20px; }

/* Stats bar */
.stats-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; min-width: 120px; text-align: center; cursor: pointer; transition: border-color .15s; }
.stat-card:hover, .stat-card.active { border-color: var(--primary); }
.stat-card .count { font-size: 24px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Filter bar */
.filter-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { font-size: 13px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); }
.filter-bar input[type="text"] { min-width: 200px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; font-size: 13px; font-weight: 500; border: 1px solid transparent; border-radius: 4px; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #0b5ed7; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5c636a; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bb2d3b; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-icon { padding: 4px 6px; }

/* Table */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none; }
th:hover { color: var(--text); }
th.sorted-asc::after { content: ' \u25B2'; font-size: 10px; }
th.sorted-desc::after { content: ' \u25BC'; font-size: 10px; }
td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:hover { background: #f8f9fe; }
tr.clickable { cursor: pointer; }

/* Color dot */
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; cursor: pointer; vertical-align: middle; }
.color-dot.empty { border: 2px dashed var(--border); }

/* Badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; cursor: pointer; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 8px; padding: 12px; justify-content: space-between; flex-wrap: wrap; }
.pagination .info { font-size: 13px; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button { padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; font-size: 13px; }
.pagination .pages button:hover { background: var(--bg); }
.pagination .pages button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.2); width: 90%; max-width: 700px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.modal .close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 10px; font-size: 14px; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,253,.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Detail page */
.detail-header { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.detail-header h2 { font-size: 20px; margin-bottom: 8px; }
.detail-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.detail-meta span { display: flex; align-items: center; gap: 4px; }
.detail-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.detail-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.editable { border: 1px solid transparent; border-radius: 4px; padding: 8px; min-height: 40px; transition: border-color .15s; }
.editable:hover { border-color: var(--border); }
.editable:focus { outline: none; border-color: var(--primary); background: #fff; }

/* Timeline */
.timeline { list-style: none; }
.timeline-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.timeline-item:last-child { border-bottom: none; }
.timeline-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; flex-shrink: 0; }
.timeline-body { flex: 1; }
.timeline-body .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.timeline-body .content { font-size: 14px; white-space: pre-wrap; }
.timeline-actions { display: flex; gap: 4px; margin-top: 6px; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 20px; border-radius: var(--radius); color: #fff; font-size: 14px; z-index: 2000; transform: translateY(100px); opacity: 0; transition: .3s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* Color picker dropdown */
.color-picker { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; display: flex; gap: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index: 50; }
.color-picker .swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-picker .swatch:hover { border-color: var(--text); }
.color-picker .swatch.clear { border: 2px dashed var(--border); background: #fff; position: relative; }
.color-picker .swatch.clear::after { content: '\00d7'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }

/* Inline select */
.inline-select { font-size: 12px; padding: 2px 4px; border: 1px solid transparent; border-radius: 4px; background: none; cursor: pointer; }
.inline-select:hover { border-color: var(--border); }

/* Import preview */
.import-preview { max-height: 300px; overflow: auto; margin: 12px 0; }
.import-preview table { font-size: 12px; }

/* Quick entry */
.quick-entry-list { max-height: 200px; overflow-y: auto; margin-bottom: 12px; }
.quick-entry-item { padding: 8px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.quick-entry-item .meta { font-size: 11px; color: var(--muted); }

/* Responsive */
@media (max-width: 768px) {
  .stats-bar { gap: 6px; }
  .stat-card { min-width: 80px; padding: 8px; }
  .stat-card .count { font-size: 18px; }
  .filter-bar { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .container { padding: 10px; }
}
