:root {
  --ink: #132238;
  --muted: #667085;
  --line: #dce6ec;
  --panel: rgba(255, 255, 255, 0.96);
  --green: #0f4f46;
  --green-2: #176b5d;
  --blue: #2563eb;
  --cyan: #0891b2;
  --orange: #f59e0b;
  --red: #dc2626;
  --shadow: 0 20px 60px rgba(15, 38, 56, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(135deg, rgba(245, 250, 246, .82) 0%, rgba(236, 246, 241, .78) 48%, rgba(244, 249, 246, .84) 100%),
    url("/assets/forest-background.jpg") center top / cover fixed;
  background-color: #eef7f1;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    repeating-radial-gradient(ellipse at 14% 18%, transparent 0 28px, rgba(15, 79, 70, 0.12) 29px 30px),
    repeating-radial-gradient(ellipse at 86% 64%, transparent 0 34px, rgba(85, 129, 65, 0.12) 35px 36px);
}

body::after {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  z-index: 0;
  height: 38vh;
  pointer-events: none;
  background:
    linear-gradient(0deg, rgba(21, 77, 49, .22), rgba(21, 77, 49, 0)),
    url("/assets/grassland-background.jpg") center bottom / cover no-repeat;
  opacity: .24;
  mask-image: linear-gradient(0deg, #000 0%, rgba(0,0,0,.82) 45%, transparent 100%);
}

.is-hidden {
  display: none !important;
}

.attachment-preview {
  color: var(--green-2);
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  display: grid;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-width: 0;
  flex-direction: column;
  height: 100vh;
  padding: 22px;
  color: #fff;
  background: linear-gradient(180deg, rgba(15, 79, 70, 0.98), rgba(12, 58, 64, 0.98));
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}

.brand-mark {
  display: grid;
  flex: 0 0 60px;
  width: 60px;
  height: 60px;
  place-items: center;
  border-radius: 0;
  background: transparent;
}

.company-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.brand > div:last-child {
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
  text-wrap: balance;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,.68);
  font-size: 12px;
}

.nav {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 8px;
  flex: 1;
  margin-top: 24px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-color: rgba(255,255,255,.42) rgba(255,255,255,.08);
  scrollbar-width: thin;
}

.nav::-webkit-scrollbar {
  width: 8px;
}

.nav::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(255,255,255,.08);
}

.nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255,255,255,.34);
}

.nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.52);
}

.nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  background: transparent;
  color: rgba(255,255,255,.76);
  text-align: left;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}

.nav button span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.1);
}

.nav button:hover,
.nav button.active {
  background: rgba(255,255,255,.13);
  color: #fff;
  transform: translateX(4px);
}

.sidebar-note {
  flex: 0 0 auto;
  margin-top: 26px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.76);
  font-size: 12px;
  line-height: 1.7;
}

.main {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 22px 28px 36px;
}

.topbar,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 28px;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.topbar p,
.section-heading p,
.muted {
  color: var(--muted);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 12px 30px rgba(15, 38, 56, .08);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--green), var(--cyan));
  color: #fff;
  font-weight: 800;
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  color: var(--muted);
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  min-width: 0;
}

.view.fly-in {
  animation: fly-in-page .32s cubic-bezier(.2, .8, .2, 1);
}

@keyframes fly-in-page {
  from {
    opacity: 0;
    transform: translateY(18px) scale(.985);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 245px;
  padding: 30px;
  border-radius: 14px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(10, 61, 38, .82), rgba(15, 85, 57, .7) 48%, rgba(19, 94, 111, .56)),
    url("/assets/hero-forest.jpg") center / cover no-repeat;
  box-shadow: var(--shadow);
}

