:root {
  --brand: #4b3d98;
  --brand-deep: #2f285d;
  --brand-soft: #f1effb;
  --brand-pale: #f8f7fc;
  --text: #242238;
  --muted: #77758b;
  --line: #e8e6ef;
  --white: #fff;
  --sidebar: 270px;
  --topbar: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--white);
  color: var(--text);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  background: #fff;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 3px 16px rgba(39, 33, 81, 0.04);
}

.mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--brand);
  background: #fff;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  width: 45px;
  height: 48px;
  flex: none;
  margin-right: 11px;
  object-fit: contain;
  clip-path: inset(0 0 19% 0);
  transform: scale(1.13);
  transform-origin: center 42%;
}

.brand-copy {
  line-height: 1.08;
}

.brand-name {
  color: #18162c;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 5px;
  color: var(--brand);
  font-family: Arial, sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.topbar-actions {
  position: relative;
  margin-left: auto;
}

.profile {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  transition: 0.18s ease;
}

.profile:hover {
  border-color: #cbc6e6;
  background: var(--brand-pale);
}

.profile[aria-expanded="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(75, 61, 152, 0.12);
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
}

.avatar svg {
  width: 19px;
  height: 19px;
}

.profile-copy {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.profile-name {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
}

.profile-role {
  color: var(--muted);
  font-size: 10.5px;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 224px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(35, 29, 72, 0.16);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;
}

.profile-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-menu-user {
  padding: 10px 11px 12px;
}

.profile-menu-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.profile-menu-role {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.logout-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border: 0;
  border-top: 1px solid var(--line);
  color: #d3463e;
  background: #fff;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease;
}

.logout-button:hover {
  background: #fff5f4;
}

.sidebar {
  position: fixed;
  z-index: 15;
  top: var(--topbar);
  bottom: 0;
  left: 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.menu-label {
  padding: 0 13px;
  margin: 0 0 10px;
  color: #a09caf;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-section-title {
  margin: 17px 13px 5px;
  color: #858097;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.nav-section-title:first-of-type {
  margin-top: 12px;
}

.nav-item.compact {
  min-height: 44px;
  padding-left: 14px;
  font-size: 13.5px;
  font-weight: 600;
}

.nav-item.compact .nav-icon {
  width: 20px;
  height: 20px;
}

.nav-item.compact.active {
  min-height: 46px;
  font-weight: 800;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-group-toggle {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  border: 0;
  border-radius: 11px;
  color: #4d495f;
  background: transparent;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.nav-group-toggle:hover,
.nav-group-toggle[aria-expanded="true"] {
  color: var(--brand);
  background: #faf9fd;
}

.nav-group-toggle .chevron {
  flex: none;
  transition: transform 0.2s ease;
}

.nav-group-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.nav-submenu {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 5px 22px;
  padding-left: 12px;
}

.nav-submenu::before {
  content: "";
  position: absolute;
  inset: 3px auto 3px 0;
  width: 1px;
  background: var(--line);
}

.nav-submenu[hidden] {
  display: none;
}

.nav-submenu .nav-item {
  min-height: 37px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
}

.nav-submenu .nav-item::before {
  left: -13px;
  width: 3px;
  height: 17px;
}

.nav-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: #bbb7c8;
}

.nav-item.active .nav-dot {
  background: var(--brand);
}

.nav-item {
  position: relative;
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  color: #605d70;
  background: transparent;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.nav-item:hover {
  color: var(--brand);
  background: var(--brand-pale);
  transform: translateX(2px);
}

.nav-item.active {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 700;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 4px;
  height: 22px;
  border-radius: 0 5px 5px 0;
  background: var(--brand);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-text {
  flex: 1;
}

.menu-count {
  min-width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--brand);
  background: #e3def7;
  font-size: 10px;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 12px 3px;
  border-top: 1px solid var(--line);
  color: #aaa6b7;
  font-size: 10.5px;
  line-height: 1.55;
}

.main {
  min-height: 100vh;
  margin-left: var(--sidebar);
  padding: calc(var(--topbar) + 36px) 38px 38px;
  background: #fff;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: #9691a5;
  font-size: 12px;
  font-weight: 600;
}

.breadcrumb-link {
  padding: 0;
  border: 0;
  color: #8f899d;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.breadcrumb-link:hover {
  color: #5f586d;
  text-decoration: underline;
}

.breadcrumb-separator {
  color: #aaa5b4;
}

.breadcrumb-current {
  color: var(--brand);
}

.page-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.page-heading-row[hidden] {
  display: none;
}

.primary-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(75, 61, 152, 0.18);
}

.primary-button:hover {
  background: var(--brand-deep);
}

.primary-button[hidden] {
  display: none;
}

.primary-button svg {
  width: 18px;
  height: 18px;
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.page-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.required {
  color: #d34f48;
}

.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #d9d5e2;
  border-radius: 10px;
  color: #5f5a6d;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.content-placeholder {
  min-height: 330px;
  display: grid;
  place-items: center;
  margin-top: 30px;
  border: 1px dashed #dcd8e9;
  border-radius: 18px;
  color: #a09caf;
  background: linear-gradient(145deg, #fff 0%, #fbfaff 100%);
  text-align: center;
}

.content-placeholder[hidden] {
  display: none;
}

.content-placeholder strong {
  display: block;
  margin-bottom: 5px;
  color: #656176;
  font-size: 14px;
}

.content-placeholder span {
  font-size: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns:
    minmax(250px, 1.35fr) minmax(170px, 0.7fr) minmax(150px, 0.65fr)
    minmax(270px, 1.15fr);
  gap: 10px;
  margin-bottom: 14px;
}

.filter-field {
  position: relative;
  min-width: 0;
}

.filter-field svg {
  position: absolute;
  z-index: 1;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: #817b91;
  transform: translateY(-50%);
  pointer-events: none;
}

.filter-control {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid #ddd9e6;
  border-radius: 12px;
  outline: none;
  color: #3f3b4e;
  background: #fff;
  font: inherit;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.filter-field.has-icon .filter-control {
  padding-left: 40px;
}

.filter-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(75, 61, 152, 0.1);
}

select.filter-control {
  cursor: pointer;
}

.date-range {
  position: relative;
}

.date-range-button {
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.date-range-button strong {
  color: var(--brand);
  font-weight: 700;
}

.date-range-button svg {
  position: static;
  width: 18px;
  height: 18px;
  margin-left: auto;
  transform: none;
  color: #655f72;
}

.date-range-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  right: 0;
  width: 340px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 13px;
  border: 1px solid #ddd9e6;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(35, 29, 72, 0.15);
}

.date-range-popover[hidden] {
  display: none;
}

.date-range-popover label {
  color: #777283;
  font-size: 11px;
  font-weight: 700;
}

.date-range-popover input {
  margin-top: 6px;
}

.table-card {
  overflow: hidden;
  border: 1px solid #e2dfe9;
  border-radius: 15px;
  background: #fff;
}

.table-scroll {
  overflow-x: auto;
}

.user-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
}

.user-table th {
  padding: 13px 14px;
  color: #625d70;
  background: #f6f4f9;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.user-table td {
  padding: 14px;
  border-top: 1px solid #ece9f1;
  color: #393647;
  font-size: 12.5px;
  vertical-align: middle;
  white-space: nowrap;
}

.user-table tbody tr:hover {
  background: #fcfbff;
}

.user-table .number {
  width: 58px;
  text-align: center;
  color: #858091;
}

.employee-id {
  color: var(--brand);
  font-weight: 700;
}

.person-name {
  font-weight: 700;
  color: #282536;
}

.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.role-badge {
  color: #514790;
  background: #efecfa;
}

.status-active {
  color: #24734b;
  background: #e8f6ee;
}

.status-inactive {
  color: #8a6670;
  background: #f2edf0;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #ded9eb;
  border-radius: 9px;
  color: var(--brand);
  background: #fff;
  cursor: pointer;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.action-button:hover {
  border-color: #bcb3dd;
  background: var(--brand-soft);
}

.action-button.delete {
  color: #c84545;
  border-color: #efd2d2;
}

.action-button.delete:hover {
  background: #fff0f0;
}

.action-button svg {
  width: 16px;
  height: 16px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 15px;
  border-top: 1px solid #e9e6ee;
  color: #777283;
  font-size: 12px;
}

.clear-filter {
  border: 0;
  color: var(--brand);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.empty-row td {
  padding: 48px 20px;
  color: #8e899a;
  text-align: center;
}

.table-footer-actions,
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-size {
  width: 62px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid #ddd9e6;
  border-radius: 9px;
  color: #413d4c;
  background: #fff;
}

.page-button {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  color: #413d4c;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.page-button:hover:not(:disabled) {
  background: var(--brand-soft);
  color: var(--brand);
}

.page-button.active {
  color: #fff;
  background: var(--brand);
}

.page-button:disabled {
  color: #c8c4cf;
  cursor: default;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  display: inline-block;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #dcd8e5;
  cursor: pointer;
  transition: 0.2s;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: 0.2s;
}

.switch input:checked + span {
  background: #208a56;
}

.switch input:checked + span::after {
  transform: translateX(16px);
}

.overlay {
  display: none;
}
