:root {
  --bg: #0a0a0c;
  --bg-elev: #16161a;
  --bg-elev-2: #1f1f24;
  --border: #2a2a30;
  --text: #f2f2f4;
  --text-dim: #9c9ca6;
  --accent: #ff6a1a;
  --accent-2: #ff8c42;
  --accent-glow: rgba(255, 106, 26, 0.45);
  --green: #33d17a;
  --red: #f75f5f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --nav-h: 64px;
}

* { box-sizing: border-box; }

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

body {
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255, 106, 26, 0.10), transparent 60%),
    var(--bg);
}

a { color: inherit; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}

@media (min-width: 900px) {
  .container { max-width: 980px; padding-top: 32px; }
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px 4px;
}
@media (min-width: 900px) { .topbar { max-width: 980px; } }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px var(--accent-glow);
}
.icon-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* Hero overtime tile */
.hero {
  text-align: center;
  padding: 26px 18px;
}
.hero .value {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px var(--accent-glow);
}
.hero .value.negative {
  background: linear-gradient(180deg, #ff9c9c, var(--red));
  -webkit-background-clip: text;
  background-clip: text;
}
.hero .label {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-tile {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-tile .num { font-size: 20px; font-weight: 700; }
.stat-tile .num.pos { color: var(--green); }
.stat-tile .num.neg { color: var(--red); }
.stat-tile .lbl { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #1a0a00;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 26px var(--accent-glow); }
.btn-stop {
  background: linear-gradient(135deg, #ff7a7a, var(--red));
  color: #2a0000;
  box-shadow: 0 4px 20px rgba(247, 95, 95, 0.4);
}
.btn-ghost {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
}

/* Forms */
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], input[type="month"],
select, textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  margin-bottom: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--text-dim); font-size: 14px; }
.checkbox-row input { width: auto; margin: 0; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card .logo {
  text-align: center;
  margin-bottom: 22px;
}
.login-card .logo .ring {
  width: 56px; height: 56px; border-radius: 50%;
  margin: 0 auto 10px;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent) 60%, #7a2e00 100%);
  box-shadow: 0 0 40px var(--accent-glow);
}
.login-card .logo h1 { font-size: 18px; margin: 0; }
.error-msg {
  background: rgba(247, 95, 95, 0.12);
  border: 1px solid var(--red);
  color: #ffb3b3;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
}
.success-msg {
  background: rgba(51, 209, 122, 0.12);
  border: 1px solid var(--green);
  color: #a8f0c6;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(16, 16, 20, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active svg { filter: drop-shadow(0 0 6px var(--accent-glow)); }

/* Entries list */
.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.entry-row:last-child { border-bottom: none; }
.entry-row .meta { flex: 1; min-width: 0; }
.entry-row .date { font-weight: 600; font-size: 14px; }
.entry-row .time-range { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.entry-row .note { color: var(--text-dim); font-size: 12px; margin-top: 2px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-row .duration { font-weight: 700; font-size: 15px; white-space: nowrap; }
.entry-row .actions { display: flex; gap: 6px; }
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 106, 26, 0.15);
  color: var(--accent-2);
  margin-left: 6px;
  text-transform: uppercase;
}
.badge.holiday { background: rgba(51, 209, 122, 0.15); color: var(--green); }
.badge.open { background: rgba(247, 95, 95, 0.18); color: #ffb3b3; }

.day-group-label {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 18px 0 6px;
}
.day-group-label:first-child { margin-top: 0; }

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #1a0a00;
  border-color: transparent;
}

.period-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.period-nav .period-label { font-weight: 700; font-size: 15px; text-align: center; flex: 1; }

.chart-wrap { position: relative; height: 260px; }
@media (min-width: 900px) { .chart-wrap { height: 340px; } }

table.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
}
table.stats-table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
}
table.stats-table tr:last-child td { border-bottom: none; }
.tnum { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.dim { color: var(--text-dim); }

.fab-row { display: flex; gap: 10px; margin-bottom: 16px; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
@media (min-width: 700px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
@media (min-width: 700px) { .modal { border-radius: 20px; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; font-size: 17px; text-transform: none; letter-spacing: 0; }
.hidden { display: none !important; }

.toast-wrap {
  position: fixed;
  top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: min(90vw, 400px);
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
.toast.ok { background: var(--green); color: #04180c; }
.toast.err { background: var(--red); color: #2a0000; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px);} to { opacity: 1; transform: translateY(0);} }

.empty-state { text-align: center; color: var(--text-dim); padding: 30px 10px; font-size: 14px; }

.live-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 106, 26, 0.1);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.live-banner .pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 2px var(--accent-glow);
  animation: pulse 1.6s infinite;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.warn-banner {
  background: rgba(247, 95, 95, 0.1);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #ffb3b3;
}
