:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #dde1e7;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #1e40af;
  --primary-hover: #1d3fa0;
  --high: #16a34a;
  --mid: #d97706;
  --low: #6b7280;
  --red: #dc2626;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

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

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

/* Navbar */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.navbar .brand { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.navbar .nav-links { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.navbar .nav-links a { color: rgba(255,255,255,.85); text-decoration: none; font-size: 13px; }
.navbar .nav-links a:hover, .navbar .nav-links a.active { color: #fff; }
.navbar .user { color: rgba(255,255,255,.6); font-size: 12px; margin-left: 8px; }

/* Main */
main { max-width: 1400px; margin: 24px auto; padding: 0 24px; }

/* Alerts */
.alert { padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: var(--red); }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--high); }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary); }

/* Login */
.login-box {
  max-width: 380px; margin: 80px auto;
  background: var(--surface); border-radius: 10px;
  padding: 40px; box-shadow: 0 4px 20px rgba(0,0,0,.1);
  text-align: center;
}
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }
.login-box label { display: block; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; margin-top: 16px; }
.login-box input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--primary); }
.login-box button { width: 100%; margin-top: 24px; padding: 10px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: var(--primary-hover); }

/* Page header */
.page-header { margin-bottom: 16px; display: flex; align-items: baseline; gap: 10px; }
.page-header h2 { font-size: 20px; }
.page-header small { color: var(--text-muted); font-size: 13px; font-weight: 400; }

/* Filters */
.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.filters input, .filters select {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; min-width: 100px;
}
.filters button { padding: 6px 16px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 13px; cursor: pointer; }
.filters .btn-reset { padding: 6px 12px; color: var(--text-muted); text-decoration: none; font-size: 13px; }
.filters .checkbox-label { font-size: 13px; display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* Table */
.licit-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.licit-table th { background: #f1f3f7; padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sort-link { color: var(--text-muted); text-decoration: none; }
.sort-link:hover { color: var(--text); }
.sort-link.sort-active { color: var(--primary); }
.licit-table td { padding: 9px 12px; border-bottom: 1px solid #f0f2f5; font-size: 13px; vertical-align: middle; }
.licit-table tr:last-child td { border-bottom: none; }
.licit-table tr:hover td { background: #fafbfd; }
.licit-table tr.row-interes td { background: #fffbeb; }
.licit-table tr.row-error td { background: #fef2f2; }
.licit-table .exp { font-family: monospace; font-size: 11px; color: var(--text-muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.licit-table .titulo a { color: var(--primary); text-decoration: none; }
.licit-table .titulo a:hover { text-decoration: underline; }
.licit-table .titulo .desc-preview { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.licit-table .val { text-align: right; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.licit-table .org { color: var(--text-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-weight: 700; font-size: 13px; }
.badge.score-high { background: #dcfce7; color: var(--high); }
.badge.score-mid { background: #fef3c7; color: var(--mid); }
.badge.score-low { background: #f3f4f6; color: var(--low); }

.estado { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.estado-publicada { background: #dbeafe; color: #1e40af; }
.estado-adjudicada { background: #d1fae5; color: #065f46; }
.estado-resuelta { background: #ede9fe; color: #5b21b6; }
.estado-anulada { background: #fee2e2; color: #991b1b; }
.estado-enevaluación { background: #fef3c7; color: #92400e; }
.estado-prevista { background: #f3f4f6; color: #6b7280; }

.interes-mark { color: var(--mid); font-size: 16px; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; font-size: 13px; }
.pagination a { color: var(--primary); text-decoration: none; }
.empty { text-align: center; color: var(--text-muted); padding: 40px; }

/* Detalle */
.detalle { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; max-width: 960px; }
.detalle-header { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.score-big { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; flex-shrink: 0; }
.score-big.score-high { background: #dcfce7; color: var(--high); }
.score-big.score-mid { background: #fef3c7; color: var(--mid); }
.score-big.score-low { background: #f3f4f6; color: var(--low); }
.detalle-meta { flex: 1; }
.detalle-meta h2 { font-size: 18px; margin-bottom: 6px; }
.detalle-meta .organismo { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.detalle-actions { display: flex; flex-direction: column; gap: 8px; min-width: 140px; }
.btn-interes { padding: 8px 16px; background: var(--mid); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-desmarcar { padding: 8px 16px; background: #f3f4f6; color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.btn-enlace { display: block; padding: 8px 16px; background: var(--primary); color: #fff; border-radius: var(--radius); text-decoration: none; font-size: 13px; text-align: center; }

.detalle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.field { }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.field span { font-size: 14px; }

.detalle-section { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 4px; margin-bottom: 20px; }
.detalle-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.score-breakdown { display: flex; gap: 20px; flex-wrap: wrap; }
.sb-item { background: var(--bg); border-radius: var(--radius); padding: 12px 16px; min-width: 140px; }
.sb-label { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.sb-val { font-size: 20px; font-weight: 800; display: block; }
.sb-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }

.detalle-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }
.detalle-footer a { color: var(--primary); text-decoration: none; font-size: 13px; }
.detalle-footer small { color: var(--text-muted); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.stat-card.high { border-color: var(--high); }
.stat-card.mid { border-color: var(--mid); }
.stat-num { font-size: 32px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
h3 { font-size: 16px; margin-bottom: 12px; margin-top: 24px; }
