/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0f1a;
  --bg-card:      #0f1729;
  --bg-card-hover:#131e35;
  --bg-surface:   #1a2540;
  --bg-input:     #111827;

  --border:       rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.12);

  /* Brand — pulled from logo */
  --cyan:         #22d3ee;
  --blue:         #0ea5e9;
  --green:        #4ade80;
  --green-dark:   #22c55e;

  /* Tier colours */
  --tier-high:    #4ade80;
  --tier-high-bg: rgba(74,222,128,0.08);
  --tier-high-border: rgba(74,222,128,0.2);

  --tier-amber:   #fbbf24;
  --tier-amber-bg:rgba(251,191,36,0.08);
  --tier-amber-border: rgba(251,191,36,0.2);

  --tier-low:     #6b7280;
  --tier-low-bg:  rgba(107,114,128,0.05);

  --tier-red:     #f87171;
  --tier-red-bg:  rgba(248,113,113,0.1);
  --tier-red-border: rgba(248,113,113,0.25);

  --text-primary:   #f0f4ff;
  --text-secondary: #8b95b0;
  --text-muted:     #4b5675;

  --font-ui:   'DM Sans', sans-serif;
  --font-head: 'Space Grotesk', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(34,211,238,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34,211,238,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,15,26,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34,211,238,0.08);
  border: 1px solid rgba(34,211,238,0.2);
  border-radius: 8px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.logo-name {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.logo-region {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-refresh:hover {
  background: var(--bg-surface);
  color: var(--cyan);
  border-color: rgba(34,211,238,0.3);
}

.btn-refresh.loading svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Stats bar ──────────────────────────────────────────────────────────── */
.stats-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.stats-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 56px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 0 24px 0 0;
}

.stat:first-child { padding-left: 0; }

.stat-value {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 24px 0 0;
}

.accent-green  { color: var(--tier-high) !important; }
.accent-amber  { color: var(--tier-amber) !important; }
.accent-muted  { color: var(--text-secondary) !important; }
.accent-red    { color: var(--tier-red) !important; }

/* ─── Filters ────────────────────────────────────────────────────────────── */
.filters-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.filters-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.filter-select,
.filter-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  min-width: 160px;
}

.filter-select:focus,
.filter-input:focus {
  border-color: rgba(34,211,238,0.4);
}

.filter-select option { background: #1a2540; }

.filter-input { min-width: 200px; }
.filter-input::placeholder { color: var(--text-muted); }

.btn-clear {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  align-self: flex-end;
}

.btn-clear:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Section headers ────────────────────────────────────────────────────── */
.tender-section,
.closing-soon-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.tender-section.dimmed { opacity: 0.75; }
.tender-section.dimmed:hover { opacity: 1; transition: opacity 0.2s; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.section-header.urgent {
  background: rgba(248,113,113,0.05);
  border-bottom-color: rgba(248,113,113,0.15);
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.section-dot.high      { background: var(--tier-high); box-shadow: 0 0 6px rgba(74,222,128,0.5); }
.section-dot.amber     { background: var(--tier-amber); box-shadow: 0 0 6px rgba(251,191,36,0.5); }
.section-dot.low       { background: var(--text-muted); }
.section-dot.dismissed { background: #374151; }
.section-dot.urgent    { background: var(--tier-red); box-shadow: 0 0 6px rgba(248,113,113,0.6); animation: pulse 2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(248,113,113,0.6); }
  50% { box-shadow: 0 0 12px rgba(248,113,113,0.9); }
}

.section-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.section-count {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ─── Tender cards ───────────────────────────────────────────────────────── */
.tender-list { padding: 8px; }
.tender-list.collapsed { display: none; }

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.tender-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: all 0.15s ease;
  position: relative;
}

.tender-card:last-child { margin-bottom: 0; }

.tender-card.tier-high {
  background: var(--tier-high-bg);
  border-color: var(--tier-high-border);
}

.tender-card.tier-high:hover {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.3);
}

.tender-card.tier-amber {
  background: var(--tier-amber-bg);
  border-color: var(--tier-amber-border);
}

.tender-card.tier-amber:hover {
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.3);
}

.tender-card.tier-low {
  background: var(--tier-low-bg);
}

.tender-card.tier-low:hover {
  background: rgba(107,114,128,0.1);
}

.tender-card.closing-urgent {
  border-left: 3px solid var(--tier-red);
}

.tender-card.dismissed-card {
  opacity: 0.45;
}

.tender-main { min-width: 0; }

.tender-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 6px;
  word-break: break-word;
}

.tender-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}

.tender-title a:hover {
  color: var(--cyan);
  text-decoration: underline;
}

.tender-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.meta-tag.municipality {
  background: rgba(14,165,233,0.1);
  color: #7dd3fc;
  border: 1px solid rgba(14,165,233,0.2);
}

.meta-tag.platform {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.meta-tag.keyword {
  background: rgba(74,222,128,0.08);
  color: #86efac;
  border: 1px solid rgba(74,222,128,0.15);
}

.meta-tag.keyword.amber {
  background: rgba(251,191,36,0.08);
  color: #fcd34d;
  border: 1px solid rgba(251,191,36,0.15);
}

.meta-tag.closing {
  background: rgba(248,113,113,0.1);
  color: #fca5a5;
  border: 1px solid rgba(248,113,113,0.2);
}

.meta-tag.closing-soon {
  background: rgba(248,113,113,0.18);
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.35);
  font-weight: 500;
}

.meta-tag.scraped {
  color: var(--text-muted);
  font-size: 10px;
}

/* ─── Card actions ───────────────────────────────────────────────────────── */
.tender-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
}

.btn-action:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-action.dismiss:hover {
  color: var(--tier-red);
  border-color: rgba(248,113,113,0.3);
}

.btn-action.restore:hover {
  color: var(--tier-high);
  border-color: rgba(74,222,128,0.3);
}

.btn-action.view {
  background: rgba(34,211,238,0.08);
  border-color: rgba(34,211,238,0.2);
  color: var(--cyan);
}

.btn-action.view:hover {
  background: rgba(34,211,238,0.15);
}

/* ─── Collapsed toggle ───────────────────────────────────────────────────── */
.tender-list.collapsed { display: none; }

/* ─── Closing soon section ───────────────────────────────────────────────── */
.closing-soon-section .tender-card { background: rgba(248,113,113,0.06); border-color: rgba(248,113,113,0.2); }
.closing-soon-section .tender-card:hover { background: rgba(248,113,113,0.1); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 999;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; }
  .stats-inner  { padding: 0 16px; gap: 0; overflow-x: auto; }
  .filters-inner { padding: 12px 16px; }
  .main { padding: 16px 16px 60px; }
  .stat { padding: 0 16px 0 0; }
  .stat-divider { margin: 0 16px 0 0; }
  .tender-card { grid-template-columns: 1fr; }
  .tender-actions { flex-direction: row; }
}
