/* =========================================================
   Visitor Management System — Shared Styles
   Primary #002e60 · Secondary #ffffff · Accent #fdc613
   Border 1px · Radius 10px · clean, fresh white theme
   ========================================================= */

:root {
  --primary: #002e60;
  --primary-hover: #013c7d;
  --primary-soft: #eaf0f8;
  --secondary: #ffffff;
  --accent: #fdc613;
  --accent-hover: #eab400;

  --ink: #0f2138;
  --muted: #62748c;
  --faint: #98a6b8;

  --surface: #f6f8fb;
  --card: #ffffff;
  --border: #e1e7ef;
  --border-strong: #c9d3e0;

  --success: #1a8f5c;
  --success-soft: #e7f7ef;
  --warn: #b3540a;
  --warn-soft: #fdf1e2;
  --danger: #c62b2b;
  --danger-soft: #fbe9e9;

  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --border-w: 1px;

  --shadow-sm: 0 1px 2px rgba(15, 33, 56, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 46, 96, 0.08);
  --shadow-pop: 0 16px 40px rgba(0, 46, 96, 0.16);

  --font-head: "Manrope", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  color: var(--primary);
  margin: 0;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

img,
svg {
  display: block;
}

::selection {
  background: var(--accent);
  color: var(--primary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Layout shells ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--primary);
  color: #cfe0f5;
  padding: 22px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.sidebar .brand strong {
  color: #fff;
  font-family: var(--font-head);
  font-size: 15.5px;
  line-height: 1.15;
  display: block;
}

.sidebar .brand span {
  color: #9db6d6;
  font-size: 11.5px;
}

.badge-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group .nav-label {
  color: #6f8dae;
  font-size: 11px;
  font-weight: 600;
  padding: 12px 12px 4px;
  letter-spacing: 0.02em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cfe0f5;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: #fff;
  color: var(--primary);
  font-weight: 700;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.sidebar-foot .who {
  line-height: 1.25;
}
.sidebar-foot .who strong {
  color: #fff;
  font-size: 13.5px;
  display: block;
}
.sidebar-foot .who span {
  color: #9db6d6;
  font-size: 11.5px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--card);
  border-bottom: var(--border-w) solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  font-size: 19px;
}
.topbar .subtitle {
  font-size: 12.5px;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 26px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: var(--border-w) solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  transition:
    transform 0.05s ease,
    background 0.15s ease,
    border-color 0.15s ease;
  white-space: nowrap;
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  color: var(--primary);
}
.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border-color: var(--border-strong);
}
.btn-outline:hover {
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #f1c3c3;
}
.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12.5px;
}
.btn svg {
  width: 15px;
  height: 15px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Cards / surfaces ---------- */

.card {
  background: var(--card);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 20px 22px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h3 {
  font-size: 15.5px;
}
.card-head p {
  font-size: 12.5px;
  margin-top: 3px;
}

/* ---------- Stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-tile {
  background: var(--card);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-tile .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-tile .stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-tile .stat-value {
  font-family: var(--font-head);
  font-size: 26px;
  color: var(--primary);
}
.stat-tile .stat-label {
  font-size: 12.5px;
  color: var(--muted);
}
.stat-tile .stat-delta {
  font-size: 11.5px;
  font-weight: 600;
}
.stat-tile .stat-delta.up {
  color: var(--success);
}
.stat-tile .stat-delta.down {
  color: var(--danger);
}

/* ---------- Tabs ---------- */

.tabbar {
  display: flex;
  gap: 4px;
  border-bottom: var(--border-w) solid var(--border);
  padding: 0 2px;
}

.tab {
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
}
.tab:hover {
  color: var(--primary);
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
}

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

thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: none;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: var(--border-w) solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

thead th:first-child {
  border-top-left-radius: var(--radius-sm);
}
thead th:last-child {
  border-top-right-radius: var(--radius-sm);
}

tbody td {
  padding: 12px 14px;
  border-bottom: var(--border-w) solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--surface);
}

.cell-person {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cell-person .avatar {
  width: 30px;
  height: 30px;
  font-size: 11.5px;
  background: var(--primary-soft);
  color: var(--primary);
}
.cell-person .meta strong {
  display: block;
  font-size: 13px;
}
.cell-person .meta span {
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- Badges / pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: var(--border-w) solid transparent;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pill-success {
  background: var(--success-soft);
  color: var(--success);
}
.pill-success .pill-dot {
  background: var(--success);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill-warn .pill-dot {
  background: var(--warn);
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.pill-danger .pill-dot {
  background: var(--danger);
}

.pill-neutral {
  background: var(--primary-soft);
  color: var(--primary);
}
.pill-neutral .pill-dot {
  background: var(--primary);
}

.pill-accent {
  background: #fff8e2;
  color: #8a6300;
}
.pill-accent .pill-dot {
  background: var(--accent);
}

.role-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  border: var(--border-w) solid var(--border-strong);
  color: var(--muted);
  letter-spacing: 0.01em;
}
.role-tag.admin {
  border-color: #b8c9e0;
  color: var(--primary);
  background: var(--primary-soft);
}
.role-tag.employee {
  border-color: #cfe3d5;
  color: var(--success);
  background: var(--success-soft);
}
.role-tag.security {
  border-color: #f0d79a;
  color: #8a6300;
  background: #fff8e2;
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.field .hint {
  font-size: 11px;
  color: var(--faint);
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 76px;
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--faint);
}

.input-icon-wrap {
  position: relative;
}
.input-icon-wrap input {
  padding-left: 38px;
}
.input-icon-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--faint);
}
.input-icon-wrap .toggle-visibility svg {
  left: -5px;
}
.input-icon-wrap .toggle-visibility {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--faint);
  padding: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.checkbox-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: 4px 0;
}

/* ---------- Permission matrix ---------- */

.perm-table td,
.perm-table th {
  text-align: center;
}
.perm-table td:first-child,
.perm-table th:first-child {
  text-align: left;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  display: inline-block;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.switch .track::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .track {
  background: var(--primary);
}
.switch input:checked + .track::before {
  transform: translateX(16px);
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 33, 56, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  border: var(--border-w) solid var(--border);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-head {
  padding: 18px 22px;
  border-bottom: var(--border-w) solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-head h3 {
  font-size: 16.5px;
}
.modal-head p {
  font-size: 12.5px;
  margin-top: 3px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: var(--border-w) solid var(--border);
  background: #fff;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.modal-close:hover {
  background: var(--surface);
  color: var(--primary);
}

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-foot {
  padding: 16px 22px;
  border-top: var(--border-w) solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Toast ---------- */

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}

.toast {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-pop);
  min-width: 260px;
  border-left: 4px solid var(--accent);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--accent);
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--faint);
}
.empty-state strong {
  color: var(--ink);
  font-size: 14.5px;
}
.empty-state p {
  font-size: 13px;
  max-width: 320px;
}

/* ---------- Utility ---------- */

.flex {
  display: flex;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-6 {
  gap: 6px;
}
.gap-8 {
  gap: 8px;
}
.gap-10 {
  gap: 10px;
}
.gap-12 {
  gap: 12px;
}
.gap-16 {
  gap: 16px;
}
.text-sm {
  font-size: 12.5px;
}
.text-muted {
  color: var(--muted);
}
.w-full {
  width: 100%;
}
.mt-4 {
  margin-top: 4px;
}
.mono-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