.hero-card::before {
  content: "";
  position: absolute;
  right: 24px;
  top: 22px;
  width: 150px;
  height: 110px;
  opacity: .28;
  background:
    radial-gradient(ellipse at 28% 58%, rgba(205, 245, 210, .72) 0 16%, transparent 17%),
    radial-gradient(ellipse at 48% 44%, rgba(205, 245, 210, .7) 0 15%, transparent 16%),
    radial-gradient(ellipse at 67% 55%, rgba(205, 245, 210, .68) 0 14%, transparent 15%),
    linear-gradient(75deg, transparent 47%, rgba(218, 255, 217, .55) 48% 52%, transparent 53%);
  transform: rotate(-8deg);
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -120px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 48% 52% 43% 57%;
  box-shadow:
    -26px -24px 0 rgba(255,255,255,.05),
    -54px -50px 0 rgba(255,255,255,.04),
    -82px -76px 0 rgba(255,255,255,.03);
}

.hero-card > * {
  position: relative;
  z-index: 1;
}

.hero-card h2 {
  max-width: 660px;
  font-size: 31px;
  line-height: 1.25;
}

.hero-card p {
  max-width: 670px;
  color: rgba(255,255,255,.78);
  line-height: 1.75;
}

.manager-dashboard-hero {
  margin-bottom: 18px;
}

.hero-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.panel,
.stat,
.module-card,
.item-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel,
.panel-body,
.stack {
  min-width: 0;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-title h3 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 18px 20px 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
}

.primary,
.soft,
.outline {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 10px;
  font-weight: 800;
}

.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .18);
}

.soft {
  background: rgba(255,255,255,.14);
  color: #fff;
}

