/* =========================================================
   BuildManage – Global Stylesheet
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --sidebar-width: 250px;
  --header-height: 62px;

  /* Sidebar */
  --sb-bg:          #1a2234;
  --sb-hover:       #243150;
  --sb-active:      #2d3d5e;
  --sb-active-bar:  #3b82f6;
  --sb-text:        rgba(255,255,255,.65);
  --sb-text-active: #ffffff;
  --sb-icon:        rgba(255,255,255,.45);
  --sb-icon-active: #93c5fd;
  --sb-border:      rgba(255,255,255,.07);
  --sb-logo-accent: #f97316;

  /* Layout */
  --header-bg:    #ffffff;
  --body-bg:      #f0f3f9;
  --card-bg:      #ffffff;

  /* Brand colors */
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --info:          #0891b2;
  --info-light:    #e0f2fe;
  --orange:        #ea580c;
  --orange-light:  #ffedd5;

  /* Typography */
  --text-dark:    #1e293b;
  --text-body:    #334155;
  --text-muted:   #64748b;
  --text-light:   #94a3b8;

  /* Borders & shadows */
  --border:       #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:    0 10px 25px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.05);

  /* Radii */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* bm-* aliases — used in modernized views */
  --bm-surface: var(--card-bg);
  --bm-bg:      var(--body-bg);
  --bm-border:  var(--border);
  --bm-primary: var(--primary);
  --bm-text:    var(--text-dark);
  --bm-muted:   var(--text-muted);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-body);
  background: var(--body-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sb-border);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--sb-logo-accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { width: 20px; height: 20px; fill: #fff; }

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-text .brand {
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sidebar-logo-text .tenant {
  font-size: .72rem;
  color: var(--sb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 158px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  list-style: none;
  margin: 0;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sb-icon);
  padding: 14px 20px 4px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sb-text);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
  text-decoration: none;
}

.sidebar-nav li a .nav-icon {
  width: 18px; height: 18px;
  color: var(--sb-icon);
  flex-shrink: 0;
  transition: color .15s;
}

.sidebar-nav li a .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 600;
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.sidebar-nav li a:hover {
  background: var(--sb-hover);
  color: #fff;
}

.sidebar-nav li a:hover .nav-icon { color: var(--sb-icon-active); }

.sidebar-nav li a.active {
  background: var(--sb-active);
  color: var(--sb-text-active);
}

.sidebar-nav li a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--sb-active-bar);
  border-radius: 0 2px 2px 0;
}

.sidebar-nav li a.active .nav-icon { color: var(--sb-icon-active); }

.sidebar-user-block {
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: 0;
}

.sidebar-user {
  flex: 1;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transition: background .15s;
  min-width: 0;
}

.sidebar-user:hover { background: var(--sb-hover); }

.sidebar-logout {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-text);
  text-decoration: none;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  border-left: 1px solid var(--sb-border);
}

