:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --blue-light: #eff6ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation; /* disable double-tap-to-zoom */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
}

/* Header: blue background, white centered text */
.app-header {
  background: var(--blue);
  color: #fff;
  text-align: center;
  padding: 20px 16px 16px;
  position: relative;
}
.sign-out {
  position: absolute;
  top: 14px;
  right: 12px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sign-out[hidden] { display: none; }
.sign-out:hover { background: rgba(255, 255, 255, 0.28); }
.sign-out:active { background: rgba(255, 255, 255, 0.32); }
.app-header h1 { margin: 0; line-height: 0; }
.app-header .logo { height: 48px; max-height: 48px; max-width: 60vw; width: auto; display: block; margin: 0 auto; }
.app-header p { margin: 3px 0 0; color: #fff; opacity: 0.9; font-size: 0.9rem; }

main { max-width: 1150px; margin: 0 auto; padding: 18px 16px 48px; }

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}
.card h2 { margin: 0 0 10px; font-size: 1rem; }
.hint { color: var(--gray-500); font-size: 0.85rem; }
.center { text-align: center; }

.notice { border-left: 5px solid var(--blue); }
.notice.error { border-left-color: var(--red); }
.notice code { background: var(--gray-100); padding: 1px 5px; border-radius: 4px; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select, input[type="search"], input[type="text"] {
  padding: 9px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--gray-50);
  color: var(--gray-900);
}
select:focus, input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
#flt-search { min-width: 180px; }
#reviewer-name { width: 170px; }

.btn {
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--blue-light); color: var(--blue); }

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi { margin-bottom: 0; }
.kpi-label { font-size: 0.8rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.7rem; font-weight: 700; margin: 4px 0 2px; color: var(--blue-dark); }
.kpi-sub { font-size: 0.8rem; color: var(--gray-500); }

/* Charts */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.chart { margin-bottom: 0; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 80px; align-items: center; gap: 8px; font-size: 0.85rem; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--gray-100); border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { background: var(--blue); height: 100%; border-radius: 999px; min-width: 2px; }
.bar-value { text-align: right; font-weight: 600; }
.bars .empty { color: var(--gray-500); font-size: 0.85rem; }

/* Table */
.table-card { padding-bottom: 8px; }
.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--gray-100); white-space: nowrap; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--blue); }
th.sorted-asc::after { content: ' \25B2'; }
th.sorted-desc::after { content: ' \25BC'; }
th.num, td.num { text-align: right; }
td.merchant { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--blue-light); }
td .btn-row { display: flex; gap: 6px; }

.status-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.status-Submitted { background: #fef3c7; color: #92400e; }
.status-Approved { background: #dbeafe; color: #1e40af; }
.status-Rejected { background: #fee2e2; color: #991b1b; }
.status-Reimbursed { background: #dcfce7; color: #166534; }

.btn-mini {
  padding: 4px 9px;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-approve { background: #dcfce7; color: #166534; }
.btn-reject { background: #fee2e2; color: #991b1b; }
.btn-reimburse { background: #dbeafe; color: #1e40af; }
.btn-delete-receipt { background: var(--gray-100); color: var(--gray-500); }
.btn-delete-receipt:hover { background: #fee2e2; color: #991b1b; }
a.photo-link { color: var(--blue); font-weight: 600; text-decoration: none; }
a.photo-link:hover { text-decoration: underline; }

/* Modal */
.modal-overlay[hidden] { display: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.7rem;
  color: var(--gray-500);
  cursor: pointer;
  line-height: 1;
}
.modal img { max-width: 100%; max-height: 55vh; display: block; margin: 8px auto 12px; border-radius: 10px; border: 1px solid var(--gray-200); }
.modal p { margin: 4px 0; font-size: 0.9rem; }
.modal .k { color: var(--gray-500); }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------------- PIN gate ---------------- */
.login-overlay[hidden] { display: none; }
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* Fully opaque animated gradient — matches the employee login gate. */
  background-color: #1d4ed8;
  background-image: linear-gradient(135deg, #1d4ed8, #4f46e5, #7c3aed, #ec4899, #1d4ed8);
  background-size: 300% 300%;
  animation: gradient-shift 15s ease infinite;
  color: #fff;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 48px 20px;
}
@media (prefers-reduced-motion: reduce) {
  .login-overlay { animation: none; }
}
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-logo { display: block; margin: 0 auto 22px; max-width: 60vw; height: auto; }
.login-title { font-size: 1.2rem; font-weight: 600; margin: 0 0 4px; }
.login-sub { margin: 0 0 14px; opacity: 0.85; font-size: 0.9rem; }
.login-error { min-height: 1.2em; margin: 12px 0 4px; color: #fecaca; font-weight: 600; font-size: 0.9rem; }

.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 8px 0; }
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  transition: background 0.15s ease;
}
.pin-dots span.filled { background: #fff; border-color: #fff; }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 10px auto 0;
  max-width: 300px;
}
.pin-key {
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #4a76ea, #2f5be0);
  color: #fff;
  font-size: 1.6rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 5px 0 #12275f,
    0 8px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.07s ease;
}
.pin-key:active,
.pin-key.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #12275f, 0 2px 5px rgba(0, 0, 0, 0.25);
  filter: brightness(1.12);
}
.pin-key-blank {
  background: none;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}
.pin-key-blank:active, .pin-key-blank.pressed { transform: none; }
.pin-key-back { font-size: 1.3rem; }

/* Gate logo: fade in from the top on load */
.logo-wrap { animation: logo-enter 0.8s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes logo-enter {
  from { opacity: 0; transform: translateY(-36px); }
}

/* Wrong PIN: shake the logo */
.login-logo.shake { animation: logo-shake 0.5s ease; }
@keyframes logo-shake {
  15% { transform: translateX(-10px) rotate(-2deg); }
  30% { transform: translateX(9px) rotate(2deg); }
  45% { transform: translateX(-7px) rotate(-1.2deg); }
  60% { transform: translateX(6px) rotate(1.2deg); }
  80% { transform: translateX(-3px); }
}

/* 3D "pushable" button at the bottom of the PIN gate (matches employee app) */
.gate-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 24px;
}
.btn3d {
  display: inline-block;
  padding: 13px 20px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--blue-dark);
  background: linear-gradient(180deg, #ffffff, #dbe4fb);
  box-shadow:
    0 6px 0 #a9bce8,
    0 10px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
}
.btn3d:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 0 #a9bce8, 0 12px 20px rgba(0, 0, 0, 0.32);
}
.btn3d:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #a9bce8, 0 3px 8px rgba(0, 0, 0, 0.25);
}
