:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #10b981;
  --green-bg: #d1fae5;
  --green-text: #065f46;
  --gray-bg: #f3f4f6;
  --gray-text: #4b5563;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-user {
  font-size: 0.85rem;
  color: var(--muted);
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

/* Layout */
.container {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

/* Filters */
.filters-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-group select,
.filter-group input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
}

.custom-dates {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.filter-search {
  flex: 1 1 220px;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}

.kpi-online {
  border-left: 4px solid var(--green);
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f9fafb;
}

tbody tr:hover {
  background: #f9fafb;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}

.visitor-link {
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.visitor-link:hover strong {
  color: var(--primary);
}

.truncate-url {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pills & Badges */
.badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge-live,
.badge-online {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge-ended {
  background: var(--gray-bg);
  color: var(--gray-text);
}

.host-pill {
  display: inline-block;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-sm {
  padding: 0.42rem 0.8rem;
  font-size: 0.84rem;
}

.btn-block {
  width: 100%;
}

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

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  background: #f9fafb;
  text-decoration: none;
}

/* Auth & Forms */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.auth-brand h1 {
  margin: 0;
  font-size: 1.4rem;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.4rem 0 1.25rem;
}

.auth-hint {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
}

.form-group input {
  padding: 0.58rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.settings-form {
  max-width: 420px;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: var(--red-bg);
  color: var(--red-text);
}
.alert-success {
  background: var(--green-bg);
  color: var(--green-text);
}

.code-block {
  background: #111827;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.86rem;
}

/* Visitor Profile */
.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.profile-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}

.profile-stats {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
}

.mini-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.mini-val {
  font-size: 1.1rem;
  font-weight: 700;
}

.profile-meta {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.8rem;
}


/* Modal & Domain Manager */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 35px rgba(0, 0, 0, 0.18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.25rem;
}

.domain-form .form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.domain-form .form-group {
  margin-bottom: 0.75rem;
}

.domain-form .form-group select {
  padding: 0.58rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
}

.domain-form .form-grow {
  flex: 1 1 240px;
}

.btn-danger {
  color: var(--red-text);
  border-color: #fecaca;
}
.btn-danger:hover {
  background: var(--red-bg);
}
