:root {
  --bg: #eef4fb;
  --panel: rgba(255, 255, 255, 0.9);
  --text: #16233a;
  --muted: #66758a;
  --line: rgba(190, 207, 226, 0.92);
  --primary: #1f5fbf;
  --primary-dark: #174a96;
  --soft: #e9f2ff;
  --navy: #173a5e;
  --gold: #a98a59;
  --shadow: 0 18px 44px rgba(23, 58, 94, 0.08);
  --success: #0f766e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(246, 250, 254, 0.9), rgba(227, 236, 247, 0.84)),
    var(--bg);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(244, 249, 254, 0.24), rgba(238, 244, 251, 0.72)),
    url("/static/images/system-premium-bg.png") center center / cover no-repeat;
  opacity: 0.96;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(10, 35, 66, 0.08), rgba(255, 255, 255, 0.1) 28%, rgba(233, 240, 248, 0.5) 100%);
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 13px 22px;
  background: linear-gradient(135deg, rgba(18, 47, 82, 0.94), rgba(25, 72, 120, 0.9));
  border-bottom: 1px solid rgba(211, 185, 134, 0.36);
  box-shadow: 0 14px 32px rgba(8, 32, 58, 0.18);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  min-width: 0;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand img {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
}

.topbar nav {
  position: absolute;
  top: calc(100% + 8px);
  right: 22px;
  display: none;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 8px;
  width: min(330px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid rgba(214, 226, 240, 0.6);
  border-radius: 8px;
  background: rgba(24, 59, 96, 0.96);
  box-shadow: 0 18px 34px rgba(8, 32, 58, 0.22);
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  backdrop-filter: blur(16px);
}

.topbar.is-menu-open nav {
  display: grid;
}

.topbar nav a,
.topbar nav form,
.nav-button {
  width: 100%;
}

.topbar nav a,
.nav-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  text-align: center;
  white-space: nowrap;
}

.topbar nav a:hover,
.nav-button:hover {
  color: #fff;
}

.topbar form {
  margin: 0;
}

.nav-button {
  font: inherit;
  cursor: pointer;
}

.menu-toggle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.menu-toggle:hover,
.topbar.is-menu-open .menu-toggle {
  background: rgba(255, 255, 255, 0.18);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px 18px 56px;
}

.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, rgba(169, 138, 89, 0.88), rgba(31, 95, 191, 0.58), rgba(15, 118, 110, 0.42));
}

.welcome {
  display: grid;
  gap: 22px;
  min-height: calc(100vh - 120px);
  align-content: center;
  padding: 38px 0 56px;
}

.welcome-logo {
  width: min(620px, 68vw);
  margin: 0 auto;
  filter: drop-shadow(0 12px 24px rgba(23, 58, 94, 0.1));
}

.welcome-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.welcome h1 {
  width: min(820px, 100%);
  margin: 0 auto;
  text-align: center;
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 900;
  color: #102039;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.82);
}

