:root {
  color-scheme: light;
  --ink: #101820;
  --muted: #5d6a6b;
  --line: rgba(16, 24, 32, 0.12);
  --paper: #f6f8f7;
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #f4c542;
  --accent-2: #2f9c95;
  --danger: #c2413b;
  --shadow: 0 18px 60px rgba(16, 24, 32, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(circle at 20% 0%, rgba(244, 197, 66, 0.18), transparent 30%),
    linear-gradient(145deg, #f6f8f7 0%, #dce7e4 48%, #eef1ec 100%);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

button:active { transform: scale(0.97); }

.app-shell {
  width: min(100%, 840px);
  min-height: 100svh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-height: 62px;
  padding: 0 2px 12px;
  backdrop-filter: blur(18px);
}

.user-ribbon {
  width: 35vw;
  max-width: 294px;
  min-width: 118px;
  min-height: 38px;
  align-self: flex-start;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-top: 0;
  border-radius: 0 0 14px 0;
  background: rgba(16, 24, 32, 0.92);
  color: white;
  box-shadow: 0 12px 28px rgba(16, 24, 32, 0.22);
  text-align: left;
  transition: width 320ms ease, min-height 320ms ease, border-radius 320ms ease;
}

.user-ribbon.expanded {
  width: 100%;
  max-width: 100%;
  min-height: 116px;
  border-radius: 0 0 16px 0;
}

.user-ribbon > span:first-child {
  display: block;
  overflow: hidden;
  padding: 10px 12px 8px;
  font-size: 0.86rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ribbon-details {
  display: grid;
  max-height: 0;
  overflow: hidden;
  gap: 3px;
  padding: 0 12px;
  opacity: 0;
  transition: max-height 280ms ease, padding 280ms ease, opacity 240ms ease;
}

.user-ribbon.expanded .ribbon-details {
  max-height: 90px;
  padding: 0 12px 12px;
  opacity: 1;
}

.ribbon-details strong {
  font-size: 1.45rem;
  line-height: 1;
}

.ribbon-details small {
  color: rgba(255, 255, 255, 0.76);
  font-weight: 750;
}

.ribbon-details em {
  justify-self: start;
  margin-top: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.16);
  font-style: normal;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 2px;
  font-size: clamp(2.35rem, 11vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

#clockDate {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 650;
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.auth-panel, .workspace {
  display: none;
}

.auth-panel.active, .workspace.active {
  display: block;
  animation: rise 360ms ease both;
}

.brand-lockup, .quick-card, .entry-card, .filters, .auth-panel, dialog {
  border: 1px solid rgba(255, 255, 255, 0.68);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.auth-panel {
  padding: 16px;
  border-radius: 8px;
}

.brand-lockup {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 8px;
  box-shadow: none;
}

.brand-lockup h2, .brand-lockup p { margin-bottom: 3px; }
.brand-lockup p { color: var(--muted); }

.mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--accent);
  font-weight: 900;
}

.segmented, .entry-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.06);
}

.entry-mode { grid-template-columns: repeat(2, 1fr); }

.segmented button, .entry-mode button {
  min-height: 42px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active, .entry-mode button.active {
  background: var(--ink);
  color: white;
}

.auth-form {
  display: none;
  margin-top: 16px;
}

.auth-form.active { display: grid; gap: 12px; }

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  outline: none;
  padding: 0 13px;
  transition: border 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 94px;
  padding-top: 12px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(47, 156, 149, 0.14);
}

input.field-valid {
  background: rgba(224, 227, 225, 0.82);
  color: #00a848;
  border-color: #00a848;
  font-weight: 900;
}

input.field-invalid {
  background: rgba(0, 0, 0, 0.82);
  color: #ff2d2d;
  border-color: #ff2d2d;
  font-weight: 900;
}

.field-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 850;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 10px;
}

.phone-field {
  display: grid;
  grid-template-columns: auto minmax(42px, 54px) auto minmax(58px, 1fr) auto minmax(58px, 1fr) auto minmax(70px, 1.2fr);
  gap: 5px;
  align-items: center;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.phone-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.phone-field span {
  color: var(--muted);
  font-weight: 900;
}

.phone-field input {
  min-height: 42px;
  padding: 0 8px;
  text-align: center;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 36px;
  height: 34px;
  border-radius: 7px;
  background: rgba(16, 24, 32, 0.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.toggle-row, .status-row, .project-select-row, .entry-actions, .filter-row, .entry-head, .dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.pill-toggle, .primary, .secondary, .ghost, .file-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
}

.primary {
  background: var(--ink);
  color: white;
  box-shadow: 0 13px 28px rgba(16, 24, 32, 0.24);
}

.secondary, .file-button {
  background: var(--accent);
  color: var(--ink);
}

.ghost, .pill-toggle {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
}

.notice {
  margin: 0;
  padding: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: rgba(244, 197, 66, 0.18);
  color: #51451a;
  font-size: 0.86rem;
  line-height: 1.35;
}

.hidden { display: none !important; }

.quick-card, .entry-card, .filters, .active-heading {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 8px;
}

.work-section {
  position: relative;
  width: 98%;
  margin-right: auto;
  margin-left: auto;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(140deg, rgba(255, 255, 255, 0.88), rgba(47, 156, 149, 0.48), rgba(16, 24, 32, 0.42)) border-box;
  box-shadow:
    inset 2px 2px 8px rgba(255, 255, 255, 0.75),
    inset -2px -2px 8px rgba(16, 24, 32, 0.12),
    0 12px 30px rgba(16, 24, 32, 0.11);
}

.section-title, .subsection-title {
  width: min(100%, 440px);
  margin: -6px auto 12px;
  padding: 7px 10px;
  border-radius: 8px;
  background: linear-gradient(32deg, rgba(13, 48, 92, 0.82), rgba(108, 197, 242, 0.82));
  color: white;
  box-shadow: 0 7px 14px rgba(16, 24, 32, 0.18);
  font-size: 0.91rem;
  font-weight: 950;
  text-align: center;
}

.subsection {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.42)) padding-box,
    linear-gradient(145deg, rgba(47, 156, 149, 0.5), rgba(255, 255, 255, 0.8), rgba(16, 24, 32, 0.24)) border-box;
  box-shadow:
    inset 3px 3px 9px rgba(16, 24, 32, 0.09),
    inset -2px -2px 7px rgba(255, 255, 255, 0.62);
}

.subsection + .subsection {
  margin-top: 2px;
}

.active-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 40px;
}

