:root {
  --fu-bg: #f4f6f9;
  --fu-surface: #ffffff;
  --fu-border: #e6e9ef;
  --fu-text: #1c2333;
  --fu-muted: #475569;
  --fu-primary: #4f46e5;
  --fu-primary-dark: #4338ca;
  --fu-accent: #06b6d4;
  --fu-danger: #dc2626;
  --fu-radius: 0.9rem;
  --fu-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

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

html {
  font-size: 17px;
}

@media (min-width: 768px) {
  html {
    font-size: 17px;
  }
}

html, body {
  height: 100%;
}

body {
  background: var(--fu-bg);
  color: var(--fu-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

/* Top navbar */
.fu-navbar {
  background: var(--fu-surface);
  border-bottom: 1px solid var(--fu-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.fu-navbar .fu-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fu-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.fu-brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  background: linear-gradient(135deg, var(--fu-primary), var(--fu-accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.fu-navbar-inner {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* User menu: a single compact avatar button that reveals Change PIN / Sign out in a
   dropdown, instead of always-visible text buttons competing for space on mobile. */
.fu-user-menu {
  position: relative;
}

.fu-user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.fu-user-menu-trigger:hover {
  background: var(--fu-bg);
}

.fu-user-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fu-primary), var(--fu-accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.fu-user-email-desktop {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fu-text);
}

.fu-user-menu-chevron {
  color: var(--fu-muted);
  font-size: 0.75rem;
}

.fu-user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  background: var(--fu-surface);
  border: 1px solid var(--fu-border);
  border-radius: 0.9rem;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
  min-width: 220px;
  padding: 0.5rem;
  z-index: 30;
}

.fu-user-menu-dropdown.fu-open {
  display: block;
}

.fu-user-menu-email {
  padding: 0.5rem 0.75rem 0.65rem;
  font-size: 0.8rem;
  color: var(--fu-muted);
  border-bottom: 1px solid var(--fu-border);
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.fu-user-menu-dropdown a,
.fu-user-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 0.6rem;
  background: none;
  border: none;
  color: var(--fu-text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.fu-user-menu-dropdown a:hover,
.fu-user-menu-dropdown button:hover {
  background: var(--fu-bg);
}

.fu-user-menu-dropdown form {
  margin: 0;
}

@media (max-width: 767.98px) {
  .fu-navbar-inner {
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .fu-navbar .fu-brand span:last-child {
    font-size: 0.95rem;
  }

  .fu-user-email-desktop {
    display: none;
  }

  .fu-user-menu-trigger {
    padding: 0.25rem;
  }
}

/* Page container */
.fu-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.fu-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.fu-page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.fu-badge-scope {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #eef2ff;
  color: var(--fu-primary-dark);
  border-radius: 2rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Filter toolbar */
.fu-toolbar {
  background: var(--fu-surface);
  border: 1px solid var(--fu-border);
  border-radius: var(--fu-radius);
  box-shadow: var(--fu-shadow);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.fu-toolbar-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.fu-toolbar-summary {
  display: none;
}

.fu-toolbar .fu-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 180px;
  min-width: 150px;
}

.fu-toolbar label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fu-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fu-toolbar select,
.fu-toolbar input[type="search"] {
  border: 1.5px solid var(--fu-border);
  border-radius: 0.6rem;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  min-height: 2.75rem;
  background: var(--fu-bg);
  color: var(--fu-text);
}

.fu-toolbar select option {
  background: var(--fu-surface);
  color: var(--fu-text);
  font-size: 1rem;
}

.fu-toolbar select:focus,
.fu-toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--fu-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.fu-toolbar .fu-clear-btn {
  border: 1.5px solid var(--fu-border);
  background: var(--fu-surface);
  border-radius: 0.6rem;
  padding: 0.65rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 2.75rem;
  color: var(--fu-text);
  cursor: pointer;
}

.fu-toolbar .fu-clear-btn:hover {
  background: var(--fu-bg);
}

.fu-count-pill {
  margin-left: auto;
  align-self: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fu-text);
  background: var(--fu-bg);
  border-radius: 2rem;
  padding: 0.35rem 0.9rem;
  white-space: nowrap;
}

/* Card wrapping the table */
.fu-card {
  background: var(--fu-surface);
  border: 1px solid var(--fu-border);
  border-radius: var(--fu-radius);
  box-shadow: var(--fu-shadow);
  overflow: hidden;
}

.fu-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.fu-table thead th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fu-muted);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--fu-border);
  background: #fafbfc;
}

.fu-table tbody tr {
  border-bottom: 1px solid var(--fu-border);
  transition: background-color 0.1s ease;
}

.fu-table tbody tr:last-child {
  border-bottom: none;
}

.fu-table tbody tr:hover {
  background: #f8fafc;
}

.fu-table td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  vertical-align: middle;
}

.fu-employee-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.fu-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fu-primary), var(--fu-accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.fu-chip {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  border-radius: 0.4rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
}

.fu-empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--fu-muted);
}

.fu-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3.5rem 1rem;
  color: var(--fu-muted);
  font-size: 0.9rem;
}

.fu-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--fu-border);
  border-top-color: var(--fu-primary);
  border-radius: 50%;
  animation: fu-spin 0.7s linear infinite;
}

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

