:root {
  --navy: #0b2b5b;
  --navy-2: #14457a;
  --blue: #1d6ff2;
  --blue-dark: #175cd3;
  --teal: #0ea5a4;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #e5484d;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --body: #eef2f7;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, 0.14);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--body);
  color: var(--text);
  min-height: 100vh;
}

/* ---------------------------------------------------------------------------
   Top bar
---------------------------------------------------------------------------- */
.topbar {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(11, 43, 91, 0.25);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 22px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(29, 111, 242, 0.45);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.brand-sub {
  color: #9db8e6;
  font-size: 11px;
  font-weight: 500;
}

.nav-links {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 4px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #c3d4f0;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  transition: 0.18s;
}

.nav-links a svg {
  width: 16px;
  height: 16px;
}

.nav-links a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-links a.active {
  color: var(--navy);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ---------------------------------------------------------------------------
   Layout
---------------------------------------------------------------------------- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 22px 60px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--navy);
}

.page-head .subtitle {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 4px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 18px;
  height: 18px;
  color: var(--blue);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ---------------------------------------------------------------------------
   Camera
---------------------------------------------------------------------------- */
.camera-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, #0d1b33, #12264a);
  aspect-ratio: 4 / 3;
  border: 1px solid #1d3a6b;
  box-shadow: var(--shadow-lg);
}

.camera-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-wrap .frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.camera-wrap .frame::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34%;
  height: 52%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.12);
}

.camera-wrap .frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(45, 200, 255, 0.9), transparent);
  animation: scan 3.2s ease-in-out infinite;
  opacity: 0.8;
}

@keyframes scan {
  0% { top: 12%; opacity: 0; }
  15% { opacity: 0.9; }
  85% { opacity: 0.9; }
  100% { top: 86%; opacity: 0; }
}

.camera-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  background: rgba(10, 20, 40, 0.55);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ---------------------------------------------------------------------------
   Buttons
---------------------------------------------------------------------------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  box-shadow: 0 4px 14px rgba(29, 111, 242, 0.35);
  transition: transform 0.12s, box-shadow 0.2s, filter 0.2s, opacity 0.2s;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 18px rgba(29, 111, 242, 0.4);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.secondary {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  box-shadow: none;
}

.btn.danger:hover {
  background: #fee2e2;
}

.btn.sm {
  padding: 8px 14px;
  font-size: 12.5px;
  width: auto;
  border-radius: 9px;
}

/* ---------------------------------------------------------------------------
   Segmented control
---------------------------------------------------------------------------- */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #eef2f8;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}

.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.15s;
}

.seg button svg {
  width: 15px;
  height: 15px;
}

.seg button.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.12);
}

/* ---------------------------------------------------------------------------
   Status box
---------------------------------------------------------------------------- */
.status-box {
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  background: #f8fafc;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.status-box.idle {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.status-box.ok {
  background: var(--success-bg);
  border-color: #a7f3d0;
}

.status-box.err {
  background: var(--danger-bg);
  border-color: #fecaca;
}

.status-box .icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
}

.status-box.ok .icon {
  background: var(--success);
  color: #fff;
}

.status-box.err .icon {
  background: var(--danger);
  color: #fff;
}

.status-box .icon svg {
  width: 22px;
  height: 22px;
}

.status-box .big {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.status-box .msg {
  font-size: 13.5px;
  margin-top: 2px;
}

.status-box .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.pill b {
  color: var(--navy);
}

/* ---------------------------------------------------------------------------
   Forms
---------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 111, 242, 0.15);
}

/* ---------------------------------------------------------------------------
   Table
---------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

thead th {
  background: #f1f5fb;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}

thead th:first-child {
  border-radius: 10px 0 0 10px;
}

thead th:last-child {
  border-radius: 0 10px 10px 0;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}

.badge.hadir {
  background: var(--success-bg);
  color: #059669;
}

.badge.masuk {
  background: #eff6ff;
  color: var(--blue);
}

.badge.pulang {
  background: var(--warn-bg);
  color: var(--warn);
}

.emp-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  margin-right: 10px;
}

.emp-name {
  font-weight: 600;
  color: var(--navy);
}

/* ---------------------------------------------------------------------------
   Actions bar / stats
---------------------------------------------------------------------------- */
.actions-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.actions-bar select,
.actions-bar input {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
}

.actions-bar select:focus,
.actions-bar input:focus {
  outline: none;
  border-color: var(--blue);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat .label svg {
  width: 15px;
  height: 15px;
}

.stat .value {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  margin-top: 4px;
}

.stat .value small {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.stat.accent-1 .value { color: var(--blue); }
.stat.accent-2 .value { color: var(--teal); }
.stat.accent-3 .value { color: var(--success); }

/* ---------------------------------------------------------------------------
   Toast
---------------------------------------------------------------------------- */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--navy);
  color: #fff;
  padding: 13px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 90vw;
}

.toast::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.toast.err::before {
  background: var(--danger);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------------------------------------------------------------------
   Misc
---------------------------------------------------------------------------- */
.spin {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: rot 0.7s linear infinite;
}

@keyframes rot {
  to { transform: rotate(360deg); }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 42px 0;
  font-size: 14px;
}

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

.clock {
  text-align: right;
}

.clock .time {
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.clock .date {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 860px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .nav-links a {
    padding: 8px 10px;
    font-size: 13px;
  }
}
