:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f4f4f0;
  --border: #e5e5e0;
  --border-strong: #d4d4cf;
  --text: #1a1a1a;
  --text-muted: #6b6b65;
  --text-dim: #999990;
  --accent: #2d5d3d;
  --accent-light: #e8f0ea;
  --accent-text: #1d4128;
  --warn: #b8721c;
  --warn-bg: #fdf3e3;
  --danger: #b13838;
  --danger-bg: #fceaea;
  --info: #355988;
  --info-bg: #e7eef8;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 32px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 6px;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  top: 8px; left: 8px;
  width: 12px; height: 12px;
  background: #c9e6cf;
  border-radius: 2px;
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.brand-sub { font-size: 11px; color: var(--text-muted); margin-top: -2px; }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  transition: all 0.12s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 34px; height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.12s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.icon-refresh::before { content: '↻'; font-size: 18px; }
.icon-edit::before { content: '✎'; }
.icon-trash::before { content: '🗑'; }
.icon-comment::before { content: '💬'; }
.icon-warning::before { content: '⚠'; }
.icon-camera::before { content: '📷'; }
.icon-mic::before { content: '🎙'; }
.icon-video::before { content: '🎬'; }
.icon-check::before { content: '✓'; }

main {
  padding: 24px;
  max-width: 1500px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  padding: 80px;
  color: var(--text-muted);
  font-size: 13px;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.controls-bar .left, .controls-bar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  transition: all 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-text); border-color: var(--accent-text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

input[type="date"], input[type="text"], input[type="time"], select, textarea {
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; }
.stat-value.accent { color: var(--accent); }
.stat-value.warn { color: var(--warn); }

.project-section {
  margin-bottom: 28px;
}
.project-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.project-name { font-size: 15px; font-weight: 600; }
.project-address { font-size: 12px; color: var(--text-muted); }
.project-shifts-count { margin-left: auto; font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.shifts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.shift-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.shift-card:hover { border-color: var(--border-strong); }
.shift-card.complete { border-left: 3px solid var(--accent); }
.shift-card.active { border-left: 3px solid var(--warn); }
.shift-card.incomplete { border-left: 3px solid var(--text-dim); }

.shift-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.shift-emp { display: flex; align-items: center; gap: 10px; }
.shift-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}
.shift-emp-name { font-weight: 600; font-size: 13px; }
.shift-emp-phone { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-success { background: var(--accent-light); color: var(--accent-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

.shift-body { padding: 12px 14px; }

.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  position: relative;
}
.timeline-row .icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}
.timeline-row .time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 38px;
}
.timeline-row .label { color: var(--text); flex: 1; }
.timeline-row .delayed-mark {
  font-size: 11px;
  color: var(--warn);
  margin-left: 4px;
  cursor: help;
}
.timeline-row .row-actions {
  display: none;
  gap: 4px;
}
.timeline-row:hover .row-actions { display: flex; }
.row-actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 4px;
}
.row-actions button:hover { background: var(--surface-2); color: var(--text); }

.intent-START .icon { color: var(--accent); }
.intent-STOP .icon { color: var(--danger); }
.intent-PAUSE_START .icon, .intent-PAUSE_END .icon, .intent-PAUSE_DURATION .icon { color: var(--warn); }
.intent-NOTE .icon { color: var(--info); }

.media-strip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.media-strip-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.media-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.media-thumb {
  width: 56px; height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
  border: 1px solid var(--border);
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-muted);
}
.media-thumb .placeholder.voice { background: var(--info-bg); color: var(--info); }
.media-thumb .placeholder.video { background: var(--accent-light); color: var(--accent-text); }

.shift-foot {
  padding: 10px 14px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}
.foot-left { display: flex; flex-direction: column; }
.foot-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.foot-pause { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.foot-worked {
  font-size: 18px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}
.shift-card.active .foot-worked { color: var(--warn); }
.shift-card.incomplete .foot-worked { color: var(--text-dim); }

.shift-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-title { font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
table.data th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}
table.data td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }

table.week-grid th:first-child { width: 180px; }
table.week-grid td.day-cell { text-align: center; font-family: 'JetBrains Mono', monospace; cursor: pointer; }
table.week-grid td.day-cell:hover { background: var(--accent-light); }
table.week-grid td.day-cell.empty { color: var(--text-dim); }
table.week-grid td.day-cell.active { color: var(--warn); font-weight: 600; }
table.week-grid td.day-cell.complete { color: var(--accent); font-weight: 600; }
table.week-grid td.total-cell { font-weight: 700; font-family: 'JetBrains Mono', monospace; background: var(--surface-2); }

.week-day-header { font-weight: 500; }
.week-day-header .dow { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.week-day-header .day-num { font-size: 13px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 10px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  width: 28px; height: 28px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 18px; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-row textarea { min-height: 80px; resize: vertical; }

.media-viewer img, .media-viewer video {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
  border-radius: 6px;
}
.media-viewer audio { width: 100%; }
.media-meta {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
}
.media-meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.transcript {
  font-style: italic;
  color: var(--text-muted);
  padding: 8px 0;
}

.comment-list { margin-top: 12px; }
.comment {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}
.comment-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }

.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.filter-row label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }

.notes-list { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.note-item {
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 0 3px 12px;
  position: relative;
}
.note-item::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--info);
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 200;
  animation: slideIn 0.2s;
}
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .topbar-left { gap: 16px; }
  .tabs { overflow-x: auto; }
  main { padding: 16px; }
}
