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

:root {
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --nav-h: 64px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--blue);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
}

.view {
  display: none;
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 16px);
  overflow-y: auto;
}

.view.active { display: block; }

/* Bottom Nav */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 100;
}

#bottom-nav button {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 4px;
  transition: color 0.15s;
}

#bottom-nav button.active { color: var(--blue); }

/* Cards */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

/* Clock View */
.clock-status {
  text-align: center;
  padding: 48px 16px 32px;
}

.clock-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.clock-badge.in  { background: #dcfce7; color: #16a34a; }
.clock-badge.out { background: #fee2e2; color: #dc2626; }

.clock-timer {
  font-size: 58px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 10px;
}

.clock-project-name {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 6px;
}

.clock-earnings {
  font-size: 26px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 36px;
}

/* Form controls */
.select-wrapper { position: relative; margin-bottom: 16px; }

select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
  appearance: none;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-danger  { background: var(--red);  color: white; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }

.btn-sm {
  display: inline-block;
  width: auto;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 6px;
}

/* Project list */
.project-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.project-info  { flex: 1; min-width: 0; }
.project-name  { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-rate  { font-size: 13px; color: var(--muted); }
.project-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title { font-size: 16px; font-weight: 700; }

/* Form */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
}

input[type="color"] {
  width: 100%;
  padding: 4px 8px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}

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

/* Log */
.entry-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.entry-left         { flex: 1; min-width: 0; }
.entry-project      { font-weight: 600; font-size: 14px; }
.entry-date         { font-size: 12px; color: var(--muted); margin-top: 2px; }
.entry-time-range   { font-size: 12px; color: var(--muted); }
.entry-right        { text-align: right; flex-shrink: 0; }
.entry-duration     { font-weight: 700; }
.entry-earnings     { font-size: 13px; color: var(--green); margin-top: 2px; }
.entry-actions      { display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end; }

input[type="datetime-local"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: var(--card);
}

/* Summary */
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-of-type { border-bottom: none; }

.summary-total {
  display: flex;
  justify-content: space-between;
  padding: 12px 0 0;
  font-weight: 700;
  font-size: 18px;
  border-top: 2px solid var(--text);
  margin-top: 4px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  z-index: 200;
}

.modal {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn { flex: 1; }

/* Empty state */
.empty {
  text-align: center;
  padding: 56px 16px;
  color: var(--muted);
}

.empty svg { margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 15px; }

.input-error { border-color: var(--red) !important; }

/* Data actions */
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Week navigation */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.week-nav-label { font-size: 14px; font-weight: 600; color: var(--text); }

/* Weekly / By Day Summary */
.wsum-card { padding: 16px; }
.wsum-pre { font-family: 'SF Mono', 'Roboto Mono', ui-monospace, monospace; font-size: 13px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.wsum-copy { margin-top: 10px; }
.wsum-copied { text-align: center; font-size: 13px; font-weight: 600; color: var(--green); height: 20px; margin-top: 6px; opacity: 0; transition: opacity 0.2s; }
.wsum-copied.visible { opacity: 1; }