.outline {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.primary,
.soft,
.outline,
.module-card,
.item-card,
.stat {
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.primary:hover,
.soft:hover,
.outline:hover {
  transform: translateY(-1px);
}

.primary:active,
.soft:active,
.outline:active {
  transform: translateY(0) scale(.98);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 27px;
}

.stat small {
  display: block;
  margin-top: 8px;
  color: var(--green-2);
  font-weight: 800;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 18px;
  align-items: start;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.active-tab {
  border-color: rgba(37, 99, 235, 0.45);
  background: #dbeafe;
  color: #1e40af;
}

.department-detail {
  margin-top: 18px;
}

.department-detail.attendance-report-mode {
  grid-template-columns: minmax(0, 1fr);
}

.attendance-report-toolbar {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.attendance-report-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.attendance-report-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.attendance-report-stats article {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.attendance-report-stats article:last-child {
  border-right: 0;
}

.attendance-report-stats span,
.attendance-report-stats strong {
  display: block;
}

.attendance-report-stats span {
  color: var(--muted);
  font-size: 13px;
}

.attendance-report-stats strong {
  margin-top: 7px;
  font-size: 22px;
}

.attendance-report-section + .attendance-report-section {
  margin-top: 24px;
}

.attendance-report-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.attendance-report-heading h4 {
  margin: 0;
  font-size: 16px;
}

.attendance-report-heading span {
  color: var(--muted);
  font-size: 13px;
}

.attendance-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.attendance-table-wrap table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

.attendance-table-wrap th,
.attendance-table-wrap td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.attendance-table-wrap th {
  background: #f1f5f9;
  color: #475569;
  font-weight: 800;
}

.attendance-table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.attendance-table-wrap td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.module-card {
  min-height: 150px;
  padding: 16px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.glow-card::before,
.module-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(37, 99, 235, .10), transparent);
  transform: translateX(-120%);
  transition: transform .45s ease;
}

.module-card:hover::before {
  transform: translateX(120%);
}

.lift:hover {
  transform: translateY(-5px);
  border-color: rgba(37, 99, 235, .35);
  box-shadow: 0 22px 45px rgba(15, 38, 56, .16);
}

.module-tab:hover {
  background: #eef6ff;
  border-color: rgba(37, 99, 235, .38);
}

.user-card {
  cursor: pointer;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.manager-password-dialog {
  width: min(420px, calc(100% - 28px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.manager-password-dialog::backdrop {
  background: rgba(15, 38, 56, .4);
}

.manager-password-dialog form {
  display: grid;
  gap: 12px;
}

.manager-password-dialog h2,
.manager-password-dialog p {
  margin: 0;
}

.manager-password-dialog input {
  width: 100%;
}

.manager-password-dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#managerPasswordError {
  color: #ad3030;
}

.portal-switch-button {
  position: relative;
  flex: 0 0 auto;
  width: max-content;
  white-space: nowrap;
}

.portal-switch-button::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 30;
  left: 50%;
  top: calc(100% + 9px);
  width: max-content;
  max-width: 180px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #173e38;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity .16s ease, transform .16s ease;
  white-space: nowrap;
}

.portal-switch-button:hover::after,
.portal-switch-button:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.logout-button {
  min-height: 40px;
  white-space: nowrap;
}

.permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.permission-edit-grid {
  margin: 12px 0;
}

.permission-search {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 16px;
}

.permission-search label {
  flex: 1 1 280px;
  min-width: 0;
  max-width: 440px;
}

.permission-search .muted {
  padding-bottom: 8px;
}

.save-user {
  margin-top: 12px;
}

.permission-chips label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.color-stat {
  overflow: hidden;
  position: relative;
}

.color-stat::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  opacity: .16;
}

.green-stat::after { background: #16a34a; }
.blue-stat::after { background: #2563eb; }
.orange-stat::after { background: #f59e0b; }
.cyan-stat::after { background: #0891b2; }

.module-card h4,
.item-card h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.module-card p,
.item-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.module-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: #e8f7f3;
  color: var(--green);
  font-size: 19px;
  font-weight: 900;
}

.module-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.item-card {
  padding: 14px;
  box-shadow: none;
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.record-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.record-fields div {
  padding: 10px;
  border: 1px solid #edf2f5;
  border-radius: 10px;
  background: #f8fafc;
}

.record-fields span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.record-fields strong {
  display: block;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.field-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #edf2f5;
  font-size: 14px;
}

.field-row span {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #b7c0ce;
  opacity: 1;
}

input[readonly],
textarea[readonly] {
  background: #f5f8fb;
  color: #5d6b7c;
}

input[type="file"] {
  padding: 8px 10px;
  color: #5d6b7c;
}

.upload-dropzone {
  gap: 8px;
  min-height: 112px;
  padding: 18px;
  border: 1px dashed #9db4c8;
  border-radius: 10px;
  background: #f8fbfd;
  color: var(--ink);
}

.upload-dropzone span {
  color: #9aa7b6;
  font-weight: 700;
}

.upload-dropzone input[type="file"] {
  border: 0;
  background: transparent;
  padding: 0;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  background: #dbeafe;
  color: #1e40af;
}

.tag.orange {
  background: #fef3c7;
  color: #92400e;
}

.tag.green {
  background: #dcfce7;
  color: #166534;
}

.tag.red {
  background: #fee2e2;
  color: #991b1b;
}

.progress {
  height: 8px;
  border-radius: 99px;
  background: #e5edf2;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-2), var(--blue));
}

.empty {
  padding: 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .shell,
  .hero-grid,
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
  }

  .main {
    width: 100%;
    min-width: 0;
  }

  .nav {
    overflow: visible;
    padding-right: 0;
  }

  .nav,
  .stats,
  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .attendance-report-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attendance-report-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attendance-report-stats article:nth-child(2) {
    border-right: 0;
  }

  .attendance-report-stats article:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .sidebar {
    padding: 14px;
  }

  .sidebar .brand {
    padding-bottom: 12px;
  }

  .sidebar .nav {
    display: flex;
    grid-template-columns: none;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 4px;
    scrollbar-width: thin;
  }

  .sidebar .nav button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding: 9px 12px;
  }

  .sidebar .sidebar-note {
    display: none;
  }

  .main {
    padding: 18px 14px 28px;
  }

  .topbar,
  .section-heading {
    display: grid;
  }

  .top-actions {
    min-width: 0;
    flex-wrap: wrap;
  }

  .top-actions .user-card {
    min-width: 0;
  }

  .nav,
  .stats,
  .module-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .attendance-report-toolbar,
  .attendance-report-stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .attendance-report-toolbar input,
  .attendance-report-toolbar select {
    min-width: 0;
  }

  .attendance-report-toolbar button {
    width: 100%;
  }

  .attendance-report-stats article,
  .attendance-report-stats article:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .attendance-report-stats article:last-child {
    border-bottom: 0;
  }
}
