:root {
  --bg: #f6f7f9;
  --fg: #1f2937;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --primary: #0f766e;
  --primary-fg: #ffffff;
  --start: #059669;
  --stop: #dc2626;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --error-bg: #fee2e2;
  --error-fg: #991b1b;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--primary);
  color: #ffffff;
  border-bottom: 1px solid rgba(0,0,0,.08);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 600; color: #ffffff; }
.topbar .brand:hover { text-decoration: none; opacity: .9; }
.topbar .nav > a { color: #ffffff; font-size: .9rem; }
.topbar .nav > a:hover { text-decoration: underline; }
.nav { display: flex; gap: .5rem; align-items: center; }
.nav form { margin: 0; display: inline-flex; }

/* Reset platform defaults so iOS/Android don't override our colors. */
.nav button {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
}
.nav .lang { gap: .25rem; }
.nav .lang button {
  border: 1px solid rgba(255,255,255,.55);
  background: transparent;
  color: #ffffff;
  padding: .3rem .55rem;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.nav .lang button.active {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
}
.nav .logout button {
  background: transparent;
  border: 1px solid rgba(255,255,255,.55);
  color: #ffffff;
  padding: .35rem .75rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
}
.nav .logout button:hover,
.nav .lang button:hover {
  background: rgba(255,255,255,.15);
}

.container { max-width: 880px; margin: 0 auto; padding: 1rem; }

.footer { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin: 0 0 1rem 0;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }

.auth-card { max-width: 380px; margin: 3rem auto; }
.auth-card h1 { margin-top: 0; }

label { display: block; margin-bottom: .9rem; }
label span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
input[type=email], input[type=password], input[type=text], input[type=number],
input[type=datetime-local], select {
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}

.btn {
  display: inline-block; cursor: pointer;
  padding: .65rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff; color: var(--fg);
  font-size: 1rem;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn-primary:hover { filter: brightness(0.95); }
.btn-danger  { background: var(--stop); color: #fff; border-color: var(--stop); }
.btn.block, button.block { width: 100%; }

.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.alert-error   { background: var(--error-bg); color: var(--error-fg); }
.alert-warn    { background: var(--warn-bg);  color: var(--warn-fg); }
.alert-success { background: #d1fae5; color: #065f46; }

.muted { color: var(--muted); font-size: .85rem; }

/* Clock */
.clock { padding-top: .5rem; }
.clock .hi { color: var(--muted); margin: 0 0 .5rem; }
.clock .status { font-size: 1.1rem; margin: .25rem 0 1.25rem; }

.btn-huge {
  width: 100%;
  height: 60vw; max-height: 320px; min-height: 200px;
  border-radius: 28px;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 600;
  color: #fff;
  border: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
}
.btn-start { background: var(--start); }
.btn-stop  { background: var(--stop); }
.btn-huge:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* Clock buttons container — column, items stretch to equal width. */
.clock-buttons {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  align-items: stretch;
}
.clock-buttons .btn { box-sizing: border-box; }

/* Shared secondary clock button (lunch + pickup). Same size as each other,
   same FULL width as the big work button. */
.btn-secondary {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: .95rem 1rem;
  border-radius: 14px;
  color: #ffffff;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  text-align: center;
}
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-lunch  { background: #fb923c; box-shadow: 0 3px 12px rgba(251,146,60,.20); }   /* light orange */
.btn-lunch.is-active  { background: #c2410c; }
.btn-pickup { background: #3b82f6; box-shadow: 0 3px 12px rgba(59,130,246,.20); }   /* blue */
.btn-pickup.is-active { background: #1d4ed8; }

/* Task picker on the clock screen. Soft amber tint so it's visible but
   doesn't compete with the primary work button. */
.task-picker {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: .7rem .85rem;
  margin-bottom: .25rem;
}
.task-picker label { margin: 0; }
.task-picker > label > span {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: .35rem;
  color: #78350f;
  font-weight: 600;
  font-size: .9rem;
}
.task-picker > label > span em { font-style: normal; font-weight: 400; font-size: .8rem; color: var(--muted); }
.task-picker select { background: #ffffff; }

/* Task name shown on a work segment in the admin time view */
.seg-task {
  background: #ecfeff;
  color: #155e75;
  border: 1px solid #a5f3fc;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Task name shown in the clock-screen status line */
.task-badge {
  display: inline-block;
  background: #ecfeff;
  color: #155e75;
  border: 1px solid #a5f3fc;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 500;
  margin-top: .2rem;
}

.today dl { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; margin: .25rem 0; }
.today dt { color: var(--muted); font-size: .85rem; }
.today dd { margin: 0 0 .25rem; font-size: 1.4rem; font-variant-numeric: tabular-nums; }

.entry-list { list-style: none; padding: 0; margin: 0; }
.entry-list li { display: flex; gap: .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.entry-list li:last-child { border-bottom: 0; }
.entry-list .ts { font-variant-numeric: tabular-nums; min-width: 3.5rem; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; }
.tag-start { background: #d1fae5; color: #065f46; }
.tag-stop  { background: #fee2e2; color: #991b1b; }
.tag-lunch_start  { background: #ffedd5; color: #9a3412; }
.tag-lunch_end    { background: #ffedd5; color: #9a3412; }
.tag-pickup_start { background: #dbeafe; color: #1e40af; }
.tag-pickup_end   { background: #dbeafe; color: #1e40af; }

/* Admin */
.admin-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .admin-grid { grid-template-columns: repeat(3, 1fr); } }
.tile { display: block; padding: 1.25rem; background: var(--card); border: 1px solid var(--border); border-radius: 12px; color: var(--fg); }
.tile h3 { margin: 0 0 .5rem 0; }

.report-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.report-table { min-width: 640px; }
/* I alt — payable grand total. Subtle accent, not dominating. */
.report-table .col-total { background: #f3f4f6; }
.report-table thead .col-total { background: #e5e7eb; }
/* Lunch — informational only. Muted text + very light tint. */
.report-table .col-lunch { background: #fafaf9; color: var(--muted); font-style: italic; }
.report-table thead .col-lunch { background: #f5f5f4; color: var(--muted); font-weight: 500; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
table.data th, table.data td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
table.data th { background: #f3f4f6; font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { margin-bottom: 0; }
.filters select, .filters input { min-width: 9rem; }

.day-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; margin-bottom: .9rem; }
.day-card header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.day-card h3 { margin: 0; font-size: 1rem; }
.day-card .totals { color: var(--muted); font-size: .9rem; }
.blocks { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 600px) { .blocks { grid-template-columns: 1fr; } }
.block-list { list-style: none; padding: 0; margin: 0; }
.block-list li { display: flex; justify-content: space-between; padding: .25rem 0; font-variant-numeric: tabular-nums; }
.block-list .lbl { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.section-work .lbl { color: #047857; }
.section-drive .lbl { color: #b45309; }

.actions-cell { white-space: nowrap; }
.actions-cell .btn { padding: .3rem .55rem; font-size: .85rem; }

.alert-open { background: #fef3c7; color: #92400e; padding: .3rem .65rem; border-radius: 999px; font-size: .75rem; }

/* Single chronological segment list (work + drive interleaved) */
.segments { list-style: none; padding: 0; margin: .25rem 0 0; }
.segment {
  display: flex;
  gap: .75rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  margin-bottom: .35rem;
  align-items: flex-start;
  border-left: 3px solid transparent;
}
.segment-work  { background: #ecfdf5; border-left-color: #059669; }
.segment-drive { background: #fffbeb; border-left-color: #d97706; }
.segment-lunch  { background: #ffedd5; border-left-color: #fb923c; }
.segment-pickup { background: #dbeafe; border-left-color: #3b82f6; }
.segment:last-child { margin-bottom: 0; }
.seg-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.seg-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-variant-numeric: tabular-nums; }
.seg-kind {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  padding: .12rem .5rem;
  border-radius: 999px;
}
.seg-kind-work  { background: #059669; color: #ffffff; }
.seg-kind-drive { background: #d97706; color: #ffffff; }
.seg-kind-lunch  { background: #fb923c; color: #ffffff; }
.seg-kind-pickup { background: #3b82f6; color: #ffffff; }
.seg-times strong { letter-spacing: .02em; }
.seg-dur { font-weight: 600; }
.seg-actions { font-size: .8rem; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.seg-actions a { color: var(--muted); }
.seg-delete-form { margin: 0; display: inline; }
.seg-delete-btn {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: .75rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  cursor: pointer;
  margin-left: auto;
}
.seg-delete-btn:hover { background: #fee2e2; }

/* Legacy aliases retained in case other places reference them */
.work-list { list-style: none; padding: 0; margin: 0; }
.work-item {
  display: flex;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.work-item:last-child { border-bottom: 0; }
.map-thumb-link {
  flex: 0 0 140px;
  display: block;
  width: 140px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
  position: relative;
  cursor: pointer;
}
.map-thumb {
  width: 100%;
  height: 100%;
  position: relative;
  pointer-events: none;   /* let the anchor catch clicks */
  background: #e5e7eb;
}
.map-thumb .leaflet-control-container { display: none; }
.map-thumb .leaflet-tile-pane img { pointer-events: none; }
.map-thumb.no-geo {
  flex: 0 0 140px;
  width: 140px;
  height: 100px;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 12px);
}
.work-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.work-times { font-variant-numeric: tabular-nums; }
.work-times strong { letter-spacing: .02em; }
.addr { font-size: .85rem; min-height: 1.1em; overflow: hidden; text-overflow: ellipsis; }
.addr-list { display: flex; flex-direction: column; gap: .15rem; }
.addr-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  align-items: baseline;
  gap: .5rem;
}
.addr-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  padding: .05rem .35rem;
  border-radius: 999px;
  text-align: center;
}
.addr-label-start { background: #d1fae5; color: #065f46; }
.addr-label-stop  { background: #fee2e2; color: #991b1b; }

/* Anomaly rows */
.anomalies {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: .5rem .65rem;
  margin: .25rem 0 .75rem;
}
.anomalies-head { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: baseline; margin-bottom: .25rem; }
.lbl-anom { color: #92400e; font-weight: 600; font-size: .8rem; }
.anomaly-list { list-style: none; padding: 0; margin: 0; }
.anomaly-list li {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: .3rem 0; border-top: 1px dashed #fde68a;
}
.anomaly-list li:first-child { border-top: 0; }
.anomaly-list .ts { font-variant-numeric: tabular-nums; }
.anomaly-actions { margin-left: auto; display: flex; gap: .35rem; }
.btn-sm { padding: .2rem .55rem; font-size: .8rem; }
.work-actions { font-size: .8rem; }
.work-actions a { margin-right: .6rem; }
