/* ---------------------------------------------------------------------------
   Timestamp — hand-rolled iOS-style CSS. Light + dark, safe-area aware.
--------------------------------------------------------------------------- */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #ffffff;
  --text: #1c1c1e;
  --text-2: #8e8e93;
  --sep: rgba(60, 60, 67, 0.16);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --warn-bg: #fff4e5;
  --warn-text: #9a5b00;
  --err-bg: #ffe5e3;
  --err-text: #b00020;
  --ok-bg: #e4f7e8;
  --ok-text: #1c7a37;
  --nav-bg: rgba(249, 249, 249, 0.86);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --text: #ffffff;
    --text-2: #98989f;
    --sep: rgba(84, 84, 88, 0.5);
    --warn-bg: #3a2c12;
    --warn-text: #ffcf7a;
    --err-bg: #3a1714;
    --err-text: #ff9a92;
    --ok-bg: #12321c;
    --ok-text: #7ee29a;
    --nav-bg: rgba(30, 30, 30, 0.8);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
}

/* --- Nav bar --------------------------------------------------------------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 56px 1fr 56px; align-items: center;
  padding: calc(var(--safe-top) + 6px) 8px 6px;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.nav-title { text-align: center; font-weight: 600; font-size: 16px; }
.nav-date { font-weight: 600; }
.nav-left { text-align: left; } .nav-right { text-align: right; }
.nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 34px; font-size: 26px; color: var(--blue);
  text-decoration: none; border-radius: 8px;
}
.nav-btn:active { background: var(--sep); }
.date-jump { position: relative; display: inline-block; }
.date-jump input[type=date] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0;
}

/* --- Layout ---------------------------------------------------------------- */
.content {
  max-width: 640px; margin: 0 auto;
  padding: 14px 14px calc(84px + var(--safe-bottom));
}
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* --- Quick punch ----------------------------------------------------------- */
.punch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.punch-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: none; border-radius: 20px; padding: 22px 0; color: #fff;
  font-size: 22px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12); transition: transform .06s ease;
}
.punch-btn:active { transform: scale(0.97); }
.punch-start { background: linear-gradient(180deg, #3ad35f, #2bb14e); }
.punch-stop  { background: linear-gradient(180deg, #ff5147, #e8362c); }
.punch-sub { font-size: 13px; font-weight: 500; opacity: 0.9; }

/* --- Totals ---------------------------------------------------------------- */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 6px; }
.total-item { display: flex; flex-direction: column; gap: 4px; }
.total-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-key { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* --- Rows / segmented ------------------------------------------------------ */
.row-card { display: flex; align-items: center; justify-content: space-between; }
.row-title { font-weight: 500; }
.segmented { display: inline-flex; background: var(--card-2); border-radius: 9px; padding: 2px; gap: 2px; }
@media (prefers-color-scheme: light) { .segmented { background: #e9e9ec; } }
.seg {
  border: none; background: transparent; color: var(--text); font-size: 14px; font-weight: 500;
  padding: 7px 16px; border-radius: 7px; cursor: pointer; text-decoration: none; text-align: center;
}
.seg-on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
@media (prefers-color-scheme: dark) { .seg-on { background: #636366; } }
.seg-wide { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; margin-bottom: 14px; }

/* --- Lists / entries ------------------------------------------------------- */
.list-section { margin-bottom: 8px; }
.list-header { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-2); margin: 18px 6px 8px; font-weight: 600; }
.empty { color: var(--text-2); text-align: center; padding: 22px 10px; font-size: 15px; }

.entry { padding: 0; overflow: hidden; }
.entry-summary { list-style: none; display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; cursor: pointer; }
.entry-summary::-webkit-details-marker { display: none; }
.entry-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-start { background: var(--green); } .dot-stop { background: var(--red); }
.entry-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.entry-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.entry-type { font-size: 13px; color: var(--text-2); text-transform: capitalize; }
.entry-tz { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.entry-flag { box-shadow: inset 3px 0 0 var(--orange), 0 1px 2px rgba(0,0,0,0.04); }
.entry-issue { color: var(--warn-text); background: var(--warn-bg); font-size: 13px;
  padding: 8px 14px; }
.entry-note { padding: 6px 14px; color: var(--text-2); font-size: 14px; }

.edit-form { padding: 8px 14px 14px; border-top: 0.5px solid var(--sep); }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-actions { display: flex; gap: 10px; margin-top: 12px; }
.edit-actions .btn { flex: 1; }

/* --- Fields ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--text-2); padding-left: 2px; }
.field input, .field select {
  font-size: 16px; padding: 11px 12px; border: 1px solid var(--sep); border-radius: 10px;
  background: var(--card-2); color: var(--text); width: 100%; -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.add-form, .table-card { padding: 14px; }

/* --- Buttons --------------------------------------------------------------- */
.btn { font-size: 16px; font-weight: 600; padding: 12px 16px; border-radius: 12px;
  border: none; cursor: pointer; text-decoration: none; text-align: center; display: inline-block; }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--card); color: var(--blue); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.btn-danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.btn:active { filter: brightness(0.94); }
.export-btn { margin-top: 6px; }

/* --- Banners --------------------------------------------------------------- */
.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.banner-warn { background: var(--warn-bg); color: var(--warn-text); }
.banner-error { background: var(--err-bg); color: var(--err-text); }
.banner-success { background: var(--ok-bg); color: var(--ok-text); }
.hint { color: var(--text-2); font-size: 13px; margin: -4px 6px 14px; }

/* --- Report table ---------------------------------------------------------- */
.table-card { padding: 4px 0; }
.trow { display: grid; grid-template-columns: 1.3fr 0.7fr 1fr 1fr 1fr;
  align-items: center; gap: 4px; padding: 11px 14px; font-size: 14px;
  font-variant-numeric: tabular-nums; text-decoration: none; color: var(--text);
  border-bottom: 0.5px solid var(--sep); }
.trow:last-child { border-bottom: none; }
.trow:active { background: var(--sep); }
.thead { color: var(--text-2); font-size: 12px; text-transform: uppercase; font-weight: 600; }
.thead:active { background: none; }
.td-date { font-weight: 600; } .td-loc { color: var(--text-2); }
.trow-flag .td-date { color: var(--orange); }

/* --- Tab bar --------------------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
  padding-bottom: var(--safe-bottom);
}
.tab, .tab-form button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; font-size: 10px; color: var(--text-2);
  text-decoration: none; background: none; border: none; width: 100%; cursor: pointer;
  font-family: inherit;
}
.tab.active { color: var(--blue); }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-form { padding: 0; }

/* --- Login ----------------------------------------------------------------- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 360px; padding: 24px; text-align: center; }
.login-logo { font-size: 52px; }
.login-title { margin: 4px 0 2px; font-size: 28px; }
.login-sub { margin: 0 0 22px; color: var(--text-2); }
.login-card { text-align: left; }
