:root {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 6% 7%;
  --card-foreground: 0 0% 98%;
  --popover: 240 6% 7%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 6% 10%;
  --secondary: 240 4% 16%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 4% 16%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 4% 16%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 4% 16%;
  --input: 240 4% 16%;
  --ring: 240 5% 64.9%;
  --radius: 0.75rem;
  --good: 142 70% 45%;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.bg-page {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 50% -10%, hsl(240 8% 14% / 0.7), transparent 60%),
    hsl(var(--background));
}

/* ----- login ----- */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 26rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: 0 24px 60px hsl(0 0% 0% / 0.45);
}
.login-logo {
  width: min(100%, 16rem);
  margin: 0 auto 1.25rem;
  filter: drop-shadow(0 8px 20px hsl(0 0% 0% / 0.35));
}
.login-card h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}
.login-card p.sub {
  margin-top: 0.35rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
}
.login-card form { margin-top: 1.5rem; display: grid; gap: 0.85rem; }
.alert {
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  background: hsl(0 62% 20% / 0.5);
  border: 1px solid hsl(0 62% 35% / 0.5);
  color: hsl(0 90% 90%);
}
.alert.ok {
  background: hsl(142 40% 14% / 0.6);
  border-color: hsl(142 40% 28% / 0.6);
  color: hsl(142 70% 85%);
}

/* ----- forms ----- */
label.fld {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
label.fld.notes-fld { gap: 0.4rem; }
label.fld span.req::after { content: ""; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"],
input[type="number"], input[type="tel"], textarea, select {
  width: 100%;
  background: hsl(240 6% 5%);
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 0.6rem 0.75rem;
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea {
  min-height: 4.6rem;
  resize: vertical;
  line-height: 1.4;
}
input:focus, textarea:focus, select:focus {
  border-color: hsl(240 5% 46%);
  box-shadow: 0 0 0 3px hsl(240 5% 46% / 0.25);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.6rem 0.95rem;
  font-weight: 550;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  transition: opacity .15s, background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}
.btn.ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.btn.danger {
  background: transparent;
  color: hsl(0 80% 75%);
  border-color: hsl(0 50% 30%);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 1rem; height: 1rem; }

/* ----- app shell ----- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(12px);
  background: hsl(240 10% 3.9% / 0.86);
  border-bottom: 1px solid hsl(var(--border));
}
.topbar-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.topbar img.logo { height: 2.1rem; width: auto; }
.topbar .brand { display: flex; flex-direction: column; min-width: 0; }
.topbar .brand strong { font-size: 0.95rem; letter-spacing: -0.02em; }
.topbar .brand span { font-size: 0.72rem; color: hsl(var(--muted-foreground)); }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 0.8rem; color: hsl(var(--muted-foreground)); }

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem 1rem 7rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
}
.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.card h2 .hint { font-weight: 400; font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

.grid-2 { display: grid; gap: 0.75rem; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 0.75rem; grid-template-columns: repeat(3, 1fr); }
.grid-4 { display: grid; gap: 0.75rem; grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }

.totals {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
}
.pill {
  background: hsl(240 5% 12%);
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
}
.pill b { color: hsl(var(--foreground)); font-variant-numeric: tabular-nums; }
.pill.grand { border-color: hsl(240 5% 30%); background: hsl(240 5% 14%); }

/* day cards */
.day {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 0.8rem;
  background: hsl(240 6% 6%);
  display: grid;
  gap: 0.65rem;
}
.day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
}
.day-head .dow { font-weight: 600; font-size: 0.85rem; letter-spacing: 0.02em; }
.day-head .dt { font-size: 0.8rem; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }
.day-head .tot { font-size: 0.8rem; font-variant-numeric: tabular-nums; color: hsl(var(--muted-foreground)); }
.day-head .tot b { color: hsl(var(--foreground)); }
.hrs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.notes-grid { display: grid; gap: 0.65rem; }
@media (min-width: 720px) {
  .notes-grid { grid-template-columns: 1fr 1fr; }
}
.days { display: grid; gap: 0.7rem; }
.week-sum {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.2rem;
}

.sticky-actions {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: hsl(240 10% 3.9% / 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid hsl(var(--border));
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
}
.sticky-actions .inner {
  max-width: 72rem; margin: 0 auto;
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.status { font-size: 0.8rem; color: hsl(var(--muted-foreground)); flex: 1; min-width: 8rem; }
.status.dirty { color: hsl(45 90% 70%); }
.status.saved { color: hsl(142 70% 70%); }
.status.err { color: hsl(0 80% 75%); }

.menu { position: relative; }
.menu-pop {
  display: none;
  position: absolute;
  right: 0; bottom: calc(100% + 0.4rem);
  min-width: 13.5rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.35rem;
  box-shadow: 0 16px 40px hsl(0 0% 0% / 0.45);
}
.menu.open .menu-pop { display: grid; gap: 0.2rem; }
.menu-pop button, .menu-pop label.file-btn {
  all: unset;
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.6rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  font-size: 0.85rem;
}
.menu-pop button:hover, .menu-pop label.file-btn:hover { background: hsl(var(--accent)); }
.menu-pop .sep { height: 1px; background: hsl(var(--border)); margin: 0.2rem 0; }

.hidden { display: none !important; }

@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .span-2, .span-3 { grid-column: span 2; }
  .topbar .user { display: none; }
}
@media (max-width: 520px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-all { grid-column: auto; }
  .hrs-row { grid-template-columns: 1fr; }
  .login-card { padding: 1.5rem 1.1rem 1.2rem; }
}
