:root {
  --ink: #182225;
  --muted: #68767c;
  --line: #dce5e8;
  --bg: #f4f7f6;
  --card: #ffffff;
  --brand: #14705b;
  --brand-dark: #10272b;
  --accent: #d97706;
  --ok: #15803d;
  --warn: #a16207;
  --danger: #b42318;
  --tech-safe-top: env(safe-area-inset-top, 0px);
  --tech-safe-bottom: var(--bm-safe-bottom, env(safe-area-inset-bottom, 0px));
  --tech-tabbar-base-height: 68px;
  --tech-tabbar-extra-gap: 8px;
  --tech-content-bottom-gap: 16px;
  --tech-app-max-width: 760px;
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

.teacher-time-off,.time-off-form{display:grid;gap:12px}.time-off-form label,.teacher-time-off>label{display:grid;gap:6px}.time-off-form input,.time-off-form textarea,.teacher-time-off input{min-height:48px;border:1px solid var(--line,#cbd8d4);border-radius:12px;padding:10px;font:inherit}.time-off-form textarea{min-height:76px;resize:vertical}.teacher-time-off .job-actions{display:flex;gap:8px;flex-wrap:wrap}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: #e9f4f1;
  color: var(--brand);
  border: 1px solid #bad8d0;
}

button.ghost {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #efbbb5;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: white;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(rgba(16, 39, 43, 0.78), rgba(20, 112, 91, 0.68)),
    url("https://images.unsplash.com/photo-1540555700478-4be289fbecef?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.login-screen.bm-bg-active {
  background: transparent;
}

.login-card {
  width: min(100%, 380px);
  display: grid;
  gap: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  padding: 26px;
  box-shadow: 0 18px 40px rgba(16, 39, 43, 0.22);
}

.app-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--brand-dark);
  font-weight: 900;
}

img.app-logo {
  object-fit: contain;
  background: #fff;
}

.login-card h1 {
  margin: 4px 0 0;
}

.login-card p,
.login-card small {
  color: var(--muted);
  line-height: 1.6;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.password-field input {
  width: 100%;
}

.password-toggle {
  min-width: 64px;
  padding: 0 12px;
  border: 1px solid #c9d6d1;
  border-radius: 10px;
  background: #f3f7f5;
  color: var(--ink, #16352f);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.password-toggle[aria-pressed="true"] {
  background: #e7f6ef;
  border-color: #9fd0bf;
}

.auth-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.auth-ok {
  min-height: 20px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 800;
}

.login-aux-btn {
  width: 100%;
  margin-top: 4px;
}

.change-password-form {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.change-password-form.hidden,
.hidden {
  display: none !important;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.app-screen {
  width: min(100%, var(--tech-app-max-width));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(14px + var(--tech-safe-top)) 14px calc(var(--tech-tabbar-base-height) + var(--tech-safe-bottom) + var(--tech-content-bottom-gap));
  background: var(--bg);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 4px 16px;
}

.app-header span {
  color: var(--muted);
  font-size: 13px;
}

.app-header h1 {
  margin: 2px 0 0;
  font-size: 23px;
}

.app-header button {
  width: 44px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.app-header button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-strip {
  display: grid;
  gap: 4px;
  border: 1px solid #b7d7cf;
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  background: #eef8f4;
  padding: 11px;
  margin-bottom: 12px;
}

.privacy-strip span {
  color: #496760;
  font-size: 13px;
  line-height: 1.5;
}

.today-overview {
  margin-bottom: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 2px 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 0;
}

.summary-grid article,
.panel,
.job-card,
.notice-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.summary-grid article {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.summary-grid span,
.mini {
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 20px;
}

.summary-grid strong.muted-strong {
  color: var(--muted);
  font-size: 18px;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, var(--tech-app-max-width));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  min-height: calc(var(--tech-tabbar-base-height) + var(--tech-safe-bottom));
  padding: 8px 10px calc(var(--tech-tabbar-extra-gap) + var(--tech-safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 40;
}

.tabbar button {
  min-height: 48px;
  background: white;
  color: var(--muted);
  border: 1px solid transparent;
}

.tabbar button.active {
  background: var(--brand);
  color: white;
}

.content {
  display: grid;
  gap: 12px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-body {
  padding: 13px;
}

.job-list {
  display: grid;
  gap: 10px;
}

.queue-actions {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.work-control-panel .queue-actions {
  margin-bottom: 0;
}

.work-control-panel .queue-actions button {
  min-height: 40px;
  background: #fff;
  color: var(--muted);
  border-color: var(--line);
  font-weight: 700;
}

.next-booking-panel .job-card {
  border-width: 2px;
  border-color: #54a38e;
  background: #f5fbf8;
}

.next-booking-panel button[data-start]:not(:disabled) {
  min-height: 54px;
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-size: 17px;
  box-shadow: 0 8px 18px rgba(20, 112, 91, 0.2);
}

.home-empty-state {
  display: grid;
  gap: 5px;
  padding: 16px;
  border: 1px dashed #cbd8d4;
  border-radius: 10px;
  background: #f8fbfa;
  color: var(--muted);
  text-align: center;
}

.home-empty-state strong {
  color: var(--ink);
}

.home-empty-state.compact {
  padding: 12px;
}

.schedule-toggle {
  width: 100%;
  margin-top: 12px;
}

.job-card {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.job-card.active {
  border-color: #e4ad5e;
  background: #fffaf2;
}

.job-top,
.job-actions,
.record-line,
.pay-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.job-actions {
  flex-wrap: wrap;
}

.job-actions button {
  flex: 1;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef3f0;
  color: #255b4f;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status.ok {
  background: #dcfce7;
  color: #166534;
}

.status.warn {
  background: #fef3c7;
  color: #92400e;
}

.status.danger {
  background: #fee2e2;
  color: #991b1b;
}

.note-form {
  display: grid;
  gap: 11px;
}

.record-list,
.notice-list,
.pay-list {
  display: grid;
  gap: 9px;
}

.record-line,
.pay-line,
.notice-card {
  padding: 11px;
  background: white;
}

.late-record-item {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.late-record-item > summary {
  display: grid;
  gap: 4px;
  cursor: pointer;
  list-style-position: inside;
}

.late-record-item[open] > summary {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.notice-card {
  display: grid;
  gap: 6px;
}

.more-list {
  display: grid;
  gap: 12px;
}

.more-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.more-card h3 {
  margin: 0;
  font-size: 17px;
}

.more-profile {
  display: grid;
  gap: 8px;
  margin: 0;
}

.more-profile div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.more-profile dt {
  color: var(--muted);
}

.more-profile dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.more-logout-card button {
  width: 100%;
}

.booking-alert {
  position: fixed;
  inset: 0;
  z-index: 2147483550;
  display: grid;
  place-items: start center;
  padding: calc(12px + var(--tech-safe-top)) 12px calc(12px + var(--tech-safe-bottom));
  background: rgba(15, 23, 42, 0.48);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.booking-alert.hidden {
  display: none;
}

.booking-alert-card {
  width: min(100%, 430px);
  max-height: calc(100dvh - var(--tech-safe-top) - var(--tech-safe-bottom) - 24px);
  display: grid;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: #ffffff;
  border: 2px solid #0f766e;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.24);
  -webkit-overflow-scrolling: touch;
}

.booking-alert-card h2 {
  margin: 0;
  font-size: 22px;
}

.booking-alert-card p {
  margin: 0;
}

.booking-alert-card.pending-confirm {
  border-color: #d97706;
}

.booking-alert-card.pending-confirm .job-actions.pending-decision {
  grid-template-columns: minmax(0, 1fr);
  gap: 40px;
  position: static;
  margin-top: 24px;
  padding: 0;
}

.booking-alert-card.pending-confirm .job-actions.pending-decision button {
  min-height: 84px;
  font-size: 24px;
  font-weight: 800;
  width: 100%;
  margin: 0;
}

.booking-alert-card.pending-confirm {
  width: min(100%, 640px);
  min-height: min(600px, calc(100dvh - var(--tech-safe-top) - var(--tech-safe-bottom) - 24px));
  align-content: start;
  padding: 24px;
}

.booking-alert-card.pending-confirm [data-request-decision="reject"] {
  background: #fff;
  color: #b91c1c;
  border: 2px solid #b91c1c;
}

.job-actions:has(> [data-request-decision="accept"]):has(> [data-request-decision="reject"]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}

.job-actions > [data-request-decision] {
  min-height: 72px;
  font-size: 22px;
}

.booking-alert-card.onsite-waiting {
  border-color: #b91c1c;
  background: #fff5f5;
}

.booking-alert-card.onsite-waiting .job-actions button.danger {
  min-height: 56px;
  font-size: 20px;
  font-weight: 800;
  background: #b91c1c;
  color: #fff;
  border: 0;
}

.alert-kicker.pending {
  color: #d97706;
}

.alert-kicker.danger {
  color: #b91c1c;
  font-weight: 800;
}

.booking-alert-card .job-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 10px 0;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.booking-alert-card .job-actions.single {
  grid-template-columns: 1fr;
}

.booking-alert-card .job-actions button {
  min-height: 52px;
}

.alert-kicker {
  color: #0f766e;
  font-size: 13px;
  font-weight: 900;
}

@media (max-width: 390px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .job-top,
  .record-line,
  .pay-line {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (min-width: 700px) {
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-screen {
    padding-inline: 20px;
  }
}

@media (max-width: 700px) {
  .booking-alert {
    align-content: start;
    padding: calc(12px + var(--tech-safe-top)) 10px calc(92px + var(--tech-safe-bottom));
    place-items: start stretch;
  }
  .booking-alert-card {
    width: 100%;
    min-height: 0;
    max-height: calc(100dvh - var(--tech-safe-top) - var(--tech-safe-bottom) - 112px);
    border-radius: 14px;
    border-width: 2px;
    padding: 18px 16px calc(18px + var(--tech-safe-bottom));
    align-content: start;
  }
}
.more-link-button{display:flex;align-items:center;justify-content:center;min-height:48px;border-radius:12px;text-decoration:none;font-weight:800}
.booking-date-groups{display:grid;gap:12px}
.booking-date-group{border:1px solid var(--line);border-radius:16px;background:#fff;overflow:hidden}
.booking-date-group>summary{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;cursor:pointer;font-weight:800;color:var(--ink);background:#f2faf7}
.booking-date-group>summary::-webkit-details-marker{display:none}
.booking-date-group>summary strong{display:inline-flex;align-items:center;justify-content:center;min-width:48px;padding:4px 10px;border-radius:999px;background:#e0f4ed;color:var(--brand);font-size:13px}
.booking-date-group .job-list{padding:12px}

body.history-query-open{overflow:hidden}
.history-query-overlay{position:fixed;inset:0;z-index:220;display:none;place-items:stretch;padding:env(safe-area-inset-top,0px) 0 env(safe-area-inset-bottom,0px);background:rgba(15,23,42,.72)}
.history-query-overlay.is-open{display:grid!important}
.history-query-overlay.hidden{display:none!important}
.history-query-dialog{width:100%;max-width:none;height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));max-height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));display:grid;grid-template-rows:auto minmax(0,1fr);overflow:hidden;border-radius:0}
.history-query-dialog .panel-body{min-height:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.history-query-dialog .form-stack{display:grid;gap:10px;margin-bottom:12px}
.history-query-dialog #teacherHistoryResults{margin-top:8px}