.active-title span {
  overflow: hidden;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-title span:first-child { font-size: 0.9rem; }
.active-title span:last-child { font-size: 0.82rem; }
.active-title b { color: var(--accent-2); }

.quick-card h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.quick-card p { margin-bottom: 0; }

.project-select-row {
  margin-top: 14px;
}

.project-select-row select { flex: 1; }

.entry-card {
  display: grid;
  gap: 12px;
}

.suggest-wrap { position: relative; }

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 7px);
  z-index: 4;
  display: none;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.95);
  box-shadow: var(--shadow);
}

.suggestions.active { display: block; }

.suggestions button {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  background: transparent;
  color: white;
  text-align: left;
}

.suggestions button + button { border-top: 1px solid rgba(255, 255, 255, 0.12); }

.entry-actions {
  align-items: stretch;
}

.entry-actions > * {
  flex: 1;
}

.file-button {
  display: grid;
  place-items: center;
  text-align: center;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-strip, .entry-photos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
}

.photo-thumb {
  position: relative;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: #d7dddb;
  cursor: zoom-in;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  max-width: calc(100% - 8px);
  overflow: hidden;
  border-radius: 5px;
  background: rgba(16, 24, 32, 0.75);
  color: white;
  padding: 2px 4px;
  font-size: 0.6rem;
  text-overflow: ellipsis;
}

.filters {
  display: grid;
  gap: 10px;
}

.filter-row > * { flex: 1; }

.timeline {
  display: grid;
  gap: 12px;
}

.entry {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(16, 24, 32, 0.09);
  animation: rise 280ms ease both;
}

.entry h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.entry-project, .entry-meta {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.entry-notes {
  color: #263233;
  line-height: 1.42;
}

.edit-btn {
  min-width: 64px;
  min-height: 38px;
  border-radius: 7px;
  background: rgba(47, 156, 149, 0.13);
  color: #0f6964;
  font-weight: 900;
}

.delete-btn {
  min-width: 64px;
  min-height: 38px;
  border-radius: 7px;
  background: rgba(194, 65, 59, 0.12);
  color: var(--danger);
  font-weight: 900;
}

.subentries {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.subentry {
  padding: 10px;
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.055);
}

.subentry-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.subentry p { margin-bottom: 4px; }

.bottom-nav {
  position: fixed;
  right: max(14px, calc((100vw - 840px) / 2 + 14px));
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: max(14px, calc((100vw - 840px) / 2 + 14px));
  z-index: 6;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.bottom-nav.active { display: grid; }

.bottom-nav button {
  min-height: 46px;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.78rem;
  font-weight: 900;
}

.bottom-nav button.active {
  background: white;
  color: var(--ink);
}

dialog {
  width: min(calc(100vw - 28px), 520px);
  border-radius: 8px;
  border: 0;
  padding: 0;
}

dialog::backdrop {
  background: rgba(16, 24, 32, 0.45);
  backdrop-filter: blur(5px);
}

dialog form, .settings-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.photo-viewer {
  display: grid;
  gap: 10px;
  max-height: min(86svh, 760px);
  padding: 12px;
  overflow: auto;
}

.photo-viewer img {
  width: 100%;
  min-width: 100%;
  max-width: none;
  border-radius: 8px;
  object-fit: contain;
  touch-action: pan-x pan-y pinch-zoom;
}

.photo-viewer-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 54px 54px 1fr;
  gap: 8px;
  padding-top: 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}

.admin-tools {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.audit-log {
  display: grid;
  max-height: 220px;
  overflow: auto;
  gap: 8px;
  font-size: 0.76rem;
}

.audit-log div {
  padding: 8px;
  border-radius: 6px;
  background: rgba(16, 24, 32, 0.055);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 720px) {
  .workspace.active {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 14px;
    align-items: start;
  }

  .quick-card, .entry-card, .filters { margin-bottom: 0; }
  .active-heading { grid-column: 1 / -1; }
  .timeline { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
