/* The phone layouts use the existing attendance, payroll and chat controls. */
@media (max-width: 760px) {
  .people-attendance {
    --attendance-selected: #98143c;
    --attendance-line: #e9dce1;
  }
  body .people-attendance .panel + .panel { margin-block-start: 10px; }
  body .people-attendance .panel-body { padding: 10px 12px; }
  body .people-attendance .people-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
  }
  body .people-attendance .people-stats > div {
    display: grid;
    align-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 49px;
    padding: 6px 10px;
    box-sizing: border-box;
    border-radius: 9px;
  }
  body .people-attendance .people-stats strong { margin: 0; font-variant-numeric: tabular-nums; }
  body .people-attendance .people-stats > div:nth-child(7):last-child {
    grid-column: 1 / -1;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 39px;
  }
  body .people-attendance .people-calendar, body .people-attendance .people-records { margin-block-start: 10px; }
  body .people-attendance :is(.people-week,.people-days) {
    display: grid;
    grid-template-columns: repeat(7,minmax(0,1fr));
    gap: 3px;
    padding-inline: 0;
  }
  body .people-attendance .people-week span { padding: 3px 0 5px; text-align: center; }
  body .people-attendance .people-days .people-day {
    align-items: center;
    justify-content: start;
    text-align: center;
    gap: 3px;
    padding: 4px 1px;
    min-height: 54px;
    overflow-wrap: anywhere;
  }
  body .people-attendance .people-day .badge { max-width: 100%; padding-inline: 2px; line-height: 1.12; }
  body .people-attendance .people-day.today { outline-color: var(--attendance-selected); }

  body [data-page-route="payroll"] .panel:has(.salary-register) {
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }
  body [data-page-route="payroll"] table.salary-register[data-mobile-card] > tbody { padding: 0; gap: 8px; }
  body [data-page-route="payroll"] table.salary-register[data-mobile-card] > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) fit-content(45%);
    grid-template-areas: "employee action" "period period" "gross gross" "deductions deductions" "net net";
    align-items: center;
    gap: 6px 8px;
    padding: 12px;
    border: 1px solid #e7dce1;
    border-radius: 13px;
    background: #fff;
  }
  body .salary-register td.salary-employee { grid-area: employee !important; }
  body .salary-register td.salary-action { grid-area: action !important; justify-self: end; }
  body .salary-register td.salary-period { grid-area: period; }
  body .salary-register td.salary-gross { grid-area: gross; }
  body .salary-register td.salary-deductions { grid-area: deductions; }
  body .salary-register td.salary-net { grid-area: net; }
  body [data-page-route="payroll"] table.salary-register :is(.salary-employee,.salary-period,.salary-action)::before { content: none; }
  body .salary-register td.salary-employee .refops-inline { display: flex; align-items: center; gap: 7px; min-width: 0; }
  body .salary-register .salary-employee strong { min-width: 0; overflow-wrap: anywhere; }
  body .salary-register .salary-employee .avatar { flex: none; }
  body .salary-register .salary-action .btn { min-height: 40px; padding-inline: 9px; white-space: normal; text-align: center; }
  body [data-page-route="payroll"] table.salary-register td.salary-period {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 8px;
    padding-block-end: 7px !important;
    margin-block-end: 2px;
    border-bottom: 1px solid #f0e8eb;
  }
  body .salary-register .salary-period small { margin: 0; color: #695c63; }
  body [data-page-route="payroll"] table.salary-register td.salary-amount {
    display: grid;
    grid-template-columns: minmax(0, 1fr) fit-content(62%);
    align-items: baseline;
    gap: 8px;
    font-size: 13px !important;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    text-align: end;
    overflow-wrap: anywhere;
  }
  body [data-page-route="payroll"] table.salary-register td.salary-amount::before {
    content: attr(data-mobile-label);
    font-size: 12px;
    margin: 0;
    color: #61565d;
    text-align: start;
  }
  body [data-page-route="payroll"] table.salary-register td.salary-net {
    padding-block-start: 6px !important;
    border-top: 1px solid #f0e8eb;
    color: #741831;
  }
  body [data-page-route="payroll"] table.salary-register td.salary-net::before { color: inherit; font-weight: bold; }

  body .refutil-chat-screen:has(.refutil-chat.is-thread-open) {
    margin: 0;
    padding: 0;
    background: white;
    gap: 0;
  }
  body .refutil-chat-screen .refutil-thread-head {
    display: flex;
    align-items: center;
    flex: none;
    gap: 8px;
    min-height: 52px;
    padding: 5px 10px;
    box-sizing: border-box;
  }
  body .refutil-chat-screen .refutil-thread-head :is(h2,p) { margin: 0; }
  body .refutil-chat-screen .refutil-thread-head .inbox-mobile-back {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    margin: 0;
  }
  body .refutil-chat-screen .refutil-thread-stream {
    align-items: stretch;
    gap: 7px;
    background-color: #fcf8fa;
    background-image: linear-gradient(rgb(252 248 250 / 95%),rgb(252 248 250 / 95%)), url("assets/triq-crm-mark.png");
    background-size: 100% 100%, clamp(86px, 24vw, 118px);
    background-position: center;
    background-repeat: no-repeat;
  }
  body .refutil-chat-screen .refutil-thread-stream .refutil-chat-message {
    align-self: flex-start;
    max-width: 85%;
    min-width: 0;
    margin: 0;
    border-color: #e6dae0;
    background: #fff;
    overflow-wrap: anywhere;
  }
  body .refutil-chat-screen .refutil-thread-stream .refutil-chat-message.mine {
    align-self: flex-end;
    border-color: #edd4dd;
    background: #f8eaf0;
  }
  body .refutil-chat-screen .refutil-thread-stream .chat-date { align-self: center; margin: 2px auto; }
  body .refutil-chat-screen .refutil-chat-message > small { display: block; color: #61535d; margin-top: 3px; }
  body .refutil-chat-screen .refutil-message-composer {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    align-items: start;
    gap: 6px;
    padding: 6px 10px max(6px, env(safe-area-inset-bottom, 0px)) !important;
    border-top: 1px solid #e8dce1;
  }
  body .refutil-chat-screen .refutil-composer-body { grid-template-columns: 42px minmax(0,1fr); gap: 4px 6px; }
  body .refutil-chat-screen .refutil-chat-file-row > label,
  body .refutil-chat-screen .refutil-message-composer > button,
  body .refutil-chat-screen .refutil-message-composer textarea {
    min-width: 0;
    margin: 0;
    height: 42px;
    min-height: 42px;
    box-sizing: border-box;
  }
  body .refutil-chat-screen .refutil-chat-file-row > label { padding: 0; display: grid; place-items: center; }
  body .refutil-chat-screen .refutil-message-composer > button { max-width: 120px; line-height: 1.1; white-space: normal; }
  body .refutil-chat-screen .refutil-chat-file-row > button { grid-column: 1/-1; justify-self: start; }
}

/* Daily work controls. */
#page-content :is(.people-attendance,.people-work,.people-attendance .panel,.people-work .panel) { min-width: 0; }
#page-content :is(.people-attendance,.people-work) .panel-head { flex-wrap: wrap; }
#page-content .people-work .work-switch {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0,1fr);
  align-items: stretch;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 3px;
  border: 1px solid #e8d9df;
  border-radius: 12px;
  background: #f9f3f5;
  box-sizing: border-box;
  overflow: visible;
}
#page-content .work-switch > button.btn {
  display: grid;
  place-items: center;
  min-height: 38px;
  height: auto;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 5px 12px;
  border: 0 !important;
  border-radius: 9px;
  box-shadow: none;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}
