:root {
  --bg: #f4f0c7;
  --bg-soft: #f9f5d8;
  --card: rgba(255, 251, 228, 0.94);
  --card-strong: #fff7d1;
  --text: #18302a;
  --muted: #667763;
  --primary: #1f7a53;
  --primary-dark: #15563b;
  --accent: #d7b93e;
  --accent-soft: #efe4a3;
  --danger: #a63d2a;
  --success: #165b3f;
  --border: rgba(93, 120, 77, 0.22);
  --shadow: 0 18px 40px rgba(65, 89, 54, 0.12);
}

:root[data-theme="dark"] {
  --bg: #101b18;
  --bg-soft: #152421;
  --card: rgba(23, 39, 35, 0.94);
  --card-strong: #1f342f;
  --text: #edf7e8;
  --muted: #b2c7b4;
  --primary: #67c487;
  --primary-dark: #4aa56b;
  --accent: #f0cf58;
  --accent-soft: #4a4217;
  --danger: #ff8f79;
  --success: #98ebae;
  --border: rgba(190, 220, 194, 0.16);
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(215, 185, 62, 0.32), transparent 30%),
    radial-gradient(circle at top right, rgba(31, 122, 83, 0.18), transparent 28%),
    linear-gradient(180deg, #f9f5dc 0%, var(--bg) 55%, #eef4d2 100%);
  min-height: 100vh;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(240, 207, 88, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(87, 176, 121, 0.14), transparent 24%),
    linear-gradient(180deg, #12211e 0%, var(--bg) 58%, #0b1412 100%);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: linear-gradient(135deg, #275f44 0%, #2f8658 52%, #d7b93e 100%);
  color: #fffef4;
  box-shadow: 0 10px 28px rgba(25, 63, 45, 0.2);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.topbar h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 28px);
  letter-spacing: 0.02em;
}
.user-block { display: flex; gap: 12px; align-items: center; }
.theme-toggle {
  width: auto;
  min-width: 104px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fffef4;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.18s ease, border-color 0.2s ease;
}
.theme-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
}
.theme-toggle[aria-pressed="true"] {
  background: rgba(23, 32, 29, 0.52);
  border-color: rgba(240, 207, 88, 0.42);
}
.container { max-width: 1200px; margin: 28px auto; padding: 0 18px 28px; }
.card {
  background: linear-gradient(180deg, var(--card) 0%, rgba(255, 248, 214, 0.96) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
:root[data-theme="dark"] .card {
  background: linear-gradient(180deg, rgba(24, 38, 34, 0.98) 0%, rgba(18, 31, 28, 0.98) 100%);
}
.card.narrow { max-width: 450px; margin-left: auto; margin-right: auto; }
.card.small { min-height: 100px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.links { display: flex; gap: 10px; flex-wrap: wrap; }
input, select, textarea, button, label {
  width: 100%;
  display: block;
  margin-top: 6px;
  margin-bottom: 10px;
}
input, select, textarea {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 252, 239, 0.95);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: rgba(15, 26, 23, 0.95);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(31, 122, 83, 0.55);
  box-shadow: 0 0 0 4px rgba(215, 185, 62, 0.18);
  background: #fffdf2;
}
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  background: rgba(19, 34, 30, 1);
  border-color: rgba(103, 196, 135, 0.52);
  box-shadow: 0 0 0 4px rgba(240, 207, 88, 0.14);
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form input, .inline-form select, .inline-form label, .inline-form button { width: auto; }
.password-field {
  position: relative;
  margin-bottom: 12px;
}
.password-field input {
  margin-bottom: 0;
  padding-right: 82px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 68px;
  margin: 0;
  padding: 7px 10px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #d7b93e 0%, #efcf58 100%);
  color: #28402d;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
}
:root[data-theme="dark"] .password-toggle {
  color: #18261f;
}
.stacked-form { flex-direction: column; align-items: stretch; }
.stacked-form input, .stacked-form button { width: 100%; }
.compact-reset-form { width: 120px; min-width: 120px; max-width: 120px; gap: 6px; }
.compact-reset-form input {
  width: 100%;
  min-width: 0;
  max-width: 120px;
  margin-bottom: 6px;
  padding: 6px 8px;
}
.compact-reset-form button {
  align-self: stretch;
  width: 100%;
  padding: 7px 8px;
}
.compact-actions { gap: 6px; }
.compact-actions .btn { width: auto; min-width: 88px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.action-row .btn { width: auto; }
.action-cell { min-width: 188px; }
.company-group-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.company-group {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 252, 232, 0.78);
  overflow: hidden;
}
:root[data-theme="dark"] .company-group {
  background: rgba(18, 31, 28, 0.92);
}
.company-group summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255, 241, 175, 0.95) 0%, rgba(246, 227, 131, 0.9) 100%);
  color: #21402d;
  font-weight: 700;
}
:root[data-theme="dark"] .company-group summary {
  background: linear-gradient(180deg, rgba(56, 83, 64, 0.98) 0%, rgba(43, 66, 51, 0.98) 100%);
  color: #eef7e8;
}
.company-group summary::-webkit-details-marker {
  display: none;
}
.company-group summary::after {
  content: "+";
  font-size: 20px;
  line-height: 1;
}
.company-group[open] summary::after {
  content: "-";
}
.company-meta {
  color: #47624c;
  font-size: 14px;
  font-weight: 600;
}
:root[data-theme="dark"] .company-meta {
  color: #b7cbb8;
}
.company-group .table-wrap {
  padding: 10px 10px 12px;
}
.staff-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.staff-hero {
  padding: 24px;
}
.staff-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: #57724d;
}
.staff-date-chip {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 241, 175, 0.88);
  border: 1px solid rgba(93, 120, 77, 0.18);
  font-weight: 700;
  color: #28412e;
  white-space: nowrap;
}
.staff-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.staff-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(247, 251, 224, 0.92);
  border: 1px solid rgba(93, 120, 77, 0.18);
  color: #29412e;
  font-weight: 600;
}
.staff-status-card {
  padding: 18px;
  border-radius: 20px;
  margin-bottom: 14px;
  background: linear-gradient(145deg, rgba(35, 108, 71, 0.95) 0%, rgba(65, 145, 92, 0.9) 100%);
  color: #fffcef;
  box-shadow: 0 16px 34px rgba(31, 122, 83, 0.2);
}
.staff-status-card .eyebrow,
.staff-status-card h3,
.staff-status-card .staff-status-meta {
  color: inherit;
}
.staff-status-card h3 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.2vw, 34px);
}
.staff-status-meta {
  margin: 0;
  opacity: 0.92;
}
.staff-check-card {
  padding: 18px;
  border-radius: 20px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(244, 249, 220, 0.98) 0%, rgba(255, 244, 188, 0.88) 100%);
  border: 1px solid rgba(93, 120, 77, 0.18);
}
.staff-check-header h3 {
  margin: 0 0 14px;
}
.staff-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.mini-check {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 251, 232, 0.88);
  border: 1px solid rgba(93, 120, 77, 0.16);
}
.mini-check-label {
  display: block;
  margin-bottom: 6px;
  color: #5e715c;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.staff-action-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.staff-action-btn {
  min-height: 54px;
  font-size: 18px;
  border-radius: 16px;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}
