:root {
  --primary: #1a56db;
  --primary-hover: #1444b0;
  --dark: #1e293b;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --white: #ffffff;
  --error: #dc2626;
  --success: #16a34a;
  --sidebar-width: 220px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gray-800);
  line-height: 1.5;
}

/* Auth pages (login, forgot, reset) */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
}

.auth-card {
  background: var(--white);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-logo {
  width: 280px;
  max-width: 100%;
  margin-bottom: 1.5rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--dark);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--gray-600);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s;
  background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group-narrow {
  flex: 0 0 90px;
}

.form-row-5 {
  display: flex;
  gap: 1rem;
}

.form-row-5 .form-group {
  flex: 1;
}

.form-card {
  background: var(--gray-50);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  margin-top: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--gray-200);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
  text-decoration: none;
}

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

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

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
}

.btn-outline:hover {
  background: var(--gray-100);
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-error {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Auth links */
.auth-links {
  margin-top: 1.25rem;
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.auth-links a:hover {
  text-decoration: underline;
}

/* ===================== */
/* Sidebar               */
/* ===================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  height: 56px;
  display: flex;
  align-items: center;
}

.sidebar-logo a {
  display: block;
  line-height: 0;
}

.sidebar-logo-img {
  height: 32px;
  width: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.25rem 0.625rem;
  padding: 0.625rem 0.75rem;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 6px;
  transition: background-color 0.1s, color 0.1s;
}

.sidebar-link:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.sidebar-link.active {
  background: var(--primary);
  color: var(--white);
  font-weight: 600;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ===================== */
/* Top bar               */
/* ===================== */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 1.5rem;
  z-index: 99;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-user-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  color: var(--gray-600);
  font-size: 0.8125rem;
  font-weight: 500;
}

.topbar-logout {
  display: inline;
}

.btn-active {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

/* ===================== */
/* App layout            */
/* ===================== */
.app-page {
  min-height: 100vh;
  background: var(--gray-100);
}

.app-content {
  margin-left: var(--sidebar-width);
  margin-top: 56px;
  padding: 1.5rem 2rem;
  min-height: calc(100vh - 56px);
}

.app-content h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--dark);
}

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

.content-header h1 {
  margin-bottom: 0;
}

.content-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.8125rem;
}

.back-link:hover {
  color: var(--primary);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* ===================== */
/* Detail view           */
/* ===================== */
.detail-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-top: 1rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.detail-grid-3 {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
}

.detail-section {
  padding: 1rem 1.25rem;
}

.detail-section:not(:last-child) {
  border-right: 1px solid var(--gray-200);
}

.detail-section-middle {
  min-width: 220px;
}

.address-display {
  font-size: 0.875rem;
  color: var(--gray-800);
  line-height: 1.5;
}

.address-country {
  color: var(--gray-400);
}

.address-coords {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.375rem;
}

.text-muted {
  font-size: 0.875rem;
  color: var(--gray-400);
}

.detail-subsection-title {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
}

.phone-display {
  font-size: 0.875rem;
  color: var(--gray-800);
}

.phone-type {
  color: var(--gray-400);
  font-size: 0.8125rem;
}

.detail-section h2 {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin-bottom: 0.75rem;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-section-header h2 {
  margin-bottom: 0;
}

.detail-section-header + p,
.detail-section-header + .text-muted {
  margin-top: 0.75rem;
}

.detail-section-header .btn-icon-sm {
  text-decoration: none;
}

.detail-row {
  display: flex;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--gray-400);
}

.detail-value {
  font-size: 0.875rem;
  color: var(--gray-800);
}

.detail-value a {
  color: var(--primary);
  text-decoration: none;
}

.detail-value a:hover {
  text-decoration: underline;
}

.detail-meta {
  display: flex;
  gap: 2rem;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.8125rem;
  color: var(--gray-400);
}

.tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: var(--gray-100);
  border-radius: 4px;
  font-size: 0.8125rem;
  margin-right: 0.25rem;
}

.app-footer {
  margin-left: var(--sidebar-width);
  text-align: center;
  padding: 1rem;
  color: var(--gray-400);
  font-size: 0.8rem;
}

/* ===================== */
/* Data table            */
/* ===================== */
.table-wrapper {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: var(--gray-50);
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
}

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

.table-row-link {
  cursor: pointer;
  transition: background-color 0.1s;
}

.table-row-link:hover {
  background: var(--gray-50);
}

.td-primary {
  font-weight: 600;
  color: var(--primary);
}

.table-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 2rem 1rem !important;
}

.th-actions {
  width: 1%;
  white-space: nowrap;
}

.td-actions {
  white-space: nowrap;
  text-align: right;
}

.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-400);
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
}

.btn-icon-sm:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-icon-danger:hover {
  background: #fef2f2;
  color: var(--error);
  border-color: #fecaca;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-unverified {
  background: #fef3c7;
  color: #92400e;
}

.badge-verified {
  background: #d1fae5;
  color: #065f46;
}

.badge-promoted {
  background: #dbeafe;
  color: #1e40af;
}

/* ===================== */
/* Tabs                  */
/* ===================== */
.tabs {
  display: flex;
  gap: 0;
  margin-top: 0.75rem;
}

