@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --navy-950: #061422;
  --navy-900: #0D2138;
  --navy-800: #15304C;
  --navy-700: #1E4160;
  --line: #3E5876;
  --ink: #EAF1F8;
  --muted: #93A9BF;
  --amber: #E8A33D;
  --amber-light: #F3C275;
  --teal: #4FB8A8;
  --coral: #E2735A;
  --steel: #8FA9C4;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy-950);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font-family: inherit; }

.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* ---------- App shell ---------- */

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--navy-950);
}

header.app-header {
  background: var(--navy-900);
  padding: env(safe-area-inset-top, 20px) 20px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.brand svg { flex-shrink: 0; }
.brand span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.header-figure {
  font-family: var(--font-mono);
  font-size: 26px;
  color: var(--amber);
  margin-top: 2px;
}
.header-range {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.tide-divider {
  width: 100%;
  height: 8px;
  margin-top: 14px;
}

main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 96px;
}

.view { padding: 16px; }

/* ---------- Timesheet cards ---------- */

.ts-card {
  position: relative;
  display: flex;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--navy-900);
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}
.ts-card .spine { width: 10px; flex-shrink: 0; }
.ts-card .seam {
  width: 0;
  border-left: 1px dashed rgba(147,169,191,0.35);
  position: relative;
}
.ts-card .seam::before, .ts-card .seam::after {
  content: '';
  position: absolute;
  left: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--navy-950);
}
.ts-card .seam::before { top: -5px; }
.ts-card .seam::after { bottom: -5px; }

.ts-card .body { flex: 1; padding: 12px 16px; }
.ts-card .row-top { display: flex; align-items: flex-start; justify-content: space-between; }
.ts-card .date { font-family: var(--font-mono); font-size: 17px; }
.ts-card .day { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-left: 6px; }
.ts-card .type-chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.ts-card .job { font-size: 12px; color: var(--muted); margin-left: 6px; }

.stamp {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid currentColor;
  border-radius: 3px;
  transform: rotate(-3deg);
  white-space: nowrap;
}

.row-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.shift-time { font-family: var(--font-mono); font-size: 13px; }
.flag-icons { display: flex; gap: 6px; align-items: center; }
.flag-icons svg { width: 14px; height: 14px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 14px;
}

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  right: 50%;
  transform: translateX(190px);
  bottom: 92px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--amber);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(232,163,61,0.4);
  z-index: 15;
}
.fab svg { color: var(--navy-950); }

.fab-secondary {
  width: 48px;
  height: 48px;
  bottom: 160px;
  background: var(--navy-700);
  border: 2px solid var(--amber);
  box-shadow: 0 8px 20px rgba(232,163,61,0.35), 0 4px 10px rgba(0,0,0,0.4);
}
.fab-secondary svg { color: var(--amber); }

@media (max-width: 480px) {
  .fab { right: 20px; transform: none; }
}

/* ---------- Bottom nav ---------- */

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 76px;
  background: #0A1A2B;
  border-top: 1px solid var(--navy-800);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 20;
}
nav.bottom-nav button {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--steel);
  padding: 6px 12px;
}
nav.bottom-nav button.active { color: var(--amber); }
nav.bottom-nav span {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Slide-up sheet ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  max-height: 88dvh;
  max-height: calc(var(--vvh, 100vh) * 0.88);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--navy-900);
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0));
  z-index: 31;
  transition: transform 0.3s ease;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.4);
}
.sheet.open { transform: translate(-50%, 0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 4px auto 16px;
}
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-header h3 { font-family: var(--font-display); font-size: 18px; margin: 0; }
.icon-btn {
  background: var(--navy-800);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}
.field {
  width: 100%;
  background: var(--navy-800);
  border: none;
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
  font-family: var(--font-mono);
  margin-bottom: 16px;
  appearance: none;
}
.field:focus { outline: 2px solid var(--amber); outline-offset: 1px; }

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.segmented button {
  padding: 10px 4px;
  border-radius: 12px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  background: var(--navy-800);
  color: var(--muted);
}
.segmented button.active { color: var(--navy-950); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}
.chip.active { border-color: var(--amber); color: var(--amber); background: rgba(232,163,61,0.1); }

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: var(--amber);
  color: var(--navy-950);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--coral);
  background: transparent;
  color: var(--coral);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  margin-top: 10px;
}

/* ---------- Salary / Summary views ---------- */

.stat-card {
  background: var(--navy-800);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}
.stat-card .header-label { margin-bottom: 4px; }
.stat-card .total { font-family: var(--font-mono); font-size: 28px; color: var(--amber); }

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 4px 0 8px;
}

.line-list { background: var(--navy-900); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.line-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--navy-800);
}
.line-item:first-child { border-top: none; }
.line-item .label { font-size: 14px; }
.line-item .sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.blended-note { color: var(--amber); font-family: var(--font-body); }
.line-item .amount { font-family: var(--font-mono); font-size: 14px; }
.amount.positive { color: var(--teal); }
.amount.negative { color: var(--coral); }

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--navy-800);
}
.cat-item:first-child { border-top: none; }
.cat-item .count { font-family: var(--font-mono); color: var(--amber); font-size: 16px; }

.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* old Edge/IE */
}
.filter-bar::-webkit-scrollbar {
  display: none;              /* Chrome, Safari, newer Edge */
}
.filter-bar button {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}
.filter-bar button.active { background: var(--amber); color: var(--navy-950); border-color: var(--amber); }

