:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --sidebar: #f0f0ee;
  --text: #242424;
  --muted: #6b6b6b;
  --line: #e5e5e3;
  --line-strong: #d7d7d3;
  --primary: #191919;
  --primary-soft: #2d3446;
  --shadow: 0 18px 40px rgba(25, 25, 25, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.mobile-topbar,
.drawer-backdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px 22px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 11px;
  font-weight: 700;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 11px 12px;
  color: #3f3f3f;
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.76);
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #4c4c4c;
  font-size: 0.9rem;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-button {
  flex: 0 0 auto;
}

.status-dot,
.notice-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: #6f8f73;
  border-radius: 999px;
}

.main-panel {
  min-width: 0;
  padding: 42px;
}

.login-body {
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand h1 {
  margin: 2px 0 0;
  font-size: 1.7rem;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: #9b2f3e;
  font-size: 0.9rem;
}

.login-button {
  width: 100%;
}

.view {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
}

.view.is-active {
  display: block;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.65rem, 2vw, 2.3rem);
  line-height: 1.12;
  font-weight: 720;
}

h2 {
  margin-bottom: 6px;
  font-size: 1rem;
  line-height: 1.35;
}

.page-description {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card,
.quiet-panel,
.toolbar-card,
.data-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 22px;
}

.metric-label,
.metric-hint,
.card-title-row p {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-value {
  font-size: 2rem;
  line-height: 1;
  font-weight: 720;
}

.quiet-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
}

.quiet-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.toolbar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

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

.admin-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  padding: 18px 24px;
  border-top: 1px solid var(--line);
}

.settings-card .table-wrap {
  border-top: 1px solid var(--line);
}

.admin-actions {
  flex-wrap: wrap;
}

.scheduler-fields {
  display: grid;
  grid-template-columns: 180px minmax(250px, 1fr) minmax(260px, 360px);
  gap: 14px;
  align-items: stretch;
  width: 100%;
}

.wide-search {
  width: min(520px, 100%);
}

.field-group,
.search-box {
  display: flex;
  align-items: center;
  min-height: 52px;
  background: #fbfbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.field-group.is-hidden {
  display: none;
}

.field-group {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 8px 12px;
}

.field-group span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.field-group input,
.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.field-group input {
  margin-top: 3px;
}

.time-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 9px 13px;
  background: #fbfbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.time-notice strong {
  font-size: 0.88rem;
}

.time-notice p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.search-box {
  gap: 10px;
  padding: 0 15px;
  border-radius: 999px;
}

.search-box span {
  color: var(--muted);
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 650;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 10px 22px rgba(25, 25, 25, 0.14);
}

.button-secondary {
  color: var(--text);
  background: #ffffff;
  border-color: var(--line-strong);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.text-button {
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-weight: 650;
}

.text-button:hover {
  color: var(--primary);
}

.action-group {
  display: inline-flex;
  gap: 8px;
}

.action-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
}

.action-button:hover {
  background: #f7f7f5;
}

.action-button.danger {
  color: #8b3f46;
  border-color: #ead0d3;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--muted);
  background: #f7f7f5;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button:hover {
  color: var(--primary);
}

