:root {
  color-scheme: light;
  font-family: Tahoma, Arial, sans-serif;
  background: #f3f6f8;
  color: #17212b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
body { background: linear-gradient(180deg, #eef5f2 0, #f5f7f9 280px); }
button, input { font: inherit; font-size: 16px; }
button, a, input { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: 100%;
  min-height: 100vh;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.card {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 22px 18px;
  background: #fff;
  border: 1px solid #dbe3e8;
  border-radius: 18px;
  box-shadow: 0 12px 35px rgba(24, 47, 66, .08);
}

.login-card { max-width: 430px; margin-top: min(14vh, 110px); }
h1 { margin: 0 0 10px; font-size: clamp(1.55rem, 7vw, 2rem); line-height: 1.35; }
h2 { margin: 0 0 14px; font-size: 1.2rem; }
h3 { margin: 18px 0 8px; font-size: 1rem; }
p { line-height: 1.65; }
.muted, .field-help { color: #61707c; }
.field-help { margin: -2px 0 8px; font-size: .92rem; }
.page-header { margin-bottom: 22px; }
.next-point { margin: 8px 0 0; font-size: 1.08rem; }
.next-point strong { display: inline-block; min-width: 42px; color: #075d3c; }

.stack-form { display: grid; gap: 10px; }
label { font-weight: 700; }
input[type="text"], input[type="password"], input[type="file"] {
  width: 100%; min-height: 50px; padding: 11px 12px; border: 1px solid #aebbc5; border-radius: 10px;
  background: #fff; color: #17212b;
}
input:focus { outline: 3px solid rgba(15, 105, 73, .2); border-color: #0f6949; }

.attendance-form { display: grid; gap: 14px; }
.action-button, .primary-button, .secondary-button, .danger-outline-button {
  min-height: 52px; width: 100%; border: 0; border-radius: 12px; padding: 12px 18px;
  font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.action-button { min-height: 62px; color: #fff; font-size: 1.16rem; }
.check-in, .primary-button { background: #087443; color: #fff; }
.check-out { background: #bd2e35; }
.secondary-button { background: #e7edf1; color: #243746; }
.danger-outline-button { margin-top: 12px; border: 2px solid #a6232b; color: #a6232b; background: #fff; }
button:disabled { opacity: .58; cursor: wait; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: #334957; }
.loading[hidden] { display: none; }
.spinner { width: 22px; height: 22px; border: 3px solid #ccd9d3; border-top-color: #087443; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.8s; } }

.result-box { margin-top: 24px; padding: 18px 14px; background: #f7fafb; border: 1px solid #dce5e9; border-radius: 14px; }
.result-grid { display: grid; grid-template-columns: minmax(115px, auto) minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.result-grid dt { font-weight: 700; color: #4a5e6c; }
.result-grid dd { margin: 0; overflow-wrap: anywhere; }
.response-body { direction: ltr; text-align: left; unicode-bidi: plaintext; max-width: 100%; max-height: 340px; overflow: auto; margin: 0; padding: 12px; border-radius: 9px; background: #17212b; color: #f4f7f8; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Consolas, monospace; font-size: .86rem; }

.alert { padding: 11px 12px; border-radius: 9px; overflow-wrap: anywhere; }
.error { background: #fdecee; color: #831c25; border: 1px solid #f2bdc2; }
.success { background: #e7f7ef; color: #075c38; border: 1px solid #a8ddc2; }
.warning { background: #fff7df; color: #6e4a00; border: 1px solid #efd589; }
.token-status { font-weight: 700; color: #075c38; }
.settings-section { padding: 20px 0; border-top: 1px solid #e0e7eb; }
.settings-section + .settings-section { margin-top: 8px; }
.page-actions { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 14px; margin-top: 24px; }
.text-link { color: #075d80; font-weight: 700; text-underline-offset: 3px; }

.confirm-overlay {
  position: fixed; inset: 0; z-index: 1000; padding: 20px;
  background: rgba(15, 25, 33, .64); display: grid; place-items: center;
}
.confirm-overlay[hidden] { display: none; }
.confirm-dialog {
  width: min(100%, 420px); padding: 24px 20px; border-radius: 16px;
  background: #fff; box-shadow: 0 20px 55px rgba(0, 0, 0, .28); text-align: center;
}
.confirm-dialog h2 { margin-bottom: 8px; }
.confirm-dialog p { margin: 0 0 20px; color: #435461; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.confirm-yes, .confirm-no {
  min-height: 52px; border: 0; border-radius: 11px; color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.confirm-yes { background: #087443; }
.confirm-no { background: #bd2e35; }

@media (min-width: 640px) {
  .page-shell { padding-top: 42px; }
  .card { padding: 30px; }
  .attendance-form { grid-template-columns: 1fr 1fr; }
  .attendance-form .loading { grid-column: 1 / -1; }
}
