:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #66736e;
  --line: #dce6e1;
  --line-strong: #bfd1ca;
  --bg: #f3f7f4;
  --panel: #ffffff;
  --panel-soft: #f8fbf9;
  --primary: #166b5d;
  --primary-dark: #104c43;
  --primary-soft: #dcefe9;
  --accent: #b97724;
  --danger: #a83d3d;
  --warning: #fff4d6;
  --radius: 12px;
  --shadow: 0 16px 40px rgba(23, 33, 29, 0.08);
  --shadow-soft: 0 8px 22px rgba(23, 33, 29, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(22, 107, 93, 0.10), transparent 32rem),
    linear-gradient(180deg, #fbfdfb 0, var(--bg) 22rem);
  font-size: 15px;
  line-height: 1.45;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  padding: 14px clamp(16px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(220, 230, 225, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #2c9a82);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: var(--shadow-soft);
}

.topbar strong {
  display: block;
  font-size: 17px;
  letter-spacing: 0;
}

.topbar span,
p,
small {
  color: var(--muted);
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.user-chip {
  display: grid;
  gap: 1px;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.user-chip span {
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
}

.user-chip small {
  font-size: 11px;
}

.user-chip a {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.notification-menu {
  position: relative;
}

.notification-menu summary {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.notification-menu summary::-webkit-details-marker {
  display: none;
}

.notification-menu summary:hover,
.notification-menu[open] summary {
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

.notification-menu svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.notification-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--danger);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(420px, calc(100vw - 28px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.notification-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.notification-panel-head strong {
  color: var(--ink);
  font-size: 15px;
}

.notification-panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.notification-close {
  display: none;
  width: 100%;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

nav a,
.button,
.actions a,
.actions button {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  font-weight: 750;
  color: #2c3934;
}

nav a svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

nav a.active,
nav a:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(22, 107, 93, 0.18);
}

main {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px);
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-head p {
  max-width: 720px;
}

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

h1 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  margin-bottom: 8px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-weight: 800;
  white-space: nowrap;
}

.button:hover,
.actions a:hover,
.actions button:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

.button.light {
  background: var(--panel-soft);
}

.head-actions,
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.head-actions form {
  display: inline-flex;
}

.quick-action-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.quick-action-form select {
  min-width: 190px;
}

.button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 6px 10px;
  white-space: nowrap;
}

.report-group {
  margin-top: 16px;
}

.report-date-label {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 900;
  margin: 4px 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tabs a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
}

.tabs a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.actions {
  min-width: 160px;
}

.actions form {
  margin: 0;
}

.actions button,
.actions a {
  padding: 7px 9px;
  font-size: 13px;
}

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

.stats div,
.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats div {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.stats div::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.stats span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.stats strong {
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: clamp(16px, 2vw, 22px);
  margin-bottom: 18px;
}

.panel.narrow {
  max-width: 720px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
}

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

th,
td {
  padding: 12px 11px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: #2d3f38;
  background: #f0f6f3;
  font-size: 13px;
  font-weight: 850;
}

td {
  background: #ffffff;
}

th.sortable {
  position: relative;
  cursor: pointer;
  user-select: none;
  padding-right: 28px;
}

th.sortable:hover,
th.sortable:focus {
  background: #e4f0eb;
  outline: none;
}

th.sortable::after {
  content: "↕";
  position: absolute;
  right: 9px;
  color: #7b8a84;
  font-size: 12px;
}

th.sortable.sort-asc::after {
  content: "↑";
  color: var(--primary);
}

th.sortable.sort-desc::after {
  content: "↓";
  color: var(--primary);
}

tr:hover td {
  background: #fbfdfc;
}

.group-row td {
  background: #eef4f1;
  color: #153f38;
  font-weight: 850;
  border-top: 2px solid var(--line-strong);
}

.department-matrix {
  min-width: 900px;
  table-layout: fixed;
  border: 0;
  background: #ffffff;
}

.range-report {
  border: 1px solid #1d1d1d;
  background: #ffffff;
}

.range-date-line {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  border-bottom: 1px solid #1d1d1d;
  padding: 8px 18px;
  font-weight: 900;
}

.range-date-line span {
  min-width: 160px;
  background: #fff7bd;
  text-align: center;
}

.range-title {
  background: #e8e2ef;
  border-bottom: 1px solid #1d1d1d;
  font-size: 1.05rem;
  font-weight: 900;
  padding: 8px;
  text-align: center;
}

.range-meta {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  border-bottom: 1px solid #1d1d1d;
}

.range-meta strong {
  background: #fff200;
  border-right: 1px solid #1d1d1d;
  font-size: clamp(1.2rem, 2.4vw, 2rem);
  padding: 6px;
  text-align: center;
}

.range-meta strong + strong {
  background: #fce4d6;
  border-right: 0;
}

.range-report .table-wrap {
  border: 0;
  border-radius: 0;
}

.range-report table {
  min-width: 760px;
}

.range-report th,
.range-report td {
  border: 1px solid #1d1d1d;
  color: #000000;
  font-weight: 850;
  padding: 7px 8px;
}

.range-report th {
  background: #f4b6ef;
}

.department-matrix th,
.department-matrix td {
  border: 1px solid var(--line);
}

.department-matrix thead th {
  background: #eef4f1;
  color: #26352f;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
  padding: 13px 10px;
  font-weight: 850;
}

.department-matrix thead th.highlight {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.department-matrix .dept-name,
.department-matrix tfoot th {
  background: #fbfcfa;
  color: #1f4f46;
  font-size: 15px;
  text-align: left;
  width: 220px;
  font-weight: 850;
}

.department-matrix .count-cell,
.department-matrix .total-cell,
.department-matrix .grand-total {
  height: 48px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: #1e2a25;
}

.department-matrix .total-cell,
.department-matrix .grand-total {
  background: #f7f3e8;
  color: #153f38;
}

.department-matrix tfoot th,
.department-matrix tfoot td {
  background: #f7f3e8;
  font-size: 18px;
  font-weight: 850;
}

.department-matrix tbody tr:hover th,
.department-matrix tbody tr:hover td {
  background: #f8fbf9;
}

.filters,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}

.filters.compact {
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr) auto;
  margin-bottom: 14px;
}

.form-grid.one {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #2e3c37;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c9d5cf;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #ffffff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 107, 93, 0.12);
  outline: none;
}

textarea {
  resize: vertical;
}

.span-all {
  grid-column: 1 / -1;
}

.picker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel-soft);
}

.date-picker-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfdfc;
}

.summary-head,
.picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.summary-head h2,
.picker-head h2 {
  margin: 0;
}

.picker-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.muted-count,
.subtle {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.summary-head .subtle {
  margin: 4px 0 0;
}

.checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 440px;
  overflow: auto;
  padding-right: 2px;
}

.date-checks {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 8px;
}

.meal-only-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.meal-only-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 900;
}

.meal-only-toggle input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.meal-only-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.picker.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.date-check-row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr;
  padding: 10px;
}

.date-check-row input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.date-check-row strong,
.date-check-row small {
  display: block;
}

.check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  font-weight: 400;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

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

.check-row:hover {
  border-color: var(--line-strong);
  background: #fbfdfc;
}

.employee-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  cursor: pointer;
}