#page-content .work-switch > button[aria-pressed="true"] { color: white !important; background: #951740 !important; }
#page-content .work-switch > button[aria-pressed="false"] { color: #54343f !important; background: transparent !important; }
#page-content .work-switch > button:focus-visible { outline: 2px solid #86123a; outline-offset: 2px; }
#page-content .work-switch > button::before,
#page-content .work-switch > button::after { content: none; }
#page-content :is(.day-controls,.clock-actions,.day-tasks-head) {
  display: flex; align-items: end; flex-wrap: wrap; gap: .6rem; min-width: 0; max-width: 100%;
}
#page-content .day-controls .field { margin: 0; min-width: 0; }
#page-content .day-toolbar { align-items: center; justify-content: space-between; gap: 12px; }
#page-content .day-tasks-head { align-items: center; justify-content: space-between; margin-bottom: .8rem; }
#page-content .day-tasks-head h2 { margin: 0; }
#page-content .my-attendance-card .clock-actions { align-items: center; justify-content: flex-end; }
#page-content .my-attendance-card .people-stats { grid-template-columns: repeat(4,minmax(0,1fr)); margin-bottom: 0; }
#page-content .live-team-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,17rem),1fr)); gap: 12px; align-items: start; }
#page-content .live-person { min-width: 0; padding: 14px; border: 1px solid #eadfe3; border-radius: 14px; background: #fff; }
#page-content .live-person header,
#page-content .live-person .live-identity { display: flex; align-items: center; gap: 8px; min-width: 0; }
#page-content .live-person header { flex-wrap: wrap; justify-content: space-between; }
#page-content .live-identity strong { overflow-wrap: anywhere; }
#page-content .live-identity .avatar { flex: none; }
#page-content .live-person dl { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; margin: 14px 0 10px; }
#page-content .live-person dl > div { padding: 8px; border-radius: 8px; background: #fbf6f8; overflow-wrap: anywhere; }
#page-content .live-person dt { color: #6a525d; font-size: .78rem; }
#page-content .live-person dd { margin: 4px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }
#page-content .live-person footer { display: flex; justify-content: flex-end; }
@media (max-width: 760px) {
  #page-content .people-work .day-toolbar {
    display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; align-items: start; padding: 12px;
  }
  #page-content .work-switch { width: 100%; }
  #page-content .work-switch > button.btn { min-height: 42px; padding-inline: 4px; }
  #page-content .people-work .day-controls {
    display: grid; width: 100%; grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: end; gap: 8px;
  }
  #page-content .day-controls .field:only-child { grid-column: 1 / -1; }
  #page-content .day-controls .field { width: 100%; }
  #page-content .day-controls :is(input,select) { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
  #page-content .my-attendance-card .people-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
}


