:root {
  --primary: #009688;
  --primary-hover: #007a6e;
  --bg-color: #f8fafc;
  --surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Geologica', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   SCREENS
========================================= */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* =========================================
   LOGIN SCREEN
========================================= */
#loginScreen {
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  background-image: radial-gradient(circle at center, #e0f2fe 0%, #f8fafc 100%);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
}

.login-logo {
  display: block;
  margin: 0 auto 32px;
  max-height: 40px;
}

.md-title-large {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* Form Inputs - Data Dense Style */
.input-group {
  display: flex;
  flex-direction: column-reverse; /* Puts label above input without DOM changes */
  margin-bottom: 20px;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
  cursor: text;
}

.input-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  background: var(--surface);
  transition: all 0.2s ease;
  font-family: inherit;
}

.input-group input:hover {
  border-color: var(--border-hover);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 150, 136, 0.15);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 24px;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Buttons */
button {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}

#btnLogin {
  width: 100%;
  background: var(--primary);
  color: white;
  padding: 12px;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
}

#btnLogin:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow);
}

#btnLogin:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
  min-height: 20px;
}

.help-text {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

.help-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.help-link:hover {
  text-decoration: underline;
}

/* =========================================
   DASHBOARD SCREEN
========================================= */
#dashboardScreen {
  flex-direction: column;
  background: var(--bg-color);
}

.admin-header {
  background: var(--surface);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg-color);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  letter-spacing: 0.05em;
}

.header-menu {
  display: flex;
  height: 100%;
  gap: 4px;
}

.header-menu a {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.header-menu a:hover {
  color: var(--text-main);
  background: var(--bg-color);
}

.header-menu a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(0, 150, 136, 0.04);
}

.header-menu svg {
  opacity: 0.7;
}

.header-menu a.active svg {
  opacity: 1;
}

.btn-danger {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

.admin-content {
  padding: 32px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* =========================================
   DASHBOARD CARDS
========================================= */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card h3 {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card p {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* =========================================
   FILTERS
========================================= */
.filters-card {
  background: var(--surface);
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.filters-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.filter-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrapper, 
.preset-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg, 
.preset-select-wrapper svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input, 
.preset-select-wrapper select {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  background: var(--surface);
  color: var(--text-main);
  transition: all 0.2s;
  min-width: 220px;
  font-family: inherit;
}

.preset-select-wrapper select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.search-input-wrapper input:hover,
.preset-select-wrapper select:hover {
  border-color: var(--border-hover);
}

.search-input-wrapper input:focus, 
.preset-select-wrapper select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 150, 136, 0.15);
}

.date-range-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-range-wrapper input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  color: var(--text-main);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-color);
  border-color: var(--border-hover);
}

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

.btn-primary:hover {
  background: #0f172a;
}

/* =========================================
   DATA TABLE
========================================= */
.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: #f8fafc;
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: background 0.2s;
}

th[data-sort]:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

td {
  padding: 14px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

td strong {
  font-weight: 500;
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:hover {
  background: #f8fafc;
}

.empty-state {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--text-muted);
  font-style: italic;
}

.whatsapp-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #15803d;
  background: #dcfce7;
  padding: 4px 10px;
  border-radius: 12px; /* Pill shape for tags */
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.whatsapp-link:hover {
  background: #bbf7d0;
  color: #166534;
}

/* =========================================
   PAGINATION
========================================= */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 16px;
}

.per-page-selector {
  display: flex;
  align-items: center;
}

.per-page-selector select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  margin: 0 8px;
  background: var(--surface);
  cursor: pointer;
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

.pagination-buttons button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
}

.pagination-buttons button:hover:not(:disabled) {
  background: var(--bg-color);
  border-color: var(--border-hover);
}

.pagination-buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-color);
}

/* =========================================
   SCROLLBAR
========================================= */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1024px) {
  .filters-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .filter-group {
    width: 100%;
  }

  .search-input-wrapper {
    flex: 1;
  }

  .search-input-wrapper input {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .admin-header {
    padding: 0 16px;
  }

  .header-left {
    gap: 16px !important;
  }

  .header-brand span {
    display: none;
  }

  .header-menu a {
    padding: 0 12px;
    font-size: 13px;
  }

  .admin-content {
    padding: 24px 16px;
  }
  
  .filter-group {
    flex-direction: column;
    align-items:stretch;
  }

  .date-range-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-secondary, .btn-primary {
    width: 100%;
    justify-content: center;
  }

  .pagination-container {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }
}
