*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Meiryo', sans-serif;
  background: #eef1f6;
  color: #1a1a2e;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.narrow {
  max-width: 420px;
  padding-top: 48px;
}

.app-title {
  text-align: center;
  font-size: 1.75rem;
  margin: 24px 0 8px;
}

.muted {
  color: #666;
  text-align: center;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 40px auto;
  max-width: 360px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 1rem;
  cursor: pointer;
  background: #3860b2;
  color: #fff;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  padding: 28px 20px;
  font-size: 1.15rem;
  line-height: 1.4;
}

.btn-lg .sub {
  font-size: 0.85rem;
  opacity: 0.9;
}

.btn-honin {
  background: #3860b2;
}

.btn-bunin {
  background: #36b04b;
}

.btn-ghost {
  background: transparent;
  color: #3860b2;
  border: 1px solid #3860b2;
}

.btn-danger {
  background: #e74c3c;
}

.btn-warn {
  background: #e67e22;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.btn-block {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.admin-link {
  display: block;
  margin: 32px auto 0;
  max-width: 200px;
  width: 100%;
}

.input {
  padding: 8px 10px;
  border: 1px solid #aab;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

.error {
  color: #c0392b;
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

.punch-header,
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.punch-header h1,
.page-header h1 {
  flex: 1;
  text-align: center;
  font-size: 1.25rem;
  margin: 0;
  background: #d6dfee;
  padding: 10px;
  border-radius: 8px;
}

.punch-toolbar,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.punch-date-block {
  flex: 1;
  min-width: 0;
}

.punch-date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.date-picker-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 20%;
  min-width: 16.5rem;
  max-width: 18rem;
  border: 1px solid #aab;
  border-radius: 6px;
  background: #fff;
  padding: 12px 14px;
  cursor: pointer;
}

.date-picker-compact--not-today {
  width: auto;
  min-width: 13.5rem;
  max-width: 15rem;
  padding: 10px 12px;
}

.date-readout {
  flex: 1;
  min-width: 0;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  pointer-events: none;
  white-space: nowrap;
}

.date-picker-compact--not-today .date-readout {
  font-size: 1.15rem;
}

.date-input-picker {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: transparent;
  cursor: pointer;
}

.date-input-picker::-webkit-datetime-edit,
.date-input-picker::-webkit-datetime-edit-fields-wrapper,
.date-input-picker::-webkit-datetime-edit-text,
.date-input-picker::-webkit-datetime-edit-month-field,
.date-input-picker::-webkit-datetime-edit-day-field,
.date-input-picker::-webkit-datetime-edit-year-field {
  display: none;
}

.date-input-picker::-webkit-calendar-picker-indicator {
  opacity: 1;
  cursor: pointer;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
}

.date-input-picker::-webkit-clear-button {
  -webkit-appearance: none;
  display: none;
}

.date-input-picker::-webkit-inner-spin-button {
  display: none;
}

.not-today-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.not-today-warning {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: #c0392b;
}

.leave-not-today-warning {
  margin-bottom: 8px;
}

.punch-date-display {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.date-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.82rem;
  color: #666;
}

.status-bar {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 8px;
}

.staff-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.staff-row {
  position: relative;
  background: #fff;
  border-radius: 8px;
  padding: 14px 14px 14px 18px;
  border: 1px solid #dde;
}

.staff-row.row-open {
  background: #ffdcdc;
}

.staff-row.row-ok {
  background: #dcffdc;
}

.staff-row.selected {
  box-shadow: 0 0 0 2px #3860b2;
}

.sel-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #00126b;
  border-radius: 8px 0 0 8px;
}

.staff-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.staff-presence-hint {
  display: inline-block;
  margin: -4px 0 10px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #5a4030;
  background: #fff3cd;
  border-radius: 6px;
}

.staff-row-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  align-items: start;
}

.staff-row-main {
  min-width: 0;
}

.staff-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.staff-actions-punch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.staff-actions-misc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.staff-actions-transfer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 2px solid #9b8ec4;
}

.btn-xfer-cancel {
  background: #6a5a9a;
  min-width: 5rem;
}

.staff-actions-leave {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 2px solid #c8d0e0;
}

.btn-punch-in {
  min-width: 4.5rem;
}

.btn-punch-out {
  min-width: 4.5rem;
}

.staff-status {
  min-width: 7.5rem;
  border-left: 1px solid #dde;
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

@media (max-width: 560px) {
  .staff-row-body {
    grid-template-columns: 1fr;
  }

  .staff-status {
    border-left: none;
    border-top: 1px solid #dde;
    padding-left: 0;
    padding-top: 10px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px 16px;
  }
}

.staff-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 0.9rem;
}

.staff-status-label {
  color: #666;
  font-size: 0.78rem;
  white-space: nowrap;
}

.staff-status-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.leave-badge {
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 6px;
}

.btn-xfer {
  background: #5c4db1;
  min-width: 4.5rem;
}

.leave-panel {
  margin-top: 16px;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ccd;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-menu {
  margin: 24px 0;
}

.admin-page {
  max-width: 960px;
}

.staff-master-page {
  max-width: 1280px;
}

.staff-master-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 8px;
}

