:root {
  --bg: #0e0e10;
  --bg-card: #1a1a1f;
  --bg-input: #25252b;
  --text: #e8e8ec;
  --text-muted: #8a8a96;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --green: #2ecc71;
  --amber: #f39c12;
  --red: #e74c3c;
  --red-hard: #c0392b;
  --border: #2a2a32;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: 2rem;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.25rem 1rem 0.5rem;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.brand {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

nav {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

nav::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.view {
  padding: 1rem;
  max-width: 640px;
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.header-actions {
  display: flex;
  gap: 0.4rem;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Timer Bar */
.timer-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  max-width: 640px;
  margin: 0 auto;
}

.timer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.timer-display {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.timer-selects {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  max-width: 220px;
}

.timer-period-select,
.timer-job-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  min-height: 40px;
  min-width: 0;
  width: 100%;
}

.timer-period-select:focus,
.timer-job-select:focus {
  outline: none;
  border-color: var(--accent);
}

.timer-job-select:disabled {
  opacity: 0.4;
  cursor: default;
}

.timer-controls {
  display: flex;
  gap: 0.4rem;
}

.btn-timer {
  flex: 1;
  padding: 0.5rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s, opacity 0.2s;
}

.btn-timer:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-timer:not(:disabled):active {
  background: var(--border);
}

.btn-play:not(:disabled) {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn-stop:not(:disabled) {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Cards */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.client-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.client-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease, background 0.3s ease;
  min-width: 2px;
}

.progress-stats {
  margin-bottom: 0.75rem;
}

.hours-readout {
  font-size: 0.95rem;
  font-weight: 600;
}

.card-details {
  margin-bottom: 0.75rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.2rem 0;
}

.detail-row span:last-child {
  color: var(--text);
  font-weight: 500;
}

/* Buttons */
.btn {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  touch-action: manipulation;
  min-height: 44px;
}

.btn:active {
  background: var(--border);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:active {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
}

.btn-sm {
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  min-height: 40px;
  flex: 1;
}

.card-btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-xs {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  min-height: 36px;
}

.btn-danger {
  color: var(--red);
  border-color: var(--red);
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-stack input,
.form-stack select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  min-height: 48px;
  width: 100%;
}

.form-stack input:focus,
.form-stack select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row label {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

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

/* Filters */
.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filters select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  flex: 1;
  min-height: 44px;
}

/* Entries */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.entry-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.entry-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.entry-client {
  font-weight: 600;
  font-size: 0.9rem;
}

.entry-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.entry-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.entry-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Clients list */
.client-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.5rem;
  gap: 0.75rem;
}

.client-row.inactive {
  opacity: 0.5;
}

.client-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.client-info strong {
  font-size: 0.95rem;
}

.client-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.client-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Data actions */
.data-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

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

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

#client-form-container {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

#client-form-container h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* History */
.history-group {
  margin-bottom: 1.5rem;
}

.history-group-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.history-card {
  margin-bottom: 0.75rem;
  opacity: 0.85;
}

/* Clickable cards */
.client-card.clickable {
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

@media (hover: hover) {
  .client-card.clickable:hover {
    border-color: var(--text-muted);
    background: #1f1f25;
  }
}

/* Period detail */
.detail-back {
  margin-bottom: 0.75rem;
}

.detail-header h2 {
  margin-bottom: 0.75rem;
}

.detail-stats {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.detail-entries-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.detail-entries-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.detail-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
}

/* Jobs */
.jobs-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.jobs-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.job-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}

.job-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-hours {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.job-unassigned .job-name {
  font-style: italic;
  color: var(--text-muted);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-icon:active {
  color: var(--red);
  background: rgba(231, 76, 60, 0.15);
}

.jobs-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  padding: 0.25rem 0;
}

.form-context {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

@media (min-width: 480px) {
  .cards-grid {
    gap: 1.25rem;
  }

  .client-card {
    padding: 1.5rem;
  }

  .progress-bar-track {
    height: 14px;
  }
}