.rates-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 0 0 16px;
  margin-top: -8px;
}
.rates-link svg { flex-shrink: 0; }

.rate-item { padding: 12px 16px; border-top: 1px solid var(--navy-800); }
.rate-item:first-child { border-top: none; }
.rate-item .rate-row { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.rate-item .rate-current { font-family: var(--font-mono); color: var(--amber); font-size: 14px; }
.rate-item .rate-since { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.rate-item .rate-history { display: none; margin-top: 8px; padding-left: 4px; }
.rate-item.expanded .rate-history { display: block; }
.rate-history-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.rate-history-row:hover { background: var(--navy-800); }

.menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--navy-800);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
}
.menu-row:first-child { border-top: none; }
.menu-row svg { color: var(--muted); }

.worker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--navy-800);
  cursor: pointer;
}
.worker-item:first-child { border-top: none; }
.worker-item .worker-username { font-size: 12px; color: var(--muted); }
.worker-item .admin-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 8px;
}

.maintenance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--navy-900);
  border-radius: 16px;
}
.maintenance-row .label { font-size: 15px; margin-bottom: 2px; }
#maintenanceToggleBtn.chip-on { border-color: var(--coral); color: var(--coral); background: rgba(226,115,90,0.12); }
#maintenanceToggleBtn.chip-off { border-color: var(--teal); color: var(--teal); background: rgba(79,184,168,0.1); }

.btn-compact { width: auto; padding: 10px 16px; flex-shrink: 0; }

.select-bar {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--navy-800);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 18;
}
.select-bar-count {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.select-bar .field { flex: 1; }

.ts-card-check {
  display: flex;
  align-items: center;
  padding-left: 12px;
}
#tsList.select-mode-active { padding-bottom: 90px; }
.ts-card-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--amber);
}

.sheet-hint {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 18px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  top: env(safe-area-inset-top, 12px);
  left: 50%;
  transform: translate(-50%, -20px);
  background: var(--navy-800);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 50;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  border-left: 3px solid var(--teal);
  max-width: 90%;
}
.toast.error { border-left-color: var(--coral); }
.toast.show { opacity: 1; transform: translate(-50%, 0); top: calc(env(safe-area-inset-top, 12px) + 12px); }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--navy-800);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #0E2438 0%, #030A13 70%);
}
.login-card { width: 100%; max-width: 360px; }
.login-hero { text-align: center; margin-bottom: 36px; }
.login-logo {
  width: 104px;
  height: 104px;
  border-radius: 26px;
  margin-bottom: 22px;
  box-shadow: 0 16px 40px rgba(237, 183, 39, 0.22), 0 4px 14px rgba(0,0,0,0.4);
}
.login-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
}
.login-subtitle {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 4px;
  padding: 0 8px;
}
.login-card .btn-primary { margin-top: 8px; }
.login-error { color: var(--coral); font-size: 13px; margin-top: 10px; text-align: center; display: none; }

/* =====================================================================
   Large screens (laptop / desktop) — everything above is untouched for
   mobile. This block only changes layout at wider viewports:
   - bottom nav becomes a fixed left sidebar
   - the app shell widens instead of staying a centered 480px column
   - bottom sheets become centered modal dialogs
   - the timesheet list uses the extra width as a card grid
   ===================================================================== */
@media (min-width: 860px) {
  #app {
    max-width: none;
    margin: 0;
    margin-left: 232px;
    min-height: 100vh;
  }

  body { background: var(--navy-950); }

  header.app-header { padding: 28px 40px 20px; }
  .view { padding: 24px 40px 180px; }
  main { padding-bottom: 0; }

  .tide-divider { max-width: none; }

  /* Sidebar nav */
  nav.bottom-nav {
    left: 0;
    top: 0;
    bottom: 0;
    transform: none;
    width: 232px;
    max-width: 232px;
    height: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    padding: 28px 14px;
    border-top: none;
    border-right: 1px solid var(--navy-800);
  }
  nav.bottom-nav button {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    width: 100%;
  }
  nav.bottom-nav button.active { background: var(--navy-800); }
  nav.bottom-nav span {
    font-size: 13.5px;
    letter-spacing: 0.02em;
    text-transform: none;
    font-weight: 500;
  }
  nav.bottom-nav button#btnLogout { margin-top: auto; }

  /* FABs stay pinned to the viewport (not the page content), so they
     remain reachable without scrolling the whole page down to find them.
     Content is full-width now (no capped max-width), so a viewport-fixed
     right edge lines up with the content's right edge correctly too. */
  .fab {
    position: fixed;
    right: 40px;
    left: auto;
    transform: none;
    bottom: 40px;
  }
  .fab-secondary { bottom: 108px; }

  .select-bar {
    position: fixed;
    left: 232px;
    right: 0;
    transform: none;
    max-width: none;
    bottom: 0;
    padding: 14px 40px;
  }
  .select-bar .field { max-width: 240px; flex: 0 0 auto; }

  /* Sheets become centered modal dialogs instead of sliding up from the
     bottom edge of the whole viewport */
  .sheet {
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -46%);
    max-width: 460px;
    max-height: 82vh;
    border-radius: 24px;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .sheet.open {
    transform: translate(-50%, -50%);
    opacity: 1;
    pointer-events: auto;
  }

  /* Timesheet cards stay one per row (no grid), full width like everything else */

  .login-wrap { background: radial-gradient(ellipse at top, #0E2438 0%, #030A13 60%); }
}