.sidebar-logout:hover {
  background: rgba(220,38,38,.15);
  color: #fca5a5;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.sidebar-avatar-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid var(--sb-bg);
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-info .user-name {
  font-size: .82rem;
  font-weight: 600;
  color: #fff;
  display: block;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info .user-role {
  font-size: .69rem;
  color: var(--sb-text);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.sidebar-role-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: .9;
}

/* ── Main area ──────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

.header-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.header-menu-toggle:hover { background: var(--border-light); color: var(--text-dark); }

.header-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.header-search input {
  width: 100%;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 0 14px 0 36px;
  font-size: .85rem;
  color: var(--text-body);
  background: var(--body-bg);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.header-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}

.header-search .search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-light);
}

.header-spacer { flex: 1; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn {
  width: 36px; height: 36px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  position: relative;
  transition: background .15s, color .15s;
}

.header-btn:hover { background: var(--border-light); color: var(--text-dark); }

.header-btn .notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid #fff;
}

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

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius);
  transition: background .15s;
}

.header-user:hover { background: var(--border-light); }

.header-user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  font-size: .78rem;
  display: flex; align-items: center; justify-content: center;
}

.header-user-info .user-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dark);
  display: block;
  line-height: 1.2;
}

.header-user-info .user-role-label {
  font-size: .7rem;
  color: var(--text-muted);
  display: block;
}

/* ── Page content ───────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 2px;
}

.page-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin: 0;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Stat Cards ─────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}

.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

.stat-card-icon svg { width: 20px; height: 20px; }

.stat-card-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-card-icon.green  { background: var(--success-light); color: var(--success); }
.stat-card-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-card-icon.orange { background: var(--orange-light);  color: var(--orange); }
.stat-card-icon.cyan   { background: var(--info-light);    color: var(--info); }
.stat-card-icon.yellow { background: var(--warning-light); color: var(--warning); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  margin-top: 6px;
}

.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.card-body { padding: 20px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--border-light);
  font-size: .8rem;
  color: var(--text-muted);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table.bm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .855rem;
}

table.bm-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.bm-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
  vertical-align: middle;
}

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

table.bm-table tbody tr:hover { background: #f8fafc; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-orange  { background: var(--orange-light);  color: var(--orange); }
.badge-secondary { background: var(--border-light); color: var(--text-muted); }

.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .855rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active { transform: translateY(1px); }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

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

.btn-secondary {
  background: #fff;
  color: var(--text-body);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; color: #fff; }

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

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }

.btn-outline {
  background: transparent;
  color: var(--text-body);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--border-light); color: var(--text-dark); }

.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-lg { padding: 11px 22px; font-size: .95rem; }

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

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

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text-body);
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: var(--font);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-control:disabled { background: var(--border-light); color: var(--text-muted); }

textarea.form-control {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 90px;
}

select.form-control { cursor: pointer; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: .75rem;
  color: var(--danger);
  margin-top: 4px;
}

.input-group {
  display: flex;
  position: relative;
}

.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid;
  margin-bottom: 16px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-light); color: #166534; border-color: var(--success); }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border-color: var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: var(--warning); }
.alert-info    { background: var(--info-light);    color: #155e75; border-color: var(--info); }

/* ── Avatar ─────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-sm { width: 30px; height: 30px; font-size: .75rem; }
.avatar-md { width: 38px; height: 38px; font-size: .85rem; }
.avatar-lg { width: 50px; height: 50px; font-size: 1rem; }

/* ── Progress bar ───────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 10px;
  transition: width .3s ease;
}

.progress-bar.blue   { background: var(--primary); }
.progress-bar.green  { background: var(--success); }
.progress-bar.orange { background: var(--orange); }
.progress-bar.red    { background: var(--danger); }

/* ── Quick action cards (Inginer/Muncitor) ──────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.quick-action-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  text-align: center;
  text-decoration: none;
  color: var(--text-body);
  transition: border-color .2s, box-shadow .2s, transform .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quick-action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: var(--primary);
}

.quick-action-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}

.quick-action-icon svg { width: 22px; height: 22px; }

.quick-action-label {
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.3;
}

/* ── Check-in/out big buttons (Muncitor) ───────────────── */
.checkin-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0;
}

.checkin-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  text-align: center;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: transform .15s, box-shadow .15s;
}

.checkin-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: #fff; }

.checkin-btn.checkout { background: var(--danger); }
.checkin-btn.location { background: var(--success); }

.checkin-btn svg { width: 28px; height: 28px; }

/* ── Activity feed ──────────────────────────────────────── */
.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}

.activity-dot.blue   { background: var(--primary); }
.activity-dot.green  { background: var(--success); }
.activity-dot.red    { background: var(--danger); }
.activity-dot.orange { background: var(--orange); }

.activity-text {
  font-size: .84rem;
  color: var(--text-body);
  flex: 1;
}

.activity-text strong { color: var(--text-dark); }

.activity-time {
  font-size: .74rem;
  color: var(--text-light);
  white-space: nowrap;
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.pagination .page-item .page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  background: #fff;
  text-decoration: none;
  transition: all .15s;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination .page-item .page-link:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Dropdown ───────────────────────────────────────────── */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 6px 0;
  z-index: 9999;
  display: none;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: .855rem;
  color: var(--text-body);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--border-light); color: var(--text-dark); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Utility ─────────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-dark { color: var(--text-dark); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: .82rem; }