/* Keep the record scope, employee and month together on the available panel width. */
.attendance-register { container: attendance-register / inline-size; min-width: 0; }
#page-content .attendance-register :is(.attendance-toolbar, .attendance-viewbar) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.25rem;
  padding: .85rem clamp(.75rem, 2cqi, 1.5rem);
  border-bottom: 1px solid #ebe2e6;
}
#page-content .attendance-register .attendance-toolbar { align-items: end; }
#page-content .attendance-register .attendance-switch {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  width: fit-content;
  max-width: 100%;
  gap: 2px;
  padding: 3px;
  border: 1px solid #e8d9df;
  border-radius: 10px;
  background: #f9f3f5;
  box-sizing: border-box;
}
#page-content .attendance-register .attendance-switch > .btn {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 36px;
  height: auto;
  margin: 0;
  padding: .38rem .85rem;
  border: 0;
  border-radius: 7px;
  box-shadow: none;
  font-size: .875rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}
#page-content .attendance-switch > .btn[aria-pressed="true"] { color: white; background: #951740; }
#page-content .attendance-switch > .btn[aria-pressed="false"] { color: #54343f; background: transparent; }
#page-content .attendance-switch > .btn:focus-visible { outline: 2px solid #86123a; outline-offset: 2px; }
#page-content .attendance-register .attendance-controls,
#page-content .attendance-register .attendance-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem .75rem;
  min-width: 0;
  max-width: 100%;
}
#page-content .attendance-register .attendance-controls { align-items: end; }
#page-content .attendance-register .attendance-month {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: end;
  gap: 4px;
  width: 17.5rem;
  max-width: 100%;
}
#page-content .attendance-register .field { display: grid; gap: 4px; min-width: 0; margin: 0; }
#page-content .attendance-register .attendance-controls > .field { width: 12.5rem; max-width: 100%; }
#page-content .attendance-register .field :is(input, select),
#page-content .attendance-register .attendance-month .btn {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
}
#page-content .attendance-register .attendance-month .btn { padding: 0; margin: 0; font-size: 1.2rem; }
#page-content .attendance-register .attendance-identity > strong { overflow-wrap: anywhere; }
@container attendance-register (max-width: 40rem) {
  #page-content .attendance-register :is(.attendance-toolbar, .attendance-viewbar) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .65rem;
  }
  #page-content .attendance-register .attendance-controls { justify-content: flex-start; }
  #page-content .attendance-register .attendance-identity { justify-content: space-between; }
  #page-content .attendance-register .attendance-switch > .btn { min-height: 42px; }
}
@container attendance-register (max-width: 30rem) {
  #page-content .attendance-register .attendance-switch:has(:nth-child(2)) { width: 100%; }
  #page-content .attendance-register .attendance-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  #page-content .attendance-register .attendance-controls > :is(.attendance-month, .field) { width: 100%; }
  #page-content .attendance-register .attendance-month { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  #page-content .attendance-register .attendance-controls :is(input, select, .btn) { min-height: 44px; }
}
