:root {
  --primary       : #7c5cbf;
  --primary-hover : #6a4aad;
  --primary-light : #ede9f7;
  --success       : #2da16b;
  --success-bg    : #d1fae5;
  --danger        : #e05050;
  --danger-bg     : #fde8e8;
  --warning       : #d97706;
  --warning-bg    : #fef3c7;

  --bg        : #faf8f5;
  --bg-card   : #ffffff;
  --bg-muted  : #f5f2ed;
  --border    : #d0c8be;
  --border-soft: #e2dbd2;

  --text-primary   : #2c2420;
  --text-secondary : #7a6e67;
  --text-muted     : #b0a49c;

  --shadow-sm : 0 1px 3px rgba(60,40,20,.05);
  --shadow-md : 0 4px 12px rgba(60,40,20,.08);
  --shadow-lg : 0 12px 30px rgba(60,40,20,.12);

  --radius    : 8px;
  --radius-sm : 4px;
  --font      : 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}

.app-container {
  width: 100%;
  max-width: 100%;
  padding: 1.5rem;
}

/* ── Header ─────────────────────────────────────────── */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .875rem;
}

.logo-icon { font-size: 2rem; }

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.logo-text p {
  font-size: .75rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* Session badge */
.session-badge {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .75rem;
  color: var(--text-secondary);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: .25rem .75rem;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .3s;
}

.badge-dot.ok  { background: var(--success); }
.badge-dot.bad { background: var(--danger); }
.badge-dot.checking { background: var(--warning); animation: pulse 1.2s infinite; }

/* Timer controls */
.timer-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--text-secondary);
}

.timer-controls input[type="number"] {
  width: 54px;
  padding: .35rem .45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg);
  text-align: center;
}

.timer-controls input[type="number"]:focus { outline: none; border-color: var(--primary); }

/* ── Tab Navigation ──────────────────────────────── */
.tab-navigation {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(124, 92, 191, 0.2);
}

.tab-content.hidden { display: none !important; }

/* ── Cookie / Captcha Banner ────────────────────────── */
.cookie-banner {
  display: flex;
  gap: 1rem;
  background: var(--warning-bg);
  border: 1px solid #f6d860;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  animation: fadeIn .3s ease;
}

.cookie-banner.hidden { display: none; }
.cookie-banner-icon { font-size: 1.5rem; flex-shrink: 0; }
.cookie-banner-body { flex: 1; }
.cookie-banner-body strong { font-size: .9rem; display: block; margin-bottom: .2rem; }
.cookie-banner-body p { font-size: .8rem; color: var(--text-secondary); margin-bottom: .6rem; }

.captcha-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  max-width: 280px;
  box-shadow: var(--shadow-sm);
}

.captcha-img-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  background: #405f8d;
  padding: 0.4rem;
  border-radius: 4px;
}

.captcha-img-wrap img {
  height: 38px;
  background: white;
  border-radius: 4px;
}

.btn-refresh-text {
  background: none;
  border: none;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.85;
  font-family: var(--font);
}

.captcha-input-row {
  display: flex;
  gap: 0.4rem;
}

.captcha-input-row input {
  flex: 1;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
}

.captcha-input-row input:focus { outline: none; border-color: var(--primary); }

.how-to { font-size: .8rem; color: var(--text-secondary); }
.how-to summary { cursor: pointer; font-weight: 600; color: var(--primary); }

/* ── Search bar component ────────────────────────────── */
.search-container {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.65rem;
  box-shadow: var(--shadow-sm);
}

.search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(124, 92, 191, 0.1);
}

.search-icon {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-right: 0.4rem;
}

#search-places-input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.4rem 0;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-primary);
}

#search-places-input:focus { outline: none; }

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 0.2rem;
}

.suggestion-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.suggestion-item:hover { background: var(--primary-light); }

.suggestion-label { font-weight: 500; font-size: 0.88rem; }
.suggestion-type {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 50px;
}

.suggestion-type.province { background: #dbeafe; color: #1e40af; }
.suggestion-type.district { background: #fef3c7; color: #92400e; }
.suggestion-type.office { background: #d1fae5; color: #065f46; }

/* Tags list */
.monitored-places-section {
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--border-soft);
}

.monitored-places-section h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.monitored-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.monitored-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 50px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.monitored-tag-type {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}

.monitored-tag button {
  background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 0.9rem;
}
.monitored-tag button:hover { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: .45rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-soft); color: var(--text-primary); }

.btn-full  { width: 100%; margin-top: 0.75rem; padding: 0.6rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; }
.card-desc { font-size: .8rem; color: var(--text-secondary); margin-bottom: 0.75rem; }

/* ── Email Tags ──────────────────────────────────────── */
.email-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }

.email-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--primary-light);
  border: 1px solid rgba(124,92,191,.2);
  color: var(--primary);
  border-radius: 50px;
  padding: .2rem .65rem;
  font-size: .78rem;
  font-weight: 600;
}

.email-tag button { background: none; border: none; cursor: pointer; color: var(--primary); font-size: .8rem; }
.email-add-row { display: flex; gap: .5rem; }
.email-add-row input[type="email"] {
  flex: 1;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .85rem;
  background: var(--bg);
  color: var(--text-primary);
}

/* ── Minimal Grid Table with borders ─────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.results-table th,
.results-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
}

.results-table th {
  background: var(--bg-muted);
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.table-empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem !important;
}

.table-office-name { font-weight: 700; }
.table-district-name { color: var(--text-secondary); }
.status-badge-pill {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-secondary); background: var(--bg-muted); padding: .2rem .5rem; border-radius: 50px;
}

.slots-grid { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.slot-btn {
  background: var(--primary-light); border: 1px solid transparent;
  color: var(--primary); border-radius: 4px; padding: 0.25rem 0.5rem;
  font-size: .75rem; font-weight: 600; font-family: var(--font);
  cursor: pointer;
}
.slot-btn:hover { background: var(--primary); color: #fff; }

/* ── Modal ───────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(44,36,32,.4);
  backdrop-filter: blur(2px); display: flex; justify-content: center;
  align-items: center; z-index: 200; padding: 1rem;
}

.modal-content {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; max-width: 380px; width: 100%; position: relative;
  box-shadow: var(--shadow-lg); text-align: center;
}

.modal-icon { font-size: 2rem; margin-bottom: .5rem; }
.modal-content h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

.close-btn {
  position: absolute; top: 0.75rem; right: 0.75rem; width: 24px; height: 24px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: .75rem; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}

.selection-summary {
  background: var(--bg-muted); border-radius: var(--radius-sm);
  padding: 0.75rem 1rem; margin-bottom: 1rem;
  text-align: left; display: flex; flex-direction: column; gap: .45rem;
}

.summary-row { display: flex; justify-content: space-between; font-size: .85rem; }
.summary-label { color: var(--text-secondary); font-weight: 600; }
.modal-note { font-size: .75rem; color: var(--text-muted); }
.modal-note a { color: var(--primary); text-decoration: none; }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #1e1a16; color: #fff; padding: .5rem 1.25rem; border-radius: 50px;
  font-size: .8rem; font-weight: 500; z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.success { background: var(--success); }
.toast.danger  { background: var(--danger); }

.hidden { display: none !important; }
@keyframes pulse { 0%,100% { opacity:.5; } 50% { opacity:1; } }
