:root {
  --orange: #f2a51a;
  --orange-dark: #dc8c00;
  --orange-soft: #fff3d9;
  --blue: #075fba;
  --blue-dark: #064b91;
  --ink: #25313d;
  --muted: #7b8792;
  --line: #e7eaee;
  --surface: #ffffff;
  --background: #f7f8fa;
  --danger: #d64545;
  --success: #2c9b62;
  --shadow: 0 8px 28px rgba(32, 47, 61, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--background); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
svg { display: block; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; padding-bottom: 86px; }
.app-header { position: relative; overflow: hidden; padding: 18px 18px 30px; background: linear-gradient(145deg, var(--orange) 0%, #f6b32f 58%, #f8c75c 100%); border-radius: 0 0 30px 30px; }
.app-header::after { content: ""; position: absolute; width: 180px; height: 180px; right: -70px; bottom: -100px; border-radius: 50%; background: rgba(255,255,255,.18); }
.brand-lockup { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; max-width: 680px; margin: 0 auto; }
.brand-logo-wrap { width: 58px; height: 58px; flex: 0 0 58px; border-radius: 16px; padding: 5px; background: #fff; box-shadow: 0 5px 18px rgba(117,75,0,.16); overflow: hidden; }
.brand-logo { width: 100%; height: 100%; object-fit: contain; border-radius: 11px; }
.eyebrow { margin: 0 0 4px; color: var(--blue); font-size: .69rem; line-height: 1.2; font-weight: 800; letter-spacing: .1em; }
.app-header .eyebrow { color: rgba(40,55,68,.75); }
.app-header h1 { margin: 0; font-size: 1.08rem; line-height: 1.25; color: #24313b; }
.employee-main { width: min(100% - 28px, 680px); margin: -12px auto 0; position: relative; z-index: 2; }

.login-card, .profile-card, .attendance-card, .password-card, .account-card { background: var(--surface); border: 1px solid rgba(231,234,238,.8); box-shadow: var(--shadow); }
.login-card { margin-top: 30px; padding: 26px 20px; border-radius: 24px; text-align: center; }
.login-logo { width: 110px; height: 110px; margin: 0 auto 12px; padding: 8px; border: 1px solid var(--line); border-radius: 24px; background: #fff; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 16px; }
.login-eyebrow { color: var(--blue); }
.login-card h2 { margin: 0; font-size: 1.5rem; }
.muted { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.stack-form { display: grid; gap: 12px; text-align: left; margin-top: 22px; }
label { display: grid; gap: 7px; color: #4b5965; font-size: .88rem; font-weight: 700; }
input, select { width: 100%; min-height: 46px; border: 1px solid #d9dfe5; border-radius: 13px; padding: 10px 12px; outline: none; background: #fff; color: var(--ink); }
input:focus, select:focus { border-color: #8cb8e8; box-shadow: 0 0 0 3px rgba(7,95,186,.1); }
.primary-button, .secondary-button { min-height: 48px; border: 0; border-radius: 13px; padding: 10px 15px; font-weight: 800; transition: transform .15s ease, filter .15s ease; }
.primary-button { background: var(--orange); color: #fff; box-shadow: 0 7px 16px rgba(242,165,26,.22); }
.secondary-button { background: var(--blue); color: #fff; box-shadow: 0 7px 16px rgba(7,95,186,.18); }
.primary-button:active, .secondary-button:active { transform: translateY(1px); }

.profile-card { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 15px; border-radius: 22px; }
.avatar { width: 54px; height: 54px; color: #78838c; }
.avatar svg { width: 100%; height: 100%; }
.profile-copy h2 { margin: 0; font-size: 1.02rem; }
.profile-copy .muted { font-size: .82rem; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--muted); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.attendance-card { margin-top: 12px; padding: 18px; border-radius: 24px; }
.attendance-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.attendance-heading h2, .section-heading h2 { margin: 0; font-size: 1.12rem; }
.status-badge { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 10px; border-radius: 999px; background: var(--orange-soft); color: var(--orange-dark); font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-badge.present { background: #e8f7ef; color: var(--success); }
.status-badge.done { background: #e9f1fb; color: var(--blue); }
.date-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); color: #65727d; font-size: .84rem; font-weight: 650; }
.date-row svg { width: 18px; height: 18px; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.time-card { padding: 13px; border-radius: 16px; background: #fafbfc; border: 1px solid var(--line); }
.time-label { display: block; color: #7d8892; font-size: .76rem; font-weight: 700; }
.time-card strong { display: block; margin: 3px 0 1px; color: var(--blue); font-size: 1.5rem; letter-spacing: -.02em; }
.time-card small { color: #89939b; font-size: .72rem; }
.location-panel { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 11px 12px; border-radius: 15px; background: #f5f8fc; }
.location-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; border-radius: 11px; background: #e7f0fb; color: var(--blue); }
.location-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.location-panel strong, .location-panel span { display: block; }
.location-panel strong { font-size: .8rem; }
.location-panel span { margin-top: 2px; color: var(--muted); font-size: .75rem; word-break: break-word; }
.attendance-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; }
.action-button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.action-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.message { min-height: 20px; margin: 10px 0 0; color: #b33c3c; font-size: .82rem; line-height: 1.4; }
.hint { margin: 9px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.4; }

.camera-panel { margin-top: 14px; padding: 12px; border: 1px dashed #d7dfe8; border-radius: 17px; background: #fbfcfd; }
.camera-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 800; }
video { display: block; width: 100%; max-height: 52vh; object-fit: cover; border-radius: 14px; background: #151a1e; transform: scaleX(-1); }

.section-heading { display: flex; justify-content: space-between; align-items: center; }

.password-card, .account-card { margin-top: 12px; padding: 18px; border-radius: 24px; scroll-margin-top: 16px; }
.account-details { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: start; margin: 18px 0; padding: 16px; border-radius: 18px; background: #f7f9fb; }
.account-avatar { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: #e8f1fc; color: var(--blue); }
.account-avatar svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.account-fields { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.account-fields .muted { margin-top: 5px; font-size: .76rem; }
.account-fields strong { font-size: .95rem; }
.account-security, .logout-button { width: 100%; min-height: 46px; margin-top: 9px; border-radius: 13px; font: inherit; font-weight: 800; }
.account-security { border: 1px solid #dce6f1; }
.logout-button { border: 1px solid #f0d4d4; background: #fff7f7; color: #b42318; }
.bottom-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 9px max(12px, env(safe-area-inset-left)) calc(9px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right)); background: rgba(255,255,255,.96); border-top: 1px solid #e9ecef; box-shadow: 0 -8px 24px rgba(34,47,58,.08); backdrop-filter: blur(12px); }
.bottom-nav-item { display: grid; justify-items: center; gap: 3px; border: 0; background: transparent; color: #8a949c; font-size: .68rem; font-weight: 700; }
.bottom-nav-item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav-item.active { color: var(--orange-dark); }

/* Admin uses the employee app's existing palette, buttons and cards. */
.admin-shell { padding-bottom: 24px; }
.admin-main { width: min(100% - 28px, 1100px); margin-top: -12px; }
.admin-profile-card { margin-bottom: 12px; }
.admin-profile-card #admin-welcome { font-size: .82rem; }
.admin-profile-card .icon-button { width: auto; padding: 0 12px; font-size: .8rem; font-weight: 800; }
.admin-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.admin-tab { min-height: 44px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; }
.admin-tab.active { background: var(--orange-soft); color: var(--orange-dark); }
.admin-tab-panel { margin-top: 12px; min-width: 0; }
.admin-tab-panel h2 { margin: 0; font-size: 1.12rem; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; margin-top: 18px; }
.filters label { min-width: 0; }
.admin-actions { display: flex; margin: 12px 0; }
.admin-actions button { width: auto; }
.table-wrap { width: 100%; overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: .82rem; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { background: #f7f9fb; color: #53616d; font-size: .73rem; }
tbody tr:last-child td { border-bottom: 0; }
td img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
td button { min-height: 36px; margin: 2px; padding: 7px 10px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-size: .74rem; font-weight: 800; }
td button.secondary { background: #e8f1fc; color: var(--blue); }
td button.danger { background: #fff0f0; color: #b42318; }
.admin-app a { color: var(--blue); font-weight: 700; }
.admin-app .message { overflow-wrap: anywhere; }

@media (min-width: 700px) {
  .app-header { padding-inline: 24px; }
  .employee-main { width: min(100% - 40px, 680px); }
  .bottom-nav { left: 50%; right: auto; width: min(100% - 40px, 680px); transform: translateX(-50%); border-radius: 18px 18px 0 0; }
}

@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row > * { max-width: 100%; }
  .admin-main { width: min(100% - 20px, 1100px); }
  .admin-tab-panel { padding: 14px; }
}

@media (max-width: 380px) {
  .employee-main { width: min(100% - 20px, 680px); }
  .app-header { padding-inline: 12px; }
  .brand-logo-wrap { width: 50px; height: 50px; flex-basis: 50px; }
  .app-header h1 { font-size: .98rem; }
  .time-card strong { font-size: 1.3rem; }
}

/* Step 2: closer to the reference app's compact mobile dashboard. */
.header-topline {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(100%, 680px);
  margin: 0 auto 12px;
  color: rgba(36, 49, 59, .72);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .08em;
}
#live-clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.date-row { flex-wrap: wrap; }
.date-divider { color: #b4bcc4; }
.location-panel { position: relative; padding-right: 38px; }
.location-dot {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c4cbd1;
  box-shadow: 0 0 0 4px rgba(196,203,209,.2);
  transform: translateY(-50%);
}
.location-dot.ready {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(44,155,98,.14);
}

@media (max-width: 380px) {
  .header-topline { font-size: .59rem; }
  .date-row { font-size: .78rem; }
}
.reset-box { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.reset-box input { min-height: 36px; min-width: 150px; flex: 1 1 150px; padding: 6px 10px; font-size: .8rem; }


/* Mobile-first hardening: safe-area spacing, reliable touch targets and narrow-screen layout. */
.app-shell { min-height: 100svh; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.bottom-nav { padding-bottom: calc(9px + env(safe-area-inset-bottom)); }
.bottom-nav-item { min-height: 48px; padding: 3px 4px; }
button, input, select { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(7,95,186,.35); outline-offset: 2px; }
.table-wrap { max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
table { min-width: 620px; }
@media (max-width: 420px) {
  .attendance-card, .password-card, .account-card { padding: 14px; border-radius: 20px; }
  .profile-card { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 9px; padding: 12px; }
  .avatar { width: 42px; height: 42px; }
  .attendance-heading { flex-wrap: wrap; }
  .attendance-actions { grid-template-columns: 1fr; }
  .action-button { min-height: 50px; }
  .time-grid { gap: 8px; }
  .time-card { padding: 11px 9px; }
  .account-details { grid-template-columns: 46px minmax(0, 1fr); gap: 10px; padding: 12px; }
  .account-avatar { width: 44px; height: 44px; border-radius: 14px; }
  .account-avatar svg { width: 24px; height: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
[hidden] { display: none !important; }