.fu-alert {
  border-radius: var(--fu-radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.fu-alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Responsive table -> stacked cards on small screens */
@media (max-width: 767.98px) {
  .fu-table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .fu-table,
  .fu-table tbody,
  .fu-table tr,
  .fu-table td {
    display: block;
    width: 100%;
  }

  .fu-table tr {
    cursor: pointer;
    padding: 0.75rem 1rem;
  }

  .fu-table td {
    border: none;
    padding: 0.35rem 0;
    text-align: right;
  }

  .fu-table td::before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--fu-muted);
  }

  .fu-table td.fu-td-employee {
    text-align: left;
    position: relative;
    padding-right: 1.5rem;
  }

  .fu-table td.fu-td-employee::before {
    display: none;
  }

  .fu-table td.fu-td-employee::after {
    content: "\25BE";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fu-muted);
    transition: transform 0.15s ease;
  }

  .fu-table tr.fu-expanded td.fu-td-employee::after {
    transform: translateY(-50%) rotate(180deg);
  }

  /* Collapsed by default on mobile — only the employee name shows until tapped. */
  .fu-table td:not(.fu-td-employee) {
    display: none;
  }

  .fu-table tr.fu-expanded td:not(.fu-td-employee) {
    display: block;
  }

  .fu-toolbar {
    padding: 0.75rem 1rem;
  }

  .fu-toolbar-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .fu-toolbar-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    padding: 0;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--fu-text);
    cursor: pointer;
  }

  .fu-toolbar-chevron {
    color: var(--fu-muted);
    transition: transform 0.15s ease;
    font-size: 0.8rem;
  }

  .fu-toolbar.fu-filters-open .fu-toolbar-chevron {
    transform: rotate(180deg);
  }

  /* Collapsed by default — the fields only take space once the toggle above is tapped. */
  .fu-toolbar-fields {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-top: 0.85rem;
  }

  .fu-toolbar.fu-filters-open .fu-toolbar-fields {
    display: flex;
  }

  /* In column direction, flex-basis controls height, not width — without this override,
     the desktop "flex: 1 1 180px" on .fu-field stretches each field to a 180px-tall box,
     which is exactly the huge-gap bug this resets. */
  .fu-toolbar-fields .fu-field {
    flex: 0 0 auto;
    min-width: 0;
  }

  .fu-toolbar-fields .fu-count-pill {
    display: none;
  }
}

/* Auth pages */
.fu-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eef2ff 0%, var(--fu-bg) 45%);
  padding: 1rem;
}

.fu-auth-card {
  background: var(--fu-surface);
  border-radius: 1.1rem;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.fu-auth-card .fu-brand-mark {
  margin-bottom: 1rem;
}

.fu-auth-card h1 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.fu-auth-card p {
  color: var(--fu-muted);
  font-size: 0.9rem;
}

.fu-auth-card label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  display: block;
}

.fu-auth-card .form-control {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0.6rem;
  padding: 0.7rem 0.9rem;
  font-size: 1.05rem;
  min-height: 2.9rem;
  border: 1.5px solid var(--fu-border);
  color: var(--fu-text);
  background: var(--fu-surface);
}

.fu-auth-card .form-control:focus {
  border-color: var(--fu-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.fu-btn-primary {
  background: var(--fu-primary);
  border: none;
  color: white;
  border-radius: 0.6rem;
  padding: 0.8rem 1rem;
  font-size: 1.05rem;
  min-height: 2.9rem;
  font-weight: 700;
  width: 100%;
  transition: background-color 0.15s ease;
}

.fu-btn-primary:hover {
  background: var(--fu-primary-dark);
  color: white;
}

/* Intentionally always light: this app is used by an older, non-technical
   audience, and auto-switching to a dark theme (via prefers-color-scheme)
   caused native dropdown menus to render with unreadable low-contrast text
   on some devices. A single well-tested light theme is more predictable. */