.data-card {
  overflow: hidden;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.card-title-row h2,
.card-title-row p {
  margin-bottom: 0;
}

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

.mobile-record-list {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

td {
  color: #303030;
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #fbfbfa;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.check-column {
  width: 72px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
}

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

.checkbox-label span {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid #c9c9c5;
  border-radius: 6px;
  background: #ffffff;
}

.checkbox-label input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked + span::after {
  width: 8px;
  height: 4px;
  content: "";
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) translate(1px, -1px);
}

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

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

.pagination-bar .button {
  min-height: 38px;
}

.pager-compact {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.page-size-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.page-size-select select {
  min-height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.punch-task-card {
  margin-top: 18px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pending {
  color: #5f5f5a;
  background: #eeeeeb;
}

.status-running {
  color: #315779;
  background: #e7f0f8;
}

.status-success {
  color: #496c4c;
  background: #e8f1e8;
}

.status-failed {
  color: #8b3f46;
  background: #f6e8ea;
}

.status-partial {
  color: #85631d;
  background: #f6edda;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(25, 25, 25, 0.28);
}

.modal-backdrop.is-visible {
  display: flex;
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(25, 25, 25, 0.18);
}

.compact-modal {
  width: min(560px, 100%);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin-bottom: 0;
}

.modal-body {
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding: 22px 24px;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  width: fit-content;
  padding: 4px;
  background: #f2f2f0;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.segment {
  min-width: 108px;
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-weight: 650;
}

.segment.is-active {
  color: var(--primary);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(25, 25, 25, 0.06);
}

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

.date-grid #singleDateField {
  grid-column: span 2;
}

.person-picker {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: #fbfbfa;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.picker-list {
  display: grid;
  max-height: 280px;
  overflow-y: auto;
}

.picker-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 16px;
  background: #fbfbfa;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.picker-pager .button {
  min-height: 34px;
  padding: 0 14px;
}

.picker-row {
  display: grid;
  grid-template-columns: 28px minmax(90px, 1fr) minmax(120px, 1.1fr) minmax(140px, 1.3fr);
  gap: 12px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.picker-row:last-child {
  border-bottom: 0;
}

.picker-row:hover {
  background: #fbfbfa;
}

.picker-meta {
  color: var(--muted);
}

.edit-person-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fbfbfa;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.edit-person-card span {
  color: var(--muted);
}

.section-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.date-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px 0 12px;
  background: #f2f2f0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.86rem;
}

.date-chip button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 48px));
  padding: 14px 16px;
  color: #ffffff;
  background: var(--primary);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px rgba(25, 25, 25, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 220px 1fr;
  }

  .main-panel {
    padding: 28px;
  }

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

  .toolbar-card,
  .scheduler-fields {
    display: grid;
  }

  .scheduler-fields {
    grid-template-columns: 1fr;
  }

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

  .date-grid #singleDateField {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  body.drawer-open {
    overflow: hidden;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
    padding-top: 64px;
  }

  .mobile-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 25;
    display: flex;
    min-height: 64px;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(247, 247, 245, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }

  .mobile-menu-button {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
  }

  .mobile-title {
    display: grid;
    gap: 2px;
  }

  .mobile-title span {
    color: var(--muted);
    font-size: 0.76rem;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 28;
    display: block;
    background: rgba(25, 25, 25, 0.3);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 29;
    width: min(304px, calc(100vw - 48px));
    height: 100vh;
    padding: 18px 14px;
    box-shadow: 20px 0 42px rgba(25, 25, 25, 0.16);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .sidebar-footer {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .main-panel {
    padding: 22px 12px 30px;
  }

  .page-heading,
  .quiet-panel {
    display: grid;
  }

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

  .toolbar-card {
    gap: 14px;
  }

  .admin-form {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .button {
    width: 100%;
    min-height: 48px;
  }

  .field-group,
  .search-box {
    min-height: 56px;
  }

  .action-button,
  .text-button {
    min-height: 40px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  tbody tr {
    padding: 14px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
  }

  tbody tr:hover {
    background: #ffffff;
  }

  td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-height: 38px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
  }

  td:last-child {
    border-bottom: 0;
  }

  .empty-cell {
    display: block;
    padding: 26px 14px;
    text-align: center;
  }

  .empty-cell::before {
    content: none;
  }

  .plans-table-wrap {
    display: none;
  }

  .mobile-record-list {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .mobile-record-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
  }

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

  .mobile-record-card summary::-webkit-details-marker {
    display: none;
  }

  .mobile-record-card summary span {
    display: grid;
    gap: 4px;
  }

  .mobile-record-card small {
    color: var(--muted);
  }

  .mobile-record-detail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 14px 14px;
  }

  .mobile-record-detail span {
    display: grid;
    gap: 4px;
    padding: 10px;
    background: #f7f7f5;
    border-radius: var(--radius-sm);
  }

  .mobile-record-detail em {
    color: var(--muted);
    font-size: 0.76rem;
    font-style: normal;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-footer,
  .modal-header {
    display: flex;
  }

  .modal-card {
    width: 100%;
    max-height: 94vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }

  .modal-body {
    max-height: calc(94vh - 174px);
    padding: 18px 16px;
  }

  .modal-footer {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .segmented-control {
    width: 100%;
  }

  .picker-row {
    grid-template-columns: 28px minmax(70px, 0.8fr) minmax(90px, 1fr);
    padding: 14px;
  }

  .picker-row .picker-class {
    grid-column: 2 / -1;
  }

  .picker-pager,
  .pagination-bar {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .page-size-select,
  .picker-pager .page-size-select {
    justify-content: center;
  }

  .pagination-bar {
    justify-content: stretch;
  }

  th {
    padding: 14px 16px;
  }
}
