:root {
  --pink: #e31957;
  --pink-dark: #c4124a;
  --aqua: #67cac5;
  --orange: #f2611e;
  --yellow: #fdd800;
  --teal: #1e9096;
  --teal-dark: #16767b;
  --light-teal: #c8ebe9;
  --bg: #fafafa;
  --card: #ffffff;
  --bord: #e4e4e4;
  --text: #333333;
  --muted: #777777;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 'Muli', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { font-family: 'McLaren', 'Muli', system-ui, sans-serif; font-weight: 400; margin: 0; }
a { color: var(--pink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* Header */
header.app {
  background: var(--yellow);
  padding: 0 max(16px, env(safe-area-inset-left));
  min-height: 60px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--pink); color: #fff;
  display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
header.app h1 { font-size: 19px; white-space: nowrap; }
header.app nav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
header.app nav a, header.app nav button {
  color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; font-size: 14px;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
header.app nav a:hover, header.app nav button:hover { background: rgba(0,0,0,.07); }
header.app .who { font-size: 14px; color: #5b5100; }

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }
main.narrow { max-width: 560px; }

.card {
  background: var(--card); border: 1px solid var(--bord); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { font-size: 18px; }

/* Buttons & inputs */
.btn {
  font: inherit; font-weight: 700; border-radius: 10px; border: 1px solid transparent;
  padding: 9px 16px; cursor: pointer; background: #eee; color: var(--text); white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn.pink { background: var(--pink); color: #fff; }
.btn.pink:hover:not(:disabled) { background: var(--pink-dark); }
.btn.ghost { background: transparent; border-color: var(--bord); }
.btn.ghost:hover { background: #f3f3f3; }
.btn.danger-outline { background: transparent; color: var(--pink); border-color: #f3b3c6; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button.link { background: none; border: 0; color: var(--teal); font: inherit; font-weight: 700; cursor: pointer; padding: 4px; }

label { display: block; font-size: 13px; font-weight: 700; color: #555; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], input[type=date], select {
  display: block; width: 100%; margin-top: 5px; font: inherit; font-weight: 400; color: var(--text);
  border: 1px solid #d6d6d6; border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--aqua); outline-offset: 0; border-color: var(--aqua); }
.form-error { color: var(--pink); font-weight: 700; margin: 4px 0 10px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }

/* Clock */
.clock { text-align: center; padding: 28px 20px; }
.status { font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.status.on { color: var(--teal); }
.status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #bbb; margin-right: 6px; vertical-align: 1px; }
.status.on .dot { background: var(--teal); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.timer { font-size: clamp(46px, 14vw, 72px); font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.since { color: var(--muted); min-height: 1.4em; }
.clock input[type=text] { max-width: 420px; margin: 18px auto 0; text-align: center; }
.clock-btn {
  display: block; width: 100%; max-width: 420px; margin: 14px auto 0; padding: 20px; font-size: 22px;
  border-radius: 16px; font-family: 'McLaren', 'Muli', sans-serif; font-weight: 400;
  box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.clock-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.12); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--bord); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.stat .s { font-size: 12px; color: var(--muted); }
@media (max-width: 480px) {
  .stats { gap: 8px; }
  .stat { padding: 10px 6px; }
  .stat .v { font-size: 19px; }
  .stat .l { font-size: 11px; }
}

.tz-banner { background: #fff7d1; border: 1px solid #f3e08a; border-radius: var(--radius); padding: 12px 14px; margin: 0 0 18px; font-size: 14px; }
.tz-banner button.link, button.link.small { font-size: inherit; padding: 0; }

/* Period navigator */
.period-nav { display: flex; align-items: center; gap: 6px; }
.period-nav .label { font-weight: 700; min-width: 150px; text-align: center; }
.period-nav button { width: 36px; height: 36px; padding: 0; }

/* Entries */
.day { border-top: 1px solid var(--bord); padding: 10px 0 4px; }
.day:first-child { border-top: 0; padding-top: 0; }
.day-head { display: flex; justify-content: space-between; font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.entry { display: grid; grid-template-columns: 150px 1fr 56px 44px; gap: 8px; align-items: center; padding: 6px 0; font-size: 14px; }
.entry-times { white-space: nowrap; }
.entry-dur { text-align: right; font-weight: 700; }
.entry-actions { text-align: right; }
@media (max-width: 560px) {
  .entry { grid-template-columns: 1fr auto auto; grid-template-areas: "times dur act" "desc desc desc"; row-gap: 0; }
  .entry-times { grid-area: times; } .entry-dur { grid-area: dur; } .entry-actions { grid-area: act; }
  .entry-desc { grid-area: desc; font-size: 13px; }
}
.live { color: var(--teal); font-weight: 800; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; border-radius: 6px; padding: 1px 6px; vertical-align: 1px; margin-left: 4px; }
.badge.edited { background: #fff1d6; color: #9a5b00; }
.badge.edited[data-history] { cursor: pointer; text-decoration: underline dotted; }
.badge.on { background: var(--light-teal); color: var(--teal-dark); }
.badge.warn { background: #fde0e8; color: var(--pink-dark); }
.badge.grey { background: #eee; color: #666; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--bord); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 800; border-bottom: 0; }
tr.expandable { cursor: pointer; }
tr.expandable:hover td { background: #fafafa; }
tr.detail > td { background: #fbfbfb; padding: 6px 16px 14px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto; border-bottom: 1px solid var(--bord); }
.tabs button {
  font: inherit; font-weight: 700; background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-color: var(--pink); }

.segmented { display: inline-flex; background: #eee; border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.segmented button { font: inherit; font-size: 14px; font-weight: 700; border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; color: #666; }
.segmented button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* Modal */
dialog.modal { border: 0; border-radius: 16px; padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(0,0,0,.35); }
dialog.modal h3 { font-size: 20px; margin-bottom: 4px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.copy-box { display: flex; gap: 8px; margin: 10px 0; }
.copy-box input { margin: 0; font-size: 13px; }

/* Auth pages */
.auth { max-width: 380px; margin: 8vh auto 0; padding: 0 16px; }
.auth .brand { text-align: center; margin-bottom: 18px; }
.auth .brand .logo { width: 56px; height: 56px; font-size: 28px; border-radius: 16px; margin: 0 auto 10px; }
.auth .btn { width: 100%; padding: 13px; font-size: 16px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #333; color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700; transition: .2s; z-index: 100;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--pink); }

@media print {
  header.app, .tabs, .toolbar, .no-print, #toast { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  tr.detail > td { background: #fff; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