.fs-xs { font-size: .75rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.ms-auto { margin-left: auto; }
.w-100 { width: 100%; }
.rounded { border-radius: var(--radius); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.separator { height: 1px; background: var(--border); margin: 16px 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Sidebar overlay (mobile) ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay { display: block; }
  .sidebar-overlay.hidden { display: none; }

  .main-wrapper { margin-left: 0; }

  .header-menu-toggle { display: flex; }

  .header-search { max-width: 200px; }

  .header-user-info { display: none; }

  .page-content { padding: 16px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .quick-actions { grid-template-columns: repeat(2, 1fr); }

  .checkin-buttons { grid-template-columns: 1fr; }

  table.bm-table thead { display: none; }

  table.bm-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    padding: 6px 14px;
  }

  table.bm-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: 8px;
  }

  table.bm-table tbody tr {
    display: block;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .header-search { display: none; }
}

/* ── Auth layout ────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2234 0%, #2d3d5e 50%, #1a2234 100%);
  padding: 24px;
}

.auth-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 40px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
  text-decoration: none;
}

.auth-logo-icon {
  width: 44px; height: 44px;
  background: var(--sb-logo-accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}

.auth-logo-icon svg { width: 24px; height: 24px; fill: #fff; }

.auth-logo-text {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: -.02em;
}

.auth-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 4px;
}

.auth-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.auth-footer {
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 24px;
}

/* ── Chart container ────────────────────────────────────── */
.chart-container { position: relative; }

/* ── Worker status card ─────────────────────────────────── */
.worker-site-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.worker-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 600;
}

.worker-status-badge.present { background: var(--success-light); color: var(--success); }
.worker-status-badge.absent  { background: var(--danger-light);  color: var(--danger); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE ENHANCEMENTS v2
   ═══════════════════════════════════════════════════════════ */

/* ── Sidebar & header ──────────────────────────────────────── */
@media (max-width: 768px) {
  /* Page header row stacks vertically */
  .page-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header-row > *:last-child {
    align-self: stretch;
  }
  .page-header-row .btn,
  .page-header-row a.btn {
    width: 100%;
    justify-content: center;
  }
  /* But if there are multiple buttons, keep them in a row */
  .page-header-row > div:last-child,
  .page-header-row > form:last-child {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  /* Card header wraps on mobile */
  .card-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .card-header .btn { flex-shrink: 0; }

  /* Stat cards: 2 columns minimum */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Form grids collapse */
  .form-row,
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] { /* handled via class below */ }

  /* Sidebar KPI grids used inline */
  .kpi-inline-grid { grid-template-columns: 1fr 1fr !important; }

  /* Tab bars scroll horizontally */
  .tab-bar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }

  /* Modals: full width on small screens */
  .modal-box {
    width: 96vw !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-body {
    grid-template-columns: 1fr !important;
  }
  .modal-body .full { grid-column: 1 !important; }

  /* Action button groups wrap */
  .action-bar, .btn-group-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Two-column sidebar layouts collapse */
  .sidebar-layout-2col {
    grid-template-columns: 1fr !important;
  }

  /* Page content padding reduced */
  .page-content { padding: 12px; }

  /* Hide secondary text in table cells on mobile */
  .bm-table td .text-secondary-mobile { display: none; }

  /* Wider form controls on mobile */
  .form-control, .form-select { font-size: 16px !important; } /* prevents iOS zoom */

  /* Hero sections stack */
  .tenant-hero { flex-wrap: wrap; }
  .tenant-kpi-row { grid-template-columns: repeat(2, 1fr) !important; }

  /* Superadmin KPI grids */
  .sa-kpi { grid-template-columns: repeat(2, 1fr) !important; }
  .sa-grid2, .sa-grid3 { grid-template-columns: 1fr !important; }

  /* Worker cards */
  .worker-site-card { padding: 12px; }

  /* Issue/report detail two-column → stack */
  .detail-2col { grid-template-columns: 1fr !important; }

  /* Attendance KPI row */
  .att-kpi-row { grid-template-columns: repeat(2, 1fr) !important; }

  /* Inline grid helpers used in various views */
  .responsive-grid-2 { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  /* Single column everywhere */
  .stats-row { grid-template-columns: 1fr; }
  .tenant-kpi-row { grid-template-columns: 1fr 1fr !important; }
  .sa-kpi { grid-template-columns: repeat(2, 1fr) !important; }

  /* Page title smaller */
  .page-title { font-size: 1.05rem; }

  /* Reduce padding further */
  .page-content { padding: 10px; }
  .card-header { padding: 12px 14px; }
  .card-body   { padding: 12px 14px; }

  /* Buttons full width on very small screens */
  .btn-mobile-full { width: 100% !important; display: flex; justify-content: center; }

  /* Hide some header elements */
  .header-btn { width: 30px; height: 30px; }

  /* Table mobile card improvements */
  table.bm-table tbody td {
    padding: 5px 12px;
    font-size: .82rem;
  }
  table.bm-table tbody td::before { font-size: .68rem; }

  /* Modals near full screen */
  .modal-box {
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: var(--radius) !important;
    margin: 0 !important;
  }
  .modal-backdrop { align-items: flex-end !important; padding: 0 !important; }

  /* Auth card full width */
  .auth-card { padding: 24px 20px; }
}

/* ── Responsive grid helpers ────────────────────────────── */
/* Use these classes instead of inline style="display:grid..." */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 1024px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px)  {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 480px)  {
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── Sticky bottom action bar (mobile forms) ─────────────── */
@media (max-width: 768px) {
  .form-actions-sticky {
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    margin: 16px -16px -16px;
    display: flex;
    gap: 8px;
    z-index: 10;
  }
  .form-actions-sticky .btn { flex: 1; justify-content: center; }
}

/* ── Touch-friendly interactive elements ─────────────────── */
@media (max-width: 768px) {
  .sidebar-nav li a { padding: 11px 20px; }
  .btn { min-height: 36px; }
  .btn-sm { min-height: 30px; padding: 0 10px; }
  input[type="checkbox"],
  input[type="radio"] { min-width: 18px; min-height: 18px; }
  .big-toggle { width: 64px !important; height: 32px !important; }
  .big-toggle::after { width: 26px !important; height: 26px !important; }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .app-header, .header-menu-toggle,
  .btn, .page-header-row .btn,
  #sidebarOverlay { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  table.bm-table thead { display: table-header-group !important; }
  table.bm-table tbody tr { display: table-row !important; }
  table.bm-table tbody td { display: table-cell !important; }
  table.bm-table tbody td::before { display: none !important; }
}
