:root {
  --ink: #111614;
  --muted: #5d6762;
  --paper: #f5f3ed;
  --panel: #fffdf8;
  --line: #d8d4c9;
  --red: #c6212f;
  --green: #2f7f5f;
  --amber: #c69232;
  --steel: #29343a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1fr);
}

.hero {
  min-height: 100vh;
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(17, 22, 20, 0.12), rgba(17, 22, 20, 0.7)),
    url("/assets/t33-hero.jpg") center / cover;
  color: #fffdf8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand-line,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-line span {
  letter-spacing: 0.22em;
  font-size: 18px;
  font-weight: 700;
}

.brand-line a,
.admin-header a {
  text-decoration: none;
  border: 1px solid currentColor;
  padding: 8px 14px;
}

.kicker {
  color: var(--red);
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 12px;
  text-transform: uppercase;
}

.hero .kicker {
  color: #fff;
}

h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  margin: 20px 0 0;
  font-size: 24px;
}

.workbench {
  padding: 42px;
  align-self: center;
}

.lookup-panel,
.checkin-form,
.pin-panel,
.table-panel,
.metric-main {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(17, 22, 20, 0.08);
}

.lookup-panel,
.checkin-form {
  padding: 28px;
}

.lookup-panel {
  margin-bottom: 18px;
}

label,
.signature-head {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  outline-color: var(--red);
}

.lookup-row button,
.signature-head button,
.admin-actions button {
  background: var(--steel);
  color: #fff;
  padding: 0 18px;
  min-height: 48px;
}

.employee-card {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  border-left: 5px solid var(--red);
  background: #f8f6ef;
}

.employee-card div {
  display: grid;
  gap: 5px;
}

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

.employee-card.is-empty {
  grid-template-columns: 1fr;
  border-left-color: var(--amber);
}

.employee-card.is-complete {
  border-left-color: var(--green);
}

.field-grid {
  display: grid;
  grid-template-columns: 0.65fr 1fr;
  gap: 16px;
}

.signature-block {
  margin-top: 20px;
}

.signature-head {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 8px;
}

canvas {
  width: 100%;
  height: clamp(260px, 44vh, 420px);
  border: 1px solid var(--line);
  background: #fff;
  touch-action: none;
}

.submit-btn {
  width: 100%;
  margin-top: 18px;
  min-height: 56px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.submit-btn:disabled {
  background: #a9aca7;
  cursor: not-allowed;
}

.message {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.message[data-tone="ok"] {
  color: var(--green);
}

.message[data-tone="warn"] {
  color: var(--red);
}

.admin-page {
  background:
    linear-gradient(90deg, rgba(198, 33, 47, 0.08) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: 24px 24px;
}

.admin-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0 60px;
}

.admin-header {
  margin-bottom: 22px;
}

.admin-header h1 {
  font-size: clamp(34px, 5vw, 58px);
}

.pin-panel {
  padding: 22px;
  margin-bottom: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.metric-main {
  padding: 22px;
  display: grid;
  gap: 8px;
}

.metric-main strong {
  font-size: 64px;
  line-height: 1;
  color: var(--red);
}

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

.location-meter {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
}

.location-meter div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

meter {
  width: 100%;
  height: 14px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

.employee-manager {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-head {
  display: grid;
  grid-template-columns: 1fr minmax(190px, 260px);
  gap: 14px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  padding: 0;
  border-bottom: 0;
}

.compact-search {
  gap: 6px;
  font-size: 13px;
}

.employee-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.employee-form input {
  min-height: 44px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-actions button,
.row-actions button {
  min-height: 44px;
  padding: 0 14px;
  background: var(--steel);
  color: #fff;
}

.form-actions button:first-child {
  background: var(--red);
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}

.row-actions button:last-child {
  background: #6c6257;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: #fff;
  background: var(--amber);
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.is-ok {
  background: var(--green);
}

.status-pill.is-muted {
  background: #7a817c;
}

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

.table-panel {
  min-width: 0;
}

.table-panel h2 {
  margin: 0;
  padding: 16px 18px;
  font-size: 20px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  max-height: 520px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e8e4dc;
  text-align: left;
  white-space: nowrap;
}

.signature-thumb {
  width: 120px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
}

.signature-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.signature-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 22, 20, 0.72);
}

.signature-dialog__panel {
  width: min(760px, 96vw);
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px;
}

.signature-dialog__panel img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.signature-dialog__close {
  min-height: 42px;
  margin-bottom: 12px;
  padding: 0 16px;
  background: var(--steel);
  color: #fff;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0ece2;
  color: var(--steel);
}

@media (max-width: 880px) {
  .shell,
  .metrics,
  .admin-grid,
  .employee-manager,
  .field-grid,
  .employee-card {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 46vh;
    padding: 28px;
  }

  .workbench {
    padding: 18px;
    align-self: start;
  }

  .lookup-panel,
  .checkin-form {
    padding: 18px;
  }

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

  .lookup-row button,
  .submit-btn {
    min-height: 54px;
  }

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

  .admin-shell {
    width: min(calc(100vw - 28px), 520px);
    padding-top: 22px;
  }

  .admin-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 12px;
  }

  .admin-header h1 {
    font-size: 32px;
    line-height: 1.12;
    word-break: keep-all;
    overflow-wrap: normal;
  }

  .admin-header a {
    padding: 8px 10px;
    white-space: nowrap;
  }

  .pin-panel {
    padding: 16px;
  }

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

  .admin-actions button {
    min-height: 46px;
  }

  .panel-head {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .employee-form {
    padding: 16px;
  }

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

  .roster-wrap {
    max-height: 440px;
  }

  .table-panel h2 {
    font-size: 18px;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 13px;
  }

  .signature-thumb {
    width: 96px;
    height: 42px;
  }
}
