:root, :root[data-theme="dark"] {
  --bg-primary:    #0d1117;
  --bg-secondary:  #161b22;
  --bg-card:       #1c2128;
  --bg-hover:      #21262d;
  --border:        #30363d;
  --border-light:  #21262d;
  --accent:        #58a6ff;
  --accent-glow:   rgba(88, 166, 255, 0.15);
  --green:         #3fb950;
  --green-bg:      rgba(63, 185, 80, 0.1);
  --yellow:        #d29922;
  --yellow-bg:     rgba(210, 153, 34, 0.1);
  --red:           #f85149;
  --red-bg:        rgba(248, 81, 73, 0.1);
  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #484f58;
  --radius:        10px;
  --radius-sm:     6px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-primary:    #f6f8fa;
    --bg-secondary:  #ffffff;
    --bg-card:       #ffffff;
    --bg-hover:      #f3f4f6;
    --border:        #d0d7de;
    --border-light:  #eaeef2;
    --accent:        #0969da;
    --accent-glow:   rgba(9, 105, 218, 0.12);
    --green:         #1a7f37;
    --green-bg:      rgba(26, 127, 55, 0.1);
    --yellow:        #9a6700;
    --yellow-bg:     rgba(154, 103, 0, 0.1);
    --red:           #cf222e;
    --red-bg:        rgba(207, 34, 46, 0.1);
    --text-primary:  #1f2328;
    --text-secondary:#57606a;
    --text-muted:    #8c959f;
  }
}

:root[data-theme="light"] {
  --bg-primary:    #f6f8fa;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-hover:      #f3f4f6;
  --border:        #d0d7de;
  --border-light:  #eaeef2;
  --accent:        #0969da;
  --accent-glow:   rgba(9, 105, 218, 0.12);
  --green:         #1a7f37;
  --green-bg:      rgba(26, 127, 55, 0.1);
  --yellow:        #9a6700;
  --yellow-bg:     rgba(154, 103, 0, 0.1);
  --red:           #cf222e;
  --red-bg:        rgba(207, 34, 46, 0.1);
  --text-primary:  #1f2328;
  --text-secondary:#57606a;
  --text-muted:    #8c959f;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ── */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.logo-icon { font-size: 1.3rem; }
.brand-title { font-weight: 700; letter-spacing: -0.01em; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Meta / Status Bar */
.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.meta-pill {
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}


/* Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.primary-action-btn {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.3);
}
.primary-action-btn:hover {
  background: rgba(88, 166, 255, 0.25);
  border-color: var(--accent);
}
.icon-only-btn {
  padding: 7px 10px;
}

/* ── Main Layout ── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

/* ── Stats Row ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.blue::before  { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.yellow::before{ background: var(--yellow); }
.stat-card.red::before   { background: var(--red); }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}
.stat-card.blue   .stat-value { color: var(--accent); }
.stat-card.green  .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.red    .stat-value { color: var(--red); }
.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn:hover, .filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.filter-btn.active-green { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.filter-btn.active-yellow { border-color: var(--yellow); color: var(--yellow); background: var(--yellow-bg); }

/* ── Change cards ── */
#changes-list { display: flex; flex-direction: column; gap: 12px; }

.change-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.change-card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.change-card.new-row   { border-left: 3px solid var(--green); }
.change-card.modified  { border-left: 3px solid var(--yellow); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: text;
}
.card-header:hover { background: var(--bg-hover); }
.card-left { display: flex; align-items: center; gap: 10px; }
.type-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}
.type-badge.new      { background: var(--green-bg);  color: var(--green); border: 1px solid rgba(63,185,80,0.3); }
.type-badge.modified { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(210,153,34,0.3); }

.card-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}
.card-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.chevron {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.2s;
}
.change-card.open .chevron { transform: rotate(180deg); }

.card-body {
  display: none;
  padding: 0 18px 18px;
  border-top: 1px solid var(--border-light);
}
.change-card.open .card-body { display: block; }

/* Row data table */
.row-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 12px;
}
.row-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.row-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  word-break: break-word;
}
.row-table tr:last-child td { border-bottom: none; }
.row-table tr:hover td { background: var(--bg-hover); }

.diff-before { color: var(--red);   text-decoration: line-through; opacity: 0.7; }
.diff-after  { color: var(--green); }
.diff-arrow  { color: var(--text-muted); margin: 0 6px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p  { font-size: 0.85rem; }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-secondary);
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Refresh button ── */
.refresh-btn {
  padding: 7px 16px;
  background: var(--accent-glow);
  border: 1px solid rgba(88,166,255,0.3);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.refresh-btn:hover { background: rgba(88,166,255,0.25); }
.refresh-btn.spinning .refresh-icon { animation: spin 0.8s linear infinite; display: inline-block; }

/* ── Acknowledge Button & Badge ── */
.ack-btn {
  padding: 6px 12px;
  background: var(--yellow-bg);
  border: 1px solid rgba(210,153,34,0.3);
  color: var(--yellow);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ack-btn:hover { background: rgba(210,153,34,0.25); }
.ack-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ack-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--green-bg);
  border: 1px solid rgba(63,185,80,0.3);
  color: var(--green);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 12px;
}

/* ── Month header ── */
.month-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 24px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.search-input-field:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent);
}
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .main { padding: 16px 12px; }
  .header { padding: 8px 12px; }
  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 8px 0;
    gap: 8px;
    align-items: stretch;
  }
  .header-meta {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .header-meta::-webkit-scrollbar { display: none; }
  .header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
  }
  .header-actions #user-profile-badge {
    flex: 1 1 100%;
    justify-content: flex-start;
    margin-bottom: 2px;
  }
  .action-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 6px 10px;
    font-size: 0.78rem;
    min-width: 0;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
  }
  .stat-card {
    padding: 14px 16px;
  }
  .stat-value {
    font-size: 1.6rem;
  }
  
  .search-bar {
    flex-direction: column;
    align-items: stretch !important;
    padding: 12px 14px !important;
  }
  
  .search-input-wrapper {
    width: 100% !important;
    flex-basis: auto !important;
  }
  
  .date-filters-wrapper {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  
  .search-bar input[type="date"],
  .search-bar select {
    flex-grow: 1;
    width: 100%;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
    padding: 12px 14px;
  }
  
  .card-left {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  
  .card-header > div:last-child {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
  }

  .card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-bar {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .scroll-to-top {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .header-actions #user-profile-badge {
    flex: 1 1 100%;
  }
  .header-actions .action-btn .btn-text {
    font-size: 0.75rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .login-card {
    padding: 20px 16px !important;
    max-width: calc(100vw - 20px) !important;
  }
  .admin-dialog {
    width: 96% !important;
    max-height: 92vh !important;
  }
}

/* ── Scroll to Top Button ── */
.scroll-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 12px var(--accent-glow);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
}
.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.scroll-to-top:hover {
  background: #4791db;
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 20px var(--accent);
}



/* ── In-House Guests View Styling ── */
.clickable-card {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.clickable-card:hover {
  transform: translateY(-2px);
  border-color: var(--green);
  box-shadow: 0 6px 16px rgba(63, 185, 80, 0.25);
}

.inhouse-summary-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px 22px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.inhouse-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.inhouse-table th, .inhouse-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  vertical-align: middle;
}

.inhouse-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.inhouse-table tr:hover {
  background: var(--bg-hover);
}

/* ── Modal & Auth Styling ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.login-card, .admin-dialog {
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.search-input-field:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

