:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-light: #888;
  --text-muted: #555;
  --accent: #4f8ef7;
  --accent-hover: #6ba3ff;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
}

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

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

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header h1 { font-size: 18px; font-weight: 600; }
.settings-trigger { color: var(--text-light); }
.settings-trigger:hover { color: var(--text); }

/* ===== Buttons ===== */
button { cursor: pointer; border: none; outline: none; font-family: inherit; font-size: 14px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.btn-large { padding: 12px 28px; font-size: 15px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text-light);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text); border-color: #555; }

.icon-btn {
  background: transparent;
  color: var(--text-light);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}
.icon-btn:hover { color: var(--text); }

.link-btn {
  background: none;
  color: var(--accent);
  font-size: 13px;
  padding: 4px 0;
  margin-top: 6px;
  display: inline-block;
}
.link-btn:hover { color: var(--accent-hover); }

/* ===== Main ===== */
.main { max-width: 960px; margin: 0 auto; padding: 32px 24px; }

/* ===== Upload ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.04);
}
.upload-area #file-input { display: none; }
.upload-icon { color: var(--text-muted); margin-bottom: 12px; }
.upload-title { font-size: 16px; font-weight: 500; margin-bottom: 6px; }
.upload-hint { color: var(--text-light); font-size: 13px; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.preview-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.preview-item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}
.preview-label {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.remove-preview {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}
.remove-preview:hover { background: var(--danger); }

.preview-pair {
  margin-top: 20px;
}
.pair-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pair-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 320px;
}
.preview-missing {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
}
.missing-label {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-actions { margin-top: 24px; text-align: center; }

/* ===== Loading ===== */
.loading-state {
  text-align: center;
  padding: 80px 24px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--text-light); }

/* ===== Results ===== */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.results-toolbar h2 { font-size: 18px; font-weight: 600; }
.toolbar-actions { display: flex; gap: 10px; }

.employee-table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.employee-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.employee-header h3 { font-size: 16px; font-weight: 600; }
.name-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  padding: 2px 6px;
  border-radius: 4px;
  width: 120px;
  transition: border-color 0.15s, background 0.15s;
}
.name-input:hover { border-color: var(--border); }
.name-input:focus { border-color: var(--accent); background: var(--surface-2); outline: none; }

.period-badge {
  font-size: 12px;
  background: rgba(79, 142, 247, 0.15);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
}
.total-hours {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-light);
}
.total-hours strong { color: var(--success); font-size: 16px; }

/* Employee name match warning */
.name-warning {
  font-size: 12px;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 4px;
}
.employee-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 12px;
}

.table-wrapper { overflow-x: auto; }

.attendance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.attendance-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.attendance-table td {
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.attendance-table tbody tr:last-child td { border-bottom: none; }
.attendance-table tbody tr:hover { background: var(--surface-2); }
.attendance-table tbody tr.row-missing td { background: rgba(248, 113, 113, 0.05); }

.time-field {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.time-colon {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  user-select: none;
}
.time-seg {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  padding: 3px 4px;
  border-radius: 4px;
  width: 30px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.time-seg:hover { border-color: var(--border); }
.time-seg:focus { border-color: var(--accent); background: var(--surface-2); outline: none; }

.note-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 3px 6px;
  border-radius: 4px;
  width: 120px;
  transition: border-color 0.15s, background 0.15s;
}
.note-input:hover { border-color: var(--border); }
.note-input:focus { border-color: var(--accent); background: var(--surface-2); outline: none; }

.hours-cell { font-weight: 500; }
.hours-cell.has-value { color: var(--success); }
.hours-cell.missing { color: var(--danger); font-size: 12px; }

/* ===== Settings Panel ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.overlay.open { display: flex; }

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 16px; font-weight: 600; }
.panel-body { padding: 20px; overflow-y: auto; flex: 1; }
.panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.setting-group { margin-bottom: 20px; }
.setting-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.setting-group input[type="text"],
.setting-group input[type="password"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
}
.setting-group input:focus {
  border-color: var(--accent);
  outline: none;
}

.employee-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.employee-row input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
.employee-row input:focus { border-color: var(--accent); outline: none; }
.remove-emp {
  background: transparent;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
}
.remove-emp:hover { color: var(--danger); }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.25s ease;
  max-width: 300px;
}
.toast-info    { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.toast-success { background: rgba(52, 211, 153, 0.15); border: 1px solid rgba(52, 211, 153, 0.3); color: var(--success); }
.toast-error   { background: rgba(248, 113, 113, 0.15); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