.staff-master-site-panel {
  min-width: 0;
}

.staff-master-site-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.staff-master-empty {
  margin: 0;
  font-size: 0.85rem;
  text-align: center;
}

.staff-master-table-wrap {
  overflow-x: auto;
}

.staff-master-table {
  width: 100%;
  font-size: 0.76rem;
}

.staff-master-table .sm-col-order {
  width: 8%;
}

.staff-master-table .sm-col-name {
  width: 18%;
}

.staff-master-table .sm-col-active {
  width: 8%;
}

.staff-master-table .sm-col-site {
  width: 18%;
}

.staff-master-table .sm-col-emp {
  width: 12%;
}

.staff-master-table .sm-col-hours {
  width: 10%;
}

.staff-master-table .sm-col-prep {
  width: 10%;
}

.staff-master-table .sm-col-edit {
  width: 10%;
}

.staff-master-table th,
.staff-master-table td {
  text-align: center;
  white-space: normal;
  padding: 4px 3px;
}

.staff-master-page .staff-master-table .row-inactive td:not(.sm-col-edit-cell) {
  color: #7a8494;
}

.staff-master-page .staff-master-table .sm-sort-order-max {
  color: #c62828;
  font-weight: 600;
}

.staff-master-page .staff-table .row-inactive {
  opacity: 0.55;
}

@media (max-width: 1000px) {
  .staff-master-columns {
    grid-template-columns: 1fr;
  }
}

.staff-form-panel {
  margin-top: 20px;
  padding: 16px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ccd;
}

.staff-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 16px;
}

.staff-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.input-narrow {
  max-width: 120px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.form-hint {
  font-size: 0.8rem;
  align-self: center;
}

.btn-edit {
  background: #555;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  white-space: nowrap;
}

.data-table th {
  background: #eef;
}

.timecard-table .tc-col-date {
  width: 28%;
}

.timecard-table .tc-col-in,
.timecard-table .tc-col-out,
.timecard-table .tc-col-paid,
.timecard-table .tc-col-abs {
  width: 13%;
}

.timecard-table .tc-col-edit {
  width: 10%;
}

.timecard-table th.tc-align-center,
.timecard-table td.tc-align-center {
  text-align: center;
}

.timecard-table th,
.timecard-table td {
  white-space: normal;
}

.timecard-table td.tc-col-date-cell {
  white-space: nowrap;
}

.note {
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
}

.rep-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
}

.rep-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.live-badge {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  margin: 8px 0;
}

.export-bar {
  background: #fff3cd;
  border: 1px solid #ffc107;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.daily-timecard-page {
  max-width: 1280px;
}

.daily-scroll {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.daily-day-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.daily-site-panel {
  min-width: 0;
}

.daily-site-title {
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  color: #333;
}

.daily-table-wrap {
  overflow-x: auto;
}

.daily-attlog-table {
  width: 100%;
  font-size: 0.78rem;
}

.daily-attlog-table .dal-col-name {
  width: 24%;
}

.daily-attlog-table .dal-col-time {
  width: 14%;
}

.daily-attlog-table .dal-col-leave {
  width: 16%;
}

.daily-attlog-table .dal-col-edit {
  width: 12%;
}

.daily-attlog-table th,
.daily-attlog-table td {
  text-align: center;
  white-space: normal;
  padding: 4px 3px;
}

.daily-attlog-table th {
  font-size: 0.76rem;
}

.attlog-clock-out-cell .attlog-clock-out {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.attlog-clock-out-cell .attlog-bulk-stamp {
  writing-mode: vertical-rl;
  text-orientation: upright;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 1.45em;
  min-height: 2.5em;
  padding: 3px 5px;
  border: 2px solid #c62828;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #c62828;
  letter-spacing: 0.1em;
  line-height: 1.1;
  flex-shrink: 0;
}

.attlog-clock-out-cell .attlog-clock-out-sep {
  margin: 0 2px;
  color: #555;
}

@media (max-width: 900px) {
  .daily-day-columns {
    grid-template-columns: 1fr;
  }
}

.daily-day-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #ccd;
}

.daily-day-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.daily-day-head {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 8px;
  padding: 8px 10px;
  background: #eef;
  border: 1px solid #ccd;
  border-radius: 6px;
  font-size: 0.95rem;
}

.daily-day-empty {
  margin: 0 0 4px;
  padding-left: 8px;
  font-size: 0.85rem;
}

.tc-row-selected td {
  background: #e3f2fd;
}

.day-editor-panel {
  margin-top: 16px;
}

.day-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.day-editor-head h3 {
  margin: 0;
  font-size: 1rem;
}

.att-record-block {
  border: 1px solid #ccd;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafafa;
}

.att-record-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.att-record-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 12px;
}

.att-record-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.leave-editor {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #ccd;
}

.leave-editor h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 9999;
  max-width: 90vw;
  text-align: center;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success {
  background: #2e7d32;
}

.toast-error {
  background: #c62828;
}

.toast-warning {
  background: #ef6c00;
}

@media (min-width: 768px) {
  .home-buttons {
    flex-direction: row;
    max-width: 720px;
  }

  .home-buttons .btn-lg {
    flex: 1;
  }
}