.service-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
}

.check-row input {
  width: 18px;
  height: 18px;
  min-height: auto;
  margin-top: 3px;
}

.check-row strong,
.check-row small {
  display: block;
}

.status {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.approved {
  color: #145447;
  background: var(--primary-soft);
}

.status.pending {
  color: #7b4f09;
  background: #fff0cd;
}

.status.cancelled {
  color: #8f2f2f;
  background: #f8dddd;
}

.notice {
  margin-bottom: 18px;
  padding: 13px 15px;
  background: var(--warning);
  border: 1px solid #e7cb7b;
  border-radius: 10px;
  color: #5f4710;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.notice.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
}

form.is-submitting {
  cursor: progress;
}

form.is-submitting button {
  pointer-events: none;
}

.table-wrap.has-horizontal-scroll {
  box-shadow: inset -12px 0 18px -18px rgba(23, 33, 29, 0.55);
}

.deadline-alert,
.pwa-card {
  margin-bottom: 18px;
  border-radius: var(--radius);
  border: 1px solid #e7cb7b;
  background: #fff8df;
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.pwa-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-color: var(--line);
  background: #ffffff;
}

.pwa-card[hidden] {
  display: none;
}

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

.pwa-card strong {
  color: var(--ink);
}

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

.pwa-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pwa-actions form {
  margin: 0;
}

.deadline-alert {
  display: grid;
  gap: 8px;
}

.deadline-alert strong {
  color: #5f4710;
}

.deadline-alert ul {
  margin: 0;
  padding-left: 20px;
  color: #5f4710;
}

.deadline-alert .button {
  width: fit-content;
}

.notification-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #efd99c;
}

.notification-item + .notification-item {
  margin-top: 8px;
}

.notification-item span {
  color: var(--muted);
}

.notification-item form {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.notification-item button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(100%, 480px);
}

.auth-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 30px);
}

.auth-brand {
  margin-bottom: 20px;
}

.auth-note {
  margin: 16px 0 0;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .grid.two {
    grid-template-columns: 1fr;
  }

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

  .date-checks {
    grid-template-columns: repeat(4, minmax(110px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: stretch;
  }

  nav a {
    justify-content: center;
    padding: 10px 8px;
  }

  nav a span {
    display: none;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .head-actions .button,
  .page-head > .button {
    width: 100%;
  }

  .pwa-card {
    align-items: stretch;
    flex-direction: column;
  }

  .pwa-actions,
  .pwa-actions .button {
    width: 100%;
  }

  .pwa-actions form {
    flex: 1 1 auto;
  }

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

  .filters.compact {
    grid-template-columns: 1fr;
  }

  .date-checks {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  main {
    padding: 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .topbar strong {
    font-size: 16px;
  }

  .topbar span {
    font-size: 12px;
  }

  nav {
    grid-template-columns: repeat(5, 1fr);
  }

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

  .user-chip {
    min-width: 0;
  }

  .notification-panel {
    position: fixed;
    top: 132px;
    right: 14px;
    left: 14px;
    width: auto;
    max-height: calc(100vh - 150px);
  }

  .notification-close {
    display: block;
  }

  nav a {
    min-height: 40px;
  }

  .panel {
    padding: 14px;
    border-radius: 10px;
  }

  .stats {
    gap: 10px;
  }

  .stats div {
    padding: 16px;
  }

  .checks {
    grid-template-columns: 1fr;
    max-height: 58vh;
  }

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

  .service-check {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 8px;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .tabs a {
    text-align: center;
  }

  .actions {
    min-width: 0;
  }

  .actions a,
  .actions button {
    min-height: 36px;
  }
}
