:root,
[data-theme="light"] {
  --font-display: "Cabinet Grotesk", "Arial", sans-serif;
  --font-body: "Satoshi", "Arial", sans-serif;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --color-bg: #f8f5f0;
  --color-surface: #fffdfa;
  --color-surface-2: #f0eae2;
  --color-border: #ded4c8;
  --color-divider: #e9e0d6;
  --color-text: #231c17;
  --color-text-muted: #7a6d63;
  --color-primary: #c4471b;
  --color-primary-hover: #a93712;
  --color-primary-soft: #f5ddd3;
  --color-success: #32704a;
  --color-success-soft: #dcece2;
  --color-error: #a13434;
  --shadow-sm: 0 1px 2px rgba(45, 29, 18, 0.06);
  --shadow-md: 0 8px 24px rgba(45, 29, 18, 0.08);
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-full: 999px;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --color-bg: #171310;
  --color-surface: #201b17;
  --color-surface-2: #2a231e;
  --color-border: #40362f;
  --color-divider: #332b25;
  --color-text: #f4ece5;
  --color-text-muted: #aa9d93;
  --color-primary: #ef7041;
  --color-primary-hover: #ff8458;
  --color-primary-soft: #48261b;
  --color-success: #73bd8d;
  --color-success-soft: #203c2a;
  --color-error: #f07a7a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  background: var(--color-bg);
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.45;
  color: var(--color-text);
  background:
    radial-gradient(circle at 105% -10%, color-mix(in srgb, var(--color-primary) 12%, transparent), transparent 34%),
    var(--color-bg);
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) var(--space-4) calc(var(--space-8) + env(safe-area-inset-bottom));
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-divider);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 44px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1;
}

.brand span {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.icon-button svg,
.refresh-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.welcome {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-8) 0 var(--space-6);
}

.eyebrow {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: var(--font-display);
  line-height: 1.12;
}

h1 {
  font-size: var(--text-xl);
}

h2 {
  font-size: var(--text-lg);
}

.live-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.live-status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 4px var(--color-success-soft);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
}

.segment {
  min-height: 44px;
  border-radius: calc(var(--radius-lg) - var(--space-1));
  color: var(--color-text-muted);
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 700;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.segment.active {
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.view {
  display: none;
  padding-top: var(--space-5);
}

.view.active {
  display: block;
}

.category-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-4);
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 700;
}

.category-tab.active {
  border-color: var(--color-primary);
  color: var(--color-bg);
  background: var(--color-primary);
}

.progress-card {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5);
  border-radius: var(--radius-xl);
  color: #fff8f3;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 45%),
    #2c201a;
  box-shadow: var(--shadow-md);
}

.progress-ring {
  --progress: 0%;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--color-primary) var(--progress), rgba(255,255,255,0.12) 0);
}

.progress-ring::before {
  content: "";
  width: 56px;
  height: 56px;
  grid-area: 1 / 1;
  border-radius: 50%;
  background: #2c201a;
}

.progress-ring strong {
  z-index: 1;
  grid-area: 1 / 1;
  font-size: var(--text-sm);
}

.progress-card h2 {
  margin-bottom: var(--space-1);
}

.progress-card p {
  color: rgba(255, 248, 243, 0.66);
  font-size: var(--text-sm);
}

.checklist {
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.check-item {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  background: var(--color-surface);
}

.check-item + .check-item,
.readonly-item + .readonly-item {
  border-top: 1px solid var(--color-divider);
}

.check-box {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.check-box svg {
  width: 16px;
  fill: none;
  stroke: white;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--transition), transform var(--transition);
}

.check-item.done .check-box {
  border-color: var(--color-success);
  background: var(--color-success);
}

.check-item.done .check-box svg {
  opacity: 1;
  transform: scale(1);
}

.check-item.done .check-text {
  color: var(--color-text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.check-item:active .check-box {
  transform: scale(0.88);
}

.check-item.pending {
  opacity: 0.65;
  pointer-events: none;
}

.check-text {
  font-size: var(--text-sm);
  font-weight: 500;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.refresh-button {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-surface);
  font-size: var(--text-xs);
  font-weight: 700;
}

.section-copy {
  margin: var(--space-3) 0 var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.employee-card {
  margin-bottom: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--color-surface);
}

.employee-summary {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  text-align: left;
  background: var(--color-surface);
}

.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--color-primary);
  background: var(--color-primary-soft);
  font-family: var(--font-display);
  font-weight: 700;
}

.employee-name {
  display: block;
  font-weight: 700;
}

.employee-count {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.mini-progress {
  width: 52px;
  height: 6px;
  margin-top: var(--space-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--color-surface-2);
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-success);
}

.chevron {
  width: 22px;
  fill: none;
  stroke: var(--color-text-muted);
  stroke-width: 2;
  transition: transform var(--transition);
}

.employee-card.open .chevron {
  transform: rotate(180deg);
}

.employee-details {
  display: none;
  border-top: 1px solid var(--color-divider);
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-surface-2) 55%, var(--color-surface));
}

.employee-card.open .employee-details {
  display: block;
}

.readonly-category + .readonly-category {
  margin-top: var(--space-5);
}

.readonly-category h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.readonly-category h3 span {
  color: var(--color-text-muted);
  font-weight: 500;
}

.readonly-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}

.readonly-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: var(--space-2);
  padding: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.readonly-icon {
  color: var(--color-text-muted);
  font-weight: 700;
}

.readonly-item.done {
  color: var(--color-text);
}

.readonly-item.done .readonly-icon {
  color: var(--color-success);
}

.state-card {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-align: center;
  color: var(--color-text-muted);
}

.state-card strong {
  color: var(--color-text);
}

.loader {
  width: 36px;
  height: 36px;
  margin-bottom: var(--space-3);
  border: 3px solid var(--color-primary-soft);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  font-weight: 700;
}

.primary-button {
  min-height: 44px;
  margin-top: var(--space-3);
  padding: 0 var(--space-5);
  border-radius: var(--radius-full);
  color: white;
  background: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100vw - var(--space-8));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  color: white;
  background: #211b17;
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, var(--space-4));
  transition: opacity var(--transition), transform var(--transition);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

[hidden] {
  display: none !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  .app-shell {
    padding-inline: var(--space-3);
  }

  .welcome {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-3);
  }

  .live-status {
    padding-left: var(--space-1);
  }

  .progress-card {
    gap: var(--space-4);
    padding: var(--space-4);
  }
}

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