.kpi-stack {
  display: grid;
  grid-template-columns: 1.45fr repeat(2, minmax(220px, 1fr));
  gap: 14px;
  align-items: stretch;
}
.kpi-card {
  min-height: 168px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(215, 185, 62, 0.18), transparent 42%);
  pointer-events: none;
}
.kpi-card > * {
  position: relative;
  z-index: 1;
}
.kpi-card-primary {
  background: linear-gradient(145deg, rgba(35, 108, 71, 0.96) 0%, rgba(61, 136, 87, 0.92) 65%, rgba(225, 196, 82, 0.92) 100%);
  color: #fffbea;
}
:root[data-theme="dark"] .kpi-card-primary {
  background: linear-gradient(145deg, rgba(39, 93, 63, 0.98) 0%, rgba(31, 70, 49, 0.98) 58%, rgba(166, 141, 49, 0.95) 100%);
}
.kpi-card-primary .kpi-label,
.kpi-card-primary .kpi-note,
.kpi-card-primary .stat {
  color: inherit;
}
.kpi-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #32513d;
}
.kpi-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.detail-row td {
  background: rgba(246, 250, 221, 0.95);
  padding: 0;
}
:root[data-theme="dark"] .detail-row td {
  background: rgba(20, 33, 29, 0.98);
}
.detail-panel {
  padding: 16px;
  background: linear-gradient(180deg, rgba(251, 247, 209, 0.98) 0%, rgba(241, 248, 213, 0.98) 100%);
}
:root[data-theme="dark"] .detail-panel {
  background: linear-gradient(180deg, rgba(24, 40, 35, 0.98) 0%, rgba(18, 31, 28, 0.98) 100%);
}
.detail-panel h4 {
  margin: 0 0 12px;
  color: #24402e;
}
:root[data-theme="dark"] .detail-panel h4 {
  color: #edf7e8;
}
.detail-panel-narrow {
  max-width: 420px;
}
.detail-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.detail-form-grid > div,
.detail-actions {
  min-width: 0;
}
.checkbox-field {
  display: flex;
  align-items: center;
}
.checkbox-field label {
  margin: 0;
}
.detail-actions {
  display: flex;
  align-items: end;
}
.reset-inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}
.reset-inline-form input {
  flex: 1 1 220px;
  margin-bottom: 0;
}
.reset-inline-form .btn {
  width: auto;
}
.btn {
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, #2f8e61 100%);
  color: #fffef4;
  padding: 10px 15px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(31, 122, 83, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(31, 122, 83, 0.24); }
.btn-sm { padding: 7px 10px; font-size: 13px; }
.btn-secondary {
  background: linear-gradient(135deg, #b89a26 0%, #d7b93e 100%);
  color: #23351f;
  box-shadow: 0 8px 18px rgba(183, 154, 38, 0.2);
}
:root[data-theme="dark"] .btn-secondary {
  color: #18261f;
}
.alert { padding: 10px; border-radius: 6px; }
.alert.error { background: #fde6de; color: var(--danger); border: 1px solid rgba(166, 61, 42, 0.18); }
.alert.success { background: #e0f2dd; color: var(--success); border: 1px solid rgba(22, 91, 63, 0.18); }
:root[data-theme="dark"] .alert.error {
  background: rgba(92, 35, 28, 0.72);
  border-color: rgba(255, 143, 121, 0.3);
}
:root[data-theme="dark"] .alert.success {
  background: rgba(28, 69, 45, 0.72);
  border-color: rgba(152, 235, 174, 0.26);
}
.muted-text { color: var(--muted); font-size: 14px; }
.status-box {
  background: linear-gradient(180deg, rgba(232, 246, 211, 0.95) 0%, rgba(251, 240, 186, 0.72) 100%);
  border: 1px solid rgba(76, 122, 76, 0.22);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
:root[data-theme="dark"] .status-box {
  background: linear-gradient(180deg, rgba(32, 57, 45, 0.95) 0%, rgba(67, 63, 29, 0.74) 100%);
  border-color: rgba(181, 210, 170, 0.18);
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  min-width: 760px;
}
.table-wrap { overflow-x: auto; }
th, td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  background: rgba(255, 251, 232, 0.8);
}
:root[data-theme="dark"] th,
:root[data-theme="dark"] td {
  background: rgba(18, 31, 28, 0.94);
}
th {
  background: linear-gradient(180deg, #fff1af 0%, #f6e383 100%);
  color: #24402e;
  font-weight: 700;
}
:root[data-theme="dark"] th {
  background: linear-gradient(180deg, rgba(78, 94, 47, 0.98) 0%, rgba(57, 73, 38, 0.98) 100%);
  color: #eef7e8;
}
.reset-password-cell { min-width: 132px; width: 132px; }
.stat { font-size: 24px; font-weight: 700; margin: 0; }

h2, h3 {
  margin-top: 0;
  color: #183226;
}
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3 {
  color: #f1f8ee;
}

label {
  font-weight: 600;
  color: #264031;
}
:root[data-theme="dark"] label,
:root[data-theme="dark"] .kpi-label,
:root[data-theme="dark"] .mini-check-label,
:root[data-theme="dark"] .eyebrow {
  color: #c6d9c7;
}

@media (max-width: 768px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }

  .user-block {
    flex-wrap: wrap;
  }

  .container {
    margin: 18px auto;
    padding: 0 12px 24px;
  }

  .card {
    border-radius: 16px;
    padding: 16px;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form input,
  .inline-form select,
  .inline-form label,
  .inline-form button {
    width: 100%;
  }

  .compact-reset-form,
  .compact-reset-form input,
  .compact-reset-form button {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .reset-password-cell {
    min-width: 180px;
    width: 180px;
  }

  .detail-form-grid,
  .reset-inline-form {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .kpi-stack {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: 140px;
  }

  .staff-hero {
    padding: 18px;
  }

  .staff-hero-top {
    flex-direction: column;
    align-items: stretch;
  }

  .staff-date-chip {
    align-self: flex-start;
  }

  .staff-check-grid {
    grid-template-columns: 1fr;
  }

  .staff-action-bar {
    grid-template-columns: 1fr;
  }

  .staff-action-btn {
    width: 100%;
  }

  .company-group summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .reset-inline-form .btn,
  .compact-actions .btn {
    width: 100%;
  }

  table {
    min-width: 640px;
    font-size: 14px;
  }

  .btn {
    min-height: 42px;
  }

  .password-toggle {
    width: 64px;
    padding: 7px 8px;
  }
}
