:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #17212f;
  --muted: #637082;
  --line: #d6e0e8;
  --brand: #126c68;
  --brand-strong: #0c5551;
  --brand-soft: #e4f2f0;
  --accent: #245aa5;
  --accent-soft: #e7eef8;
  --warning: #a05a12;
  --good: #13724d;
  --danger: #b33b3f;
  --shadow: 0 16px 36px rgba(27, 40, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft JhengHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 22px;
}

.is-hidden {
  display: none !important;
}

.clock-panel {
  display: grid;
  min-width: 220px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: right;
}

.clock-panel span {
  color: var(--muted);
  font-size: 13px;
}

.clock-panel strong {
  font-size: 28px;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.login-view {
  display: grid;
  min-height: calc(100vh - 180px);
  align-items: center;
}

.login-panel {
  display: grid;
  gap: 18px;
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.attendance-view {
  display: grid;
  gap: 18px;
}

.employee-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.employee-strip div {
  display: grid;
  gap: 2px;
}

.employee-strip span,
.employee-strip small,
.network-panel small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.employee-strip strong {
  font-size: 22px;
}

.punch-panel,
.summary-panel,
.records-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.punch-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
}

.full-span {
  grid-column: 1 / -1;
}

.panel-title,
.location-panel,
.network-panel {
  grid-column: 1 / -1;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  min-width: 76px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf1f5;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.status-pill.is-online {
  background: #e2f4ed;
  color: var(--good);
}

.status-pill.is-warning {
  background: #f8eadc;
  color: var(--warning);
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.location-panel span,
.network-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 92, 168, 0.16);
}

.location-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  padding: 12px;
}

.network-panel {
  display: flex;
  min-height: 72px;
  border: 1px solid #c9dfdc;
  border-radius: 8px;
  background: var(--brand-soft);
  padding: 13px 14px;
}

.network-panel div,
.location-panel div {
  display: grid;
  gap: 4px;
}

.location-panel strong,
.network-panel strong {
  font-size: 14px;
}

.network-panel.is-offsite {
  border-color: var(--line);
  background: #f7f9fb;
}

.network-panel.is-active {
  border-color: #9ed1c8;
  background: #dff2ee;
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease;
}

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

button:active {
  transform: translateY(0);
}

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

.primary-btn {
  background: var(--brand);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--brand-strong);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.secondary-btn:hover {
  background: #f2f5f8;
}

.secondary-btn.compact {
  min-width: 108px;
  min-height: 40px;
  padding: 0 12px;
}

.summary-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
}

.stat-block {
  display: grid;
  min-height: 82px;
  align-content: center;
  gap: 6px;
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #f8fafb;
  padding: 16px;
}

.stat-block.online {
  border-left-color: var(--good);
}

.stat-block.warning {
  border-left-color: var(--danger);
}

.stat-block.latest {
  border-left-color: var(--warning);
}

.stat-block span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-block strong {
  font-size: 26px;
  line-height: 1.1;
}

.records-section {
  padding: 18px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-actions input {
  min-width: 230px;
  min-height: 40px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #eef3f7;
  color: #364255;
  font-size: 13px;
}

td {
  font-size: 14px;
}

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

.employee-cell {
  display: grid;
  gap: 3px;
}

.employee-cell strong {
  font-size: 15px;
}

.employee-cell span,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

.record-status,
.range-pill {
  display: inline-flex;
  min-width: 56px;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.record-status.online,
.range-pill.ok {
  background: #e2f4ed;
  color: var(--good);
}

.record-status.offline {
  background: #f4e8df;
  color: var(--warning);
}

.record-source {
  display: grid;
  gap: 3px;
}

.record-source strong {
  font-size: 14px;
}

.record-source span {
  color: var(--muted);
  font-size: 12px;
}

.range-pill.warn {
  background: #fae7e7;
  color: var(--danger);
}

.range-pill.neutral {
  background: #edf1f5;
  color: var(--muted);
}

.empty-state {
  height: 130px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .employee-strip,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .clock-panel {
    min-width: 0;
    text-align: left;
  }

  .control-grid,
  .punch-panel {
    grid-template-columns: 1fr;
  }

  .action-row,
  .table-actions {
    grid-template-columns: 1fr;
  }

  .location-panel,
  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions input,
  .secondary-btn.compact {
    width: 100%;
    min-width: 0;
  }

  .login-view {
    min-height: auto;
  }
}
