:root {
  --bg: #0f172a;
  --card: #111c33;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --primary: #3b82f6;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, rgba(59,130,246,0.20), transparent 50%),
              radial-gradient(1000px 700px at 80% 30%, rgba(239,68,68,0.14), transparent 55%),
              var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

.header h1 { margin: 0 0 4px; font-size: 28px; }
.muted { color: var(--muted); margin: 0; }
.tiny { font-size: 12px; }

.card {
  background: rgba(17, 28, 51, 0.75);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-top: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.label { color: var(--muted); font-size: 12px; letter-spacing: 0.03em; text-transform: uppercase; }
.value { font-size: 18px; margin-top: 4px; }

.actions {
  display: flex;
  gap: 10px;
  margin: 10px 0 6px;
  align-items: center;
}

.small-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.05s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover { background: rgba(255,255,255,0.09); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.primary {
  background: rgba(59,130,246,0.25);
  border-color: rgba(59,130,246,0.5);
}
.primary:hover { background: rgba(59,130,246,0.33); }

.danger { border-color: rgba(239,68,68,0.5); }
.danger:hover { background: rgba(239,68,68,0.16); }

.subtle { font-weight: 600; opacity: 0.9; }

.tableWrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th { color: var(--muted); font-weight: 700; }

.toast {
  margin: 10px 0 0;
  min-height: 18px;
  color: var(--muted);
}

/* --- Login form helpers --- */
.form { display: grid; gap: 12px; margin-top: 10px; }
.field { display: grid; gap: 6px; }
.rememberRow { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-top: -4px; }
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: rgba(59,130,246,0.6); }
select.input { color: #e5e7eb; }
select.input option { background: #1e293b; color: #e5e7eb; }
select.input option:hover { background: linear-gradient(#2d4a7a, #2d4a7a); color: #e5e7eb; }
select.input option:checked { background: linear-gradient(#2d4a7a, #2d4a7a); color: #e5e7eb; }

.error { color: #fca5a5; margin: 10px 0 0; min-height: 18px; }

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

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* Admin page: allow more width */
.wrap {
  max-width: 1180px; /* was 860px */
}

/* Split layout overflow fix */
.split {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  min-width: 0;
  box-sizing: border-box;
  background: rgba(17, 28, 51, 0.88);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

/* Prevent anything from visually spilling outside the card */
.card {
  overflow: visible;
}

/* Tables: stop them from forcing the panel wider */
.tableWrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  table-layout: fixed;
}
.table th, .table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Geofence status pill */
.gf {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 12px;
  font-weight: 700;
}
.gf.in  { border-color: rgba(34,197,94,0.45); }
.gf.out { border-color: rgba(239,68,68,0.45); }
.gf.unk { border-color: rgba(148,163,184,0.35); opacity: 0.9; }

/* Admin geofence + status chips */
.gf, .st {
  display: inline-block;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
}

.gf.in { border-color: rgba(34,197,94,0.45); }
.gf.out { border-color: rgba(239,68,68,0.45); }
.gf.unk { border-color: rgba(148,163,184,0.35); }

.st.ok { border-color: rgba(34,197,94,0.45); }
.st.bad { border-color: rgba(239,68,68,0.45); }

/* Modal */
.modalBackdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 9999;
}

.modalCard{
  width: min(920px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: rgba(17, 28, 51, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  backdrop-filter: blur(12px);
  padding: 16px;
}

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

.modalBody{
  display: grid;
  gap: 10px;
}

.kvGrid{
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
}

.kvKey{
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.kvVal{
  word-break: break-word;
}

.codeBox{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  overflow: auto;
}

/* Anomaly flag indicator (inline in table) */
.flagIcon {
  display: inline-block;
  margin-left: 5px;
  color: #f97316;
  font-size: 13px;
  vertical-align: middle;
  cursor: default;
  line-height: 1;
}

/* Flags section in punch detail modal */
.flagList {
  border: 1px solid rgba(249,115,22,0.35);
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(249,115,22,0.08);
}
.flagItem {
  color: #fb923c;
  font-size: 13px;
  padding: 3px 0;
}

/* Custom select dropdown */
.csWrap { position: relative; display: block; }

.csBtn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  /* inherits .btn + .input styles; override font so it looks like an input */
  font-weight: 400;
}
.csBtn::after {
  content: "▾";
  flex-shrink: 0;
  opacity: 0.5;
  font-size: 11px;
}
.csBtn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.csBtn:disabled::after { display: none; }

.csPanel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 500;
  background: #111c33;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
}

.csItem {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.csItem:hover { background: rgba(255,255,255,0.07); }
.csItem.cs-selected { background: rgba(59,130,246,0.2); color: #93c5fd; }