.tab {
  padding: 0.5rem 1.25rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
  margin-right: -1px;
}

.tab:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

.tab.active {
  background: var(--white);
  color: var(--gray-800);
  font-weight: 600;
  border-color: var(--gray-200);
  position: relative;
}

.tab-panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 0 8px 8px 8px;
  padding: 1rem 1.25rem;
}

.tab-panel-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

/* ===================== */
/* Inline form           */
/* ===================== */
.inline-form {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.form-help {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.25rem;
}

.form-help a {
  color: var(--primary);
}

.form-section-title {
  font-size: 0.9375rem;
  color: var(--gray-800);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.places-search-input {
  border: 1px solid var(--primary) !important;
  background: #f0f5ff !important;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-600);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

/* ===================== */
/* Multi-select dropdown */
/* ===================== */
.multiselect {
  position: relative;
}

.multiselect-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.9375rem;
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s;
  min-height: 40px;
}

.multiselect-display:hover {
  border-color: var(--gray-300);
}

.multiselect.open .multiselect-display {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.multiselect-text {
  color: var(--gray-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiselect-text.has-value {
  color: var(--gray-800);
}

.multiselect-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  margin-top: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
}

.multiselect.open .multiselect-dropdown {
  display: block;
}

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--gray-800);
  cursor: pointer;
  transition: background-color 0.1s;
}

.multiselect-option:hover {
  background: var(--gray-50);
}

.multiselect-option input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ===================== */
/* Address cards         */
/* ===================== */
.address-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
}

.address-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.address-card-body {
  flex: 1;
}

.address-line {
  font-size: 0.875rem;
  color: var(--gray-800);
  line-height: 1.4;
}

.address-country {
  color: var(--gray-400);
}

.address-coords {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.25rem;
}

.address-card .badge {
  margin-bottom: 0.375rem;
}

.address-card-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-100);
}

.btn-danger {
  color: var(--error);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
}

.empty-state {
  text-align: center;
  color: var(--gray-400);
  padding: 2rem 1rem;
  font-size: 0.875rem;
}

/* ===================== */
/* Table sort & filter   */
/* ===================== */
.sortable-th {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sortable-th:hover {
  background: var(--gray-100);
}

.sort-arrow {
  font-size: 0.7rem;
  color: var(--gray-400);
}

.sort-active {
  color: var(--primary);
}

.sort-active .sort-arrow {
  color: var(--primary);
}

.table-filter-row {
  background: var(--white);
}

.table-filter-cell {
  padding: 0.375rem 0.5rem !important;
  border-bottom: 1px solid var(--gray-200) !important;
}

.table-filter-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: border-color 0.15s;
}

.table-filter-input::placeholder {
  color: var(--gray-300);
}

.table-filter-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.1);
}

/* Responsive */
@media (max-width: 480px) {
  .auth-card {
    margin: 1rem;
    padding: 1.5rem;
  }
  .auth-logo {
    width: 200px;
  }
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .sidebar {
    width: 60px;
  }
  .sidebar-logo-img {
    width: 36px;
  }
  .sidebar-link {
    justify-content: center;
    padding: 0.75rem;
    font-size: 0;
  }
  .sidebar-icon {
    width: 22px;
    height: 22px;
  }
  .app-content,
  .app-footer {
    margin-left: 60px;
  }
  .topbar {
    left: 60px;
  }
}


/* Datetime field with Now button */
.datetime-wrapper {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}
.datetime-wrapper input[type="datetime-local"] {
  flex: 1;
}
.btn-now {
  padding: 0.5rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--gray-600);
  transition: background 0.15s, border-color 0.15s;
}
.btn-now:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

/* Flatpickr theme overrides */
.flatpickr-calendar {
  background: var(--white) !important;
  border: 1.5px solid var(--gray-300) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
  font-family: inherit !important;
}
.flatpickr-months {
  background: var(--primary) !important;
  border-radius: 6px 6px 0 0 !important;
  padding: 4px 0 !important;
}
.flatpickr-months .flatpickr-month,
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  color: var(--white) !important;
  fill: var(--white) !important;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
  fill: var(--gray-200) !important;
}
.flatpickr-current-month .cur-month,
.flatpickr-current-month input.cur-year {
  color: var(--white) !important;
  font-weight: 600 !important;
}
span.flatpickr-weekday {
  color: var(--gray-600) !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
}
.flatpickr-day {
  color: var(--gray-800) !important;
  border-radius: 6px !important;
}
.flatpickr-day:hover {
  background: var(--gray-100) !important;
  border-color: var(--gray-200) !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: var(--white) !important;
}
.flatpickr-day.today {
  border-color: var(--primary) !important;
}
.flatpickr-day.today:hover {
  background: var(--primary) !important;
  color: var(--white) !important;
}
.flatpickr-time {
  border-top: 1px solid var(--gray-200) !important;
}
.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
  color: var(--gray-800) !important;
  font-weight: 500 !important;
}
.flatpickr-time input:hover,
.flatpickr-time input:focus,
.flatpickr-time .flatpickr-am-pm:hover {
  background: var(--gray-50) !important;
}
.numInputWrapper:hover {
  background: var(--gray-50) !important;
}