.welcome-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.welcome-secondary {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.secondary-module-link {
  min-width: 260px;
  min-height: 82px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 18px 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8a6a3d, #c4a064);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(194, 65, 12, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.secondary-module-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(194, 65, 12, 0.28);
  filter: saturate(1.04);
}

.module-card {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  text-align: center;
  box-shadow: 0 20px 46px rgba(23, 58, 94, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.22);
  filter: saturate(1.04);
}

.module-attendance {
  background:
    linear-gradient(135deg, rgba(15, 107, 104, 0.94), rgba(56, 182, 167, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent);
}

.module-duty {
  background:
    linear-gradient(135deg, rgba(23, 58, 94, 0.96), rgba(74, 143, 216, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent);
}

.module-night-duty {
  background:
    linear-gradient(135deg, rgba(117, 68, 28, 0.96), rgba(194, 128, 52, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent);
}

.module-card span {
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 900;
}

.panel.narrow {
  max-width: 440px;
  margin-inline: auto;
}

.narrow-panel {
  max-width: 680px;
  margin-inline: auto;
}

.staff-self-form {
  display: grid;
  gap: 14px;
}

.staff-self-form label small {
  margin-left: 6px;
  color: #b91c1c;
  font-size: 12px;
}

.staff-self-list {
  display: grid;
  gap: 12px;
}

.staff-self-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.staff-self-accordion {
  padding: 0;
  gap: 0;
}

.staff-self-accordion[open] {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 30px rgba(23, 58, 94, 0.08);
}

.staff-self-summary {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.staff-self-summary::-webkit-details-marker {
  display: none;
}

.staff-self-summary::after {
  content: "";
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.staff-self-accordion[open] .staff-self-summary::after {
  transform: rotate(225deg);
}

.staff-self-person {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.staff-self-person strong {
  color: var(--text);
  font-size: 17px;
}

.staff-self-open {
  margin-left: auto;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.staff-self-body {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.staff-self-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

h1,
h2 {
  margin: 0 0 16px;
  line-height: 1.25;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.compact-selector {
  grid-template-columns: minmax(180px, 260px) auto;
  justify-content: start;
}

.subtle {
  margin: -6px 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.form-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field-caption small {
  margin-left: 6px;
  color: #b91c1c;
  font-size: 12px;
}

select,
input,
textarea,
button,
.link-button {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

select,
input,
textarea {
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

select:focus,
input:focus,
textarea:focus {
  outline: 0;
  border-color: #89aee4;
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.12);
  background: #fff;
}

.file-picker-control {
  position: relative;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.file-picker-control input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-picker-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.file-picker-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

button,
.link-button {
  border: 0;
  padding: 0 16px;
  cursor: pointer;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(31, 95, 191, 0.18);
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
}

.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 700;
}

.small {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
}

.flash {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
}

.flash p {
  margin: 0;
}

.stack-form,
.inline-form,
.staff-add {
  display: grid;
  gap: 12px;
}

.inline-form {
  grid-template-columns: minmax(160px, 240px) auto;
  align-items: end;
}

.staff-add {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}

.staff-add button {
  min-width: 126px;
}

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

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.data-table select,
.data-table input {
  min-height: 38px;
}

.file-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.upload-field {
  display: grid;
  gap: 8px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.upload-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.upload-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid rgba(31, 95, 191, 0.2);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(31, 95, 191, 0.95), rgba(26, 87, 170, 0.95));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(31, 95, 191, 0.14);
}

label.upload-button {
  display: inline-flex;
  gap: 0;
  color: #fff;
  font-size: 13px;
}

.upload-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty-inline {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

.staff-editor-list {
  display: grid;
  gap: 12px;
}

.staff-editor-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(215, 225, 236, 0.94);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(23, 58, 94, 0.05);
}

.staff-editor-main {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 0.9fr) minmax(120px, 0.8fr) minmax(108px, 0.65fr) minmax(92px, 0.55fr) auto;
  gap: 10px;
  align-items: end;
}

.field-control {
  display: block;
  min-width: 0;
}

.field-control.narrow {
  max-width: 126px;
}

.staff-editor-actions {
  align-items: end;
  justify-content: flex-end;
  padding-bottom: 1px;
}

.staff-extra-panel {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.staff-extra-panel summary {
  width: max-content;
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.staff-extra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.holiday-list {
  display: grid;
  gap: 12px;
}

.holiday-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.holiday-item p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.date-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.date-pills span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 13px;
}

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

.date-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.date-card {
  min-height: 116px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: left;
}

.date-card.has-staff {
  border-color: #9bbcfb;
  background: #f8fbff;
}

.date-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}

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

.avatar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #93c5fd;
  border-radius: 50%;
  background: var(--soft);
  color: #1e3a8a;
  font-weight: 700;
  font-size: 14px;
}

.empty-note {
  color: var(--muted);
  font-size: 14px;
}

.dialog {
  width: min(560px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.dialog form {
  padding: 16px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 24px;
}

.staff-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin: 16px 0;
  max-height: min(56vh, 460px);
  overflow: auto;
}

.staff-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.staff-option input {
  width: 18px;
  height: 18px;
}

.staff-code {
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.panel-heading,
.summary-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-actions form {
  margin: 0;
}

.summary-card {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card strong {
  display: block;
}

.summary-card-head {
  margin-bottom: 8px;
}

.summary-card span {
  display: inline-flex;
  margin: 0 5px 6px 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 13px;
}

.summary-card span.done {
  background: #dcfce7;
  color: #166534;
}

.summary-detail-popover {
  position: absolute;
  z-index: 20;
  left: 12px;
  right: 12px;
  top: calc(100% - 4px);
  display: none;
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid #bfd3e8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.summary-card:hover .summary-detail-popover,
.summary-card:focus-within .summary-detail-popover {
  display: block;
}

.small-button {
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.danger {
  background: #dc2626;
  color: #fff;
}

.ghost-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.danger:hover,
.ghost-danger:hover {
  filter: brightness(0.96);
}

.helper-text,
.muted {
  color: var(--muted);
  font-size: 14px;
}

.night-duty-upload {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.special-night-duty-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(90px, 0.6fr)) minmax(180px, 1.2fr) minmax(120px, 0.8fr) auto;
  gap: 10px;
  align-items: end;
}

.special-night-duty-table {
  margin-top: 14px;
}

.special-night-duty-table form {
  margin: 0;
}

.night-duty-list {
  display: grid;
  gap: 10px;
}

.night-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.night-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.night-calendar-day {
  min-height: 126px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(166, 190, 220, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 18px rgba(23, 58, 94, 0.05);
}

.night-calendar-day:first-child {
  grid-column-start: var(--weekday);
}

.night-calendar-day.is-weekend {
  background: rgba(247, 251, 255, 0.94);
}

.night-calendar-date {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.night-calendar-date strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.night-calendar-date span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.night-calendar-people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.night-calendar-empty {
  color: #94a3b8;
  font-size: 13px;
}

.night-calendar-note {
  margin-top: 12px;
}

.night-duty-day {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.night-duty-date {
  display: grid;
  gap: 2px;
}

.night-duty-date strong {
  font-size: 20px;
}

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

.night-duty-people {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.night-duty-person {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 31px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f2ff;
  color: #174a96;
  font-weight: 800;
}

.night-duty-person.color-0 {
  background: #e0f2fe;
  color: #075985;
}

.night-duty-person.color-1 {
  background: #dcfce7;
  color: #166534;
}

.night-duty-person.color-2 {
  background: #fef3c7;
  color: #92400e;
}

.night-duty-person.color-3 {
  background: #fae8ff;
  color: #86198f;
}

.night-duty-person.color-4 {
  background: #ffe4e6;
  color: #9f1239;
}

.night-duty-person.color-5 {
  background: #ccfbf1;
  color: #115e59;
}

.night-duty-person.color-6 {
  background: #ede9fe;
  color: #5b21b6;
}

.night-duty-person.color-7 {
  background: #ffedd5;
  color: #9a3412;
}

.night-duty-person.color-8 {
  background: #dbeafe;
  color: #1e40af;
}

.night-duty-person.color-9 {
  background: #fce7f3;
  color: #9d174d;
}

.night-duty-person small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.night-duty-person.is-unmatched {
  background: #fee2e2;
  color: #991b1b;
}

.attendance-panel {
  display: grid;
  gap: 14px;
}

.attendance-entry-list {
  display: grid;
  gap: 12px;
}

.attendance-entry {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.entry-fields {
  display: grid;
  grid-template-columns: 1.1fr 0.85fr 1fr 76px 1.3fr auto;
  gap: 10px;
  align-items: end;
}

.full-month-option {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.full-month-option input {
  width: 18px;
  height: 18px;
}

.date-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.date-chip {
  display: block;
  color: var(--text);
}

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

.date-chip span {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 700;
}

.date-chip small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.date-chip input:checked + span {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.date-checkboxes.is-disabled {
  opacity: 0.58;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  body::before {
    background:
      linear-gradient(180deg, rgba(238, 245, 252, 0.16), rgba(238, 245, 252, 0.72) 62%, rgba(238, 245, 252, 0.9)),
      url("/static/images/system-premium-bg.png") 14% top / auto 100vh no-repeat;
    opacity: 1;
  }

  body::after {
    background:
      linear-gradient(180deg, rgba(11, 40, 72, 0.12), transparent 180px),
      linear-gradient(90deg, rgba(23, 58, 94, 0.08), transparent 58%);
  }

  .shell {
    padding: 14px 10px 38px;
  }

  .panel {
    background: rgba(255, 255, 255, 0.84);
    padding: 15px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 21px;
  }

  .selector {
    grid-template-columns: 1fr;
  }

  .welcome-actions {
    grid-template-columns: 1fr;
  }

  .secondary-module-link {
    width: 100%;
    min-width: 0;
    min-height: 68px;
    font-size: 20px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .staff-add,
  .inline-form,
  .staff-self-grid,
  .staff-editor-main,
  .entry-fields,
  .night-duty-upload,
  .special-night-duty-form,
  .night-duty-day {
    grid-template-columns: 1fr;
  }

  .night-calendar-weekdays {
    display: none;
  }

  .night-calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .night-calendar-day {
    min-height: 84px;
    gap: 7px;
    padding: 8px;
  }

  .night-calendar-day:first-child {
    grid-column-start: auto;
  }

  .night-calendar-date {
    display: grid;
    gap: 3px;
  }

  .night-calendar-date strong {
    font-size: 18px;
  }

  .night-calendar-date span {
    font-size: 11px;
  }

  .night-duty-person {
    min-height: 26px;
    padding: 3px 8px;
    font-size: 13px;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .field-control.narrow {
    max-width: none;
  }

  .staff-editor-actions {
    justify-content: flex-start;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px 12px;
    gap: 8px 10px;
  }

  .brand {
    width: auto;
    justify-content: flex-start;
    gap: 9px;
    font-size: 16px;
    line-height: 1.2;
  }

  .brand img {
    width: 28px;
    height: 28px;
  }

  .menu-toggle {
    min-height: 34px;
    padding: 0 13px;
    font-size: 14px;
  }

  .topbar nav {
    position: static;
    grid-column: 1 / -1;
    display: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    padding: 4px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 12px;
    backdrop-filter: none;
  }

  .topbar nav a,
  .nav-button {
    min-height: 34px;
    padding: 0 6px;
  }

  .welcome {
    min-height: calc(100vh - 92px);
    gap: 16px;
    align-content: start;
    padding-top: 18px;
  }

  .welcome-logo {
    width: min(86vw, 420px);
  }

  .welcome h1 {
    text-align: left;
    font-size: 28px;
  }

  .module-card {
    min-height: 136px;
  }

  .page-heading {
    align-items: center;
    margin-bottom: 10px;
  }

  .page-heading .ghost {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .date-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .date-card {
    min-height: 104px;
    padding: 12px;
  }

  .date-title {
    font-size: 19px;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }

  .dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 24px);
  }

  .staff-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 62vh;
  }

  .staff-option {
    padding: 9px;
    min-width: 0;
  }
}

@media (max-width: 340px) {
  .topbar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .night-calendar-grid,
  .date-grid,
  .staff-list {
    grid-template-columns: 1fr;
  }
}

/* 2026-06 brand alignment: visual-only overrides for the chlab portal refresh. */
:root {
  --brand-bg: #f6fbff;
  --brand-ink: #0b1527;
  --brand-blue: #1f6fff;
  --brand-green: #00a982;
  --brand-violet: #7657d9;
  --brand-line: rgba(33, 78, 126, 0.16);
  --brand-shadow: 0 22px 70px rgba(33, 74, 118, 0.15);
}

body {
  color: var(--brand-ink);
  background:
    linear-gradient(90deg, rgba(247, 252, 255, 0.96), rgba(237, 248, 255, 0.88)),
    url("/static/images/pharmacy-lab-bg-v2.png") 58% top / cover no-repeat fixed,
    var(--brand-bg);
}

body::before {
  background:
    linear-gradient(90deg, rgba(247, 252, 255, 0.96), rgba(247, 252, 255, 0.58) 56%, rgba(247, 252, 255, 0.2)),
    url("/static/images/pharmacy-lab-bg-v2.png") center top / cover no-repeat;
  opacity: 1;
}

body::after {
  background:
    linear-gradient(rgba(21, 72, 120, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 72, 120, 0.026) 1px, transparent 1px);
  background-size: 48px 48px;
}

.topbar {
  min-height: 60px;
  background: linear-gradient(135deg, rgba(8, 63, 114, 0.94), rgba(15, 76, 129, 0.9));
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 18px 42px rgba(8, 32, 58, 0.22);
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
}

.menu-toggle {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.topbar nav {
  border-color: rgba(190, 215, 245, 0.55);
  border-radius: 16px;
  background: rgba(10, 49, 88, 0.94);
}

.topbar nav a,
.nav-button {
  border-radius: 12px;
}

.shell {
  padding-top: 18px;
}

.panel {
  border-color: rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--brand-shadow);
}

.panel::before {
  height: 0;
}

.welcome {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(1120px, 100%);
  min-height: calc(100vh - 100px);
  margin-inline: auto;
}

.welcome-logo,
.welcome h1 {
  grid-column: 1 / -1;
}

.welcome-logo {
  width: min(560px, 68vw);
}

.welcome-actions,
.welcome-secondary {
  display: contents;
}

.module-card,
.secondary-module-link {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 206px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  background-position: center;
  background-size: cover;
  color: #102039;
  text-align: left;
  box-shadow: 0 22px 60px rgba(33, 74, 118, 0.16);
}

.module-card::before,
.secondary-module-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02) 52%, rgba(232, 245, 255, 0.22)),
    linear-gradient(25deg, rgba(247, 252, 255, 0.36), rgba(255, 255, 255, 0.02) 52%, rgba(255, 255, 255, 0.08));
}

.module-card::after,
.secondary-module-link::after {
  content: "›";
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.12)),
    rgba(4, 26, 50, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
  z-index: 1;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.module-card span,
.secondary-module-link {
  font-size: clamp(22px, 2.7vw, 32px);
  font-weight: 900;
  line-height: 1.12;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8),
    0 10px 24px rgba(35, 86, 137, 0.16);
}

.module-card span {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 58px);
}

.secondary-module-link::before {
  pointer-events: none;
}

.module-card:hover,
.secondary-module-link:hover {
  transform: translateY(-5px);
  box-shadow: 0 30px 82px rgba(33, 74, 118, 0.22);
  filter: saturate(1.04);
}

.secondary-module-link {
  width: auto;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02) 56%, rgba(225, 240, 255, 0.2)),
    url("/static/images/module-staff-maintenance-v2.png");
}

.module-duty {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02) 56%, rgba(225, 240, 255, 0.2)),
    url("/static/images/module-duty-report-v2.png");
}

.module-attendance {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02) 56%, rgba(225, 248, 246, 0.2)),
    url("/static/images/module-attendance-report-v2.png");
}

.module-night-duty {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02) 56%, rgba(228, 235, 255, 0.16)),
    url("/static/images/module-night-duty-v2.png");
}

.module-card::after,
.secondary-module-link::after {
  content: none !important;
  display: none !important;
}

button,
.link-button,
.ghost,
.primary,
.small-button,
.upload-button {
  border-radius: 12px;
}

input,
select,
textarea,
.field-control,
.date-card,
.summary-card,
.staff-self-card {
  border-color: rgba(33, 78, 126, 0.16);
  border-radius: 14px;
}

@media (max-width: 720px) {
  body,
  body::before {
    background:
      linear-gradient(180deg, rgba(247, 252, 255, 0.96), rgba(237, 248, 255, 0.88)),
      url("/static/images/pharmacy-lab-bg-v2.png") 58% top / auto 520px no-repeat,
      var(--brand-bg);
  }

  .topbar {
    padding: 10px 12px;
  }

  .topbar nav {
    border-radius: 0;
    background: transparent;
  }

  .topbar nav a,
  .nav-button {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
  }

  .welcome {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 16px 0 34px;
  }

  .welcome-logo {
    width: min(82vw, 380px);
  }

  .module-card {
    min-height: 128px;
    border-radius: 18px;
  }

  .secondary-module-link {
    min-height: 128px;
  }

  .module-card span,
  .secondary-module-link {
    font-size: 24px;
  }

  .module-card::after,
  .secondary-module-link::after {
    right: 18px;
    bottom: 18px;
    width: 32px;
    height: 32px;
    font-size: 25px;
  }
}

/* Night duty page refresh: keep the data layout, align the visual language. */
body:has(.night-calendar-grid) .shell > .panel:first-of-type {
  min-height: 168px;
  display: grid;
  align-content: center;
  padding: 22px 30px;
  border-color: rgba(255, 255, 255, 0.66);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.68), rgba(236, 248, 255, 0.42) 48%, rgba(255, 255, 255, 0.08)),
    url("/static/images/night-duty-page-bg-v2.png") center center / cover no-repeat;
  color: #fff;
  box-shadow: 0 28px 90px rgba(13, 40, 92, 0.2);
}

body:has(.night-calendar-grid) .shell > .panel:first-of-type h1 {
  margin-bottom: 10px;
  color: #102039;
  font-size: clamp(24px, 2.5vw, 32px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.82);
}

body:has(.night-calendar-grid) .shell > .panel:first-of-type label {
  color: #526c8d;
}

body:has(.night-calendar-grid) .shell > .panel:first-of-type .selector {
  grid-template-columns: minmax(220px, 320px) auto;
  justify-content: start;
}

body:has(.night-calendar-grid) .shell > .panel:first-of-type select {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 30px rgba(0, 20, 52, 0.16);
}

body:has(.night-calendar-grid) .shell > .panel:first-of-type .primary {
  background: linear-gradient(135deg, #1f6fff, #00a982);
  box-shadow: 0 16px 36px rgba(0, 97, 255, 0.26);
}

body:has(.night-calendar-grid) .shell > .panel:nth-of-type(2) {
  border-color: rgba(148, 190, 242, 0.28);
  background:
    radial-gradient(circle at 14% 0%, rgba(31, 111, 255, 0.08), transparent 32%),
    radial-gradient(circle at 94% 6%, rgba(0, 169, 130, 0.06), transparent 30%),
    linear-gradient(135deg, rgba(250, 253, 255, 0.88), rgba(235, 247, 255, 0.7)),
    rgba(255, 255, 255, 0.72);
  box-shadow: 0 28px 86px rgba(33, 74, 118, 0.14);
}

body:has(.night-calendar-grid) .panel-heading {
  align-items: flex-start;
}

body:has(.night-calendar-grid) .panel-heading h2 {
  color: #0b1527;
  font-size: clamp(20px, 2vw, 28px);
}

body:has(.night-calendar-grid) .panel-heading .muted {
  color: #506b8c;
  font-weight: 700;
}

body:has(.night-calendar-grid) .night-calendar-weekdays {
  color: #496889;
  letter-spacing: 0;
}

body:has(.night-calendar-grid) .night-calendar-grid {
  gap: 10px;
}

body:has(.night-calendar-grid) .night-calendar-day {
  min-height: 112px;
  border-color: rgba(93, 151, 222, 0.3);
  border-radius: 16px;
  background:
    radial-gradient(circle at 16% 8%, rgba(31, 111, 255, 0.08), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.74), rgba(226, 242, 255, 0.58));
  box-shadow: 0 14px 34px rgba(26, 73, 126, 0.08);
}

body:has(.night-calendar-grid) .night-calendar-day.is-weekend {
  background:
    radial-gradient(circle at 16% 8%, rgba(118, 87, 217, 0.08), transparent 42%),
    linear-gradient(145deg, rgba(238, 246, 255, 0.84), rgba(218, 235, 255, 0.64));
}

body:has(.night-calendar-grid) .night-calendar-day:hover {
  transform: translateY(-2px);
  border-color: rgba(31, 111, 255, 0.38);
  box-shadow: 0 20px 48px rgba(26, 73, 126, 0.13);
}

body:has(.night-calendar-grid) .night-calendar-date strong {
  color: #102039;
  font-size: 24px;
}

body:has(.night-calendar-grid) .night-calendar-date span,
body:has(.night-calendar-grid) .night-calendar-empty {
  color: #526c8d;
}

body:has(.night-calendar-grid) .night-duty-person {
  border: 1px solid rgba(255, 255, 255, 0.54);
  box-shadow: 0 8px 18px rgba(30, 76, 134, 0.08);
}

@media (max-width: 720px) {
  body:has(.night-calendar-grid) .shell > .panel:first-of-type {
    min-height: 148px;
    padding: 18px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(235, 248, 255, 0.32) 58%, rgba(255, 255, 255, 0.08)),
      url("/static/images/night-duty-page-bg-v2.png") 66% center / auto 100% no-repeat;
  }

  body:has(.night-calendar-grid) .shell > .panel:first-of-type h1 {
    margin-bottom: 8px;
    font-size: 24px;
  }

  body:has(.night-calendar-grid) .shell > .panel:first-of-type .selector {
    grid-template-columns: 1fr;
  }

  body:has(.night-calendar-grid) .shell > .panel:nth-of-type(2) {
    padding: 18px 12px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(235, 246, 255, 0.5)),
      rgba(255, 255, 255, 0.58);
  }

  body:has(.night-calendar-grid) .panel-heading {
    gap: 3px;
    margin-bottom: 12px;
  }

  body:has(.night-calendar-grid) .night-calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  body:has(.night-calendar-grid) .night-calendar-day {
    min-height: 88px;
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 8px;
    padding: 10px 12px;
    border-color: rgba(126, 179, 244, 0.34);
    border-radius: 16px;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(223, 241, 255, 0.76) 58%, rgba(211, 248, 242, 0.72)),
      rgba(255, 255, 255, 0.82);
    box-shadow: 0 14px 32px rgba(33, 84, 140, 0.12);
  }

  body:has(.night-calendar-grid) .night-calendar-day.is-weekend {
    background:
      linear-gradient(135deg, rgba(250, 253, 255, 0.92), rgba(229, 239, 255, 0.78) 58%, rgba(236, 231, 255, 0.72)),
      rgba(255, 255, 255, 0.82);
  }

  body:has(.night-calendar-grid) .night-calendar-day:hover {
    transform: none;
  }

  body:has(.night-calendar-grid) .night-calendar-date {
    display: flex;
    gap: 2px;
    justify-content: space-between;
  }

  body:has(.night-calendar-grid) .night-calendar-date strong {
    color: #102039;
    font-size: 24px;
    line-height: 1;
  }

  body:has(.night-calendar-grid) .night-calendar-date span {
    color: #526c8d;
    font-size: 12px;
  }

  body:has(.night-calendar-grid) .night-calendar-people {
    justify-content: flex-start;
  }

  body:has(.night-calendar-grid) .night-calendar-empty {
    justify-self: start;
    color: #72849b;
    font-weight: 700;
  }

  body:has(.night-calendar-grid) .night-duty-person {
    min-height: 28px;
    padding: 4px 9px;
    border-color: rgba(255, 255, 255, 0.68);
    box-shadow: 0 10px 20px rgba(0, 12, 32, 0.16);
  }
}
