* { box-sizing: border-box; }
html { min-height: 100%; background: #f3f7fc; }
body { min-height: 100vh; min-height: 100dvh; margin: 0; padding-bottom: env(safe-area-inset-bottom); background: #f3f7fc; color: #102038; font-family: Arial, sans-serif; }
header { position: relative; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: max(15px, env(safe-area-inset-top)) max(5%, env(safe-area-inset-right)) 15px max(5%, env(safe-area-inset-left)); background: #081a33; color: white; }
header strong { font-size: 25px; }
header small { color: #85adff; }
nav { display: flex; align-items: center; gap: 15px; }
nav a, nav button { border: 0; background: none; color: white; text-decoration: none; font-weight: bold; cursor: pointer; }
nav form { margin: 0; }
.mobile-nav-toggle { display: none; width: 46px; height: 46px; border: 1px solid #ffffff40; border-radius: 11px; background: #ffffff12; color: #fff; font-size: 25px; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.connection-banner { position: sticky; top: 0; z-index: 100; padding: 12px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); background: #fef3c7; color: #7c2d12; text-align: center; }
.connection-banner[hidden] { display: none; }
.install-app-button { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 50; padding: 13px 17px; border: 1px solid #9dbdff; border-radius: 999px; background: #081a33; color: #fff; box-shadow: 0 12px 35px #06152c55; font: inherit; font-weight: 800; cursor: pointer; }
.install-app-button[hidden] { display: none; }
.install-help-dialog { width: min(440px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 20px; color: #102038; box-shadow: 0 24px 80px #06152c66; }
.install-help-dialog::backdrop { background: #06152cbf; backdrop-filter: blur(3px); }
.install-help-card { padding: 28px; }
.install-help-card h2 { margin: 5px 0 14px; font-size: 28px; }
.install-help-card p:not(.eyebrow) { color: #52647d; line-height: 1.6; }
.install-help-card .primary { margin-top: 10px; }
.container { width: min(920px, 90%); margin: 55px auto; }
.eyebrow { color: #1646a0; font-weight: bold; text-transform: uppercase; }
h1 { margin: 5px 0 30px; font-size: clamp(36px, 7vw, 58px); }
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: linear-gradient(135deg, #06152c, #1646a0); }
.brand { display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; }
.brand b { font-size: clamp(70px, 13vw, 150px); }
.brand span { letter-spacing: .3em; }
.login form { align-self: center; width: min(430px, 88%); margin: auto; padding: 38px; border-radius: 20px; background: white; }
.login label { display: grid; gap: 7px; margin: 20px 0; font-weight: bold; }
.login input { padding: 14px; border: 1px solid #cad5e7; border-radius: 9px; font-size: 17px; }
.primary, .mark { width: 100%; padding: 16px; border: 0; border-radius: 10px; background: #1646a0; color: white; font-size: 18px; font-weight: bold; cursor: pointer; }
.clock-card { padding: 35px; border-radius: 20px; background: white; box-shadow: 0 15px 35px #10204018; text-align: center; }
#clock { font-size: clamp(22px, 5vw, 38px); font-weight: bold; }
.attendance-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 680px; margin: 25px auto 5px; }
.mark.entry { background: #16804a; }
.mark.exit { background: #c43b31; }
.mark:disabled { background: #d8dee8; color: #7b8799; cursor: not-allowed; }
.location-dialog { width: min(680px, calc(100% - 28px)); max-height: min(90vh, 780px); padding: 0; overflow: auto; border: 0; border-radius: 20px; color: #102038; box-shadow: 0 24px 80px #06152c55; }
.location-dialog::backdrop { background: #06152cbf; backdrop-filter: blur(3px); }
.location-dialog__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 24px 24px 14px; }
.location-dialog__header .eyebrow { margin: 0 0 5px; }
.location-dialog__header h2 { margin: 0; }
.dialog-close { width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 50%; background: #edf2f8; color: #102038; font-size: 28px; line-height: 1; cursor: pointer; }
.location-loading { min-height: 330px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 35px; text-align: center; }
.location-loading p { color: #64748b; }
.location-spinner { width: 48px; height: 48px; margin-bottom: 20px; border: 5px solid #dce6f5; border-top-color: #1646a0; border-radius: 50%; animation: location-spin .8s linear infinite; }
@keyframes location-spin { to { transform: rotate(360deg); } }
.location-preview { display: grid; gap: 15px; padding: 0 24px; }
.location-preview[hidden], .location-loading[hidden], .location-error[hidden] { display: none !important; }
#location-map { width: 100%; height: 330px; border: 1px solid #cad5e7; border-radius: 14px; background: #e8eef6; }
.location-details { padding: 14px 16px; border-radius: 12px; background: #edf5ff; }
.location-details p { margin: 6px 0; }
.location-details small { color: #52647d; }
.location-error { margin: 18px 24px 0; padding: 14px; border-radius: 10px; background: #ffe4e1; color: #8c241d; }
.location-dialog__actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; padding: 20px 24px 24px; }
.location-dialog__actions .primary:disabled { background: #aab7ca; cursor: wait; }
.secondary { padding: 14px; border: 1px solid #cad5e7; border-radius: 10px; background: white; color: #102038; font-size: 17px; font-weight: bold; cursor: pointer; }
.records { display: grid; gap: 10px; }
.records article { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; padding: 17px; border-radius: 11px; background: white; }
.records a { color: #1646a0; }
.stats { display: flex; gap: 18px; }
.stats div { display: flex; flex-direction: column; min-width: 170px; padding: 25px; border-radius: 15px; background: white; }
.stats b { color: #1646a0; font-size: 35px; }
.table { overflow: auto; border-radius: 12px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px; border-bottom: 1px solid #e5eaf2; text-align: left; }
.alert { width: min(500px, 90%); margin: 20px auto; padding: 13px; border-radius: 8px; background: #ffe4e1; color: #8c241d; }
@media (max-width: 700px) {
  .login { grid-template-columns: 1fr; }
  .brand { min-height: 210px; }
  .brand b { font-size: 75px; }
  .login form { margin: -20px auto 30px; }
  header { align-items: center; }
  .mobile-nav-toggle { display: grid; place-items: center; }
  nav { position: absolute; top: calc(100% - 1px); right: max(12px, env(safe-area-inset-right)); left: max(12px, env(safe-area-inset-left)); display: none; align-items: stretch; flex-direction: column; gap: 3px; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); padding: 12px; overflow: auto; border: 1px solid #ffffff20; border-radius: 0 0 16px 16px; background: #081a33; box-shadow: 0 18px 40px #06152c66; }
  nav.is-open { display: flex; }
  nav a, nav button { display: block; width: 100%; min-height: 45px; padding: 12px; border-radius: 9px; text-align: left; }
  nav a:hover, nav button:hover { background: #ffffff12; }
  nav form { width: 100%; }
  .attendance-actions { grid-template-columns: 1fr; }
  .records article { grid-template-columns: 1fr; }
  .stats { flex-direction: column; }
  .location-dialog__header { padding: 20px 18px 12px; }
  .location-preview { padding: 0 18px; }
  #location-map { height: 280px; }
  .location-dialog__actions { padding: 18px; }
  .container { width: min(100% - 28px, 920px); margin: 34px auto; }
  h1 { font-size: clamp(32px, 11vw, 46px); }
  input, select, textarea { font-size: 16px; }
  .install-app-button { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .location-dialog__actions { grid-template-columns: 1fr; }
  .location-dialog { width: calc(100% - 18px); max-height: 94dvh; }
  #location-map { height: 240px; }
}

@media (display-mode: standalone) {
  .install-app-button { display: none !important; }
